I have a PLC tag reporting on a photoeye that counts from 0 to 200 whenever it is blocked, then it resets to zero and when it is blocked again, it starts counting again. I want to know the number of times this is reset to zero. I have added the tag and selected it as an event meter, accumulating on zero. It counts just fine and I can get the total at the end of the shift from the database by looking at the value of that field. I would then like to reset this counter to zero and when they start again the next day, it will begin counting at 1. I am not sure where I need to reset this counter. I tried reseting the field in the database to 0, but the next entry from FSQL just writes a value incremented from what the original value was.
Do I need to configure an action item from FSQL to reset it at a certain time? Thanks in advance for your help.
Writing to the correct database field should be enough… I just gave it a try and it seemed to work ok (note: it should work irregardless of the item direction- even opc to db should be fine).
What version of FactorySQL are you using? How quickly is the group executing? Is the item set to opc to db, or to a different mode?
Ooh, and I missed an obvious question: is the group set to insert a new row each time?
If the group is set to insert, it will just write what it has in memory, and will never read from the database. In that case, it is strangely difficult or impossible to reset the counter… seems strange, but nothing comes to mind…
Instead, what I normally think of in cases like this, is to have the tracking group set to “update last row”, and then to have another group (or an action item) that inserts a new row periodically in order to create a new shift/count. If the new row has default values of 0, the counters will start from there.
Hmm, strange, do you have the “store audit log” option checked? It’s disabled if the group is OPC->DB, but I think there’s a small bug that’s been encountered before where it causes problems if it’s set and then the group is switched back to OPC to DB.
So, try changing the group to bi-direction, uncheck “store audit log”, and then switch it back to opc->db.