How to reset an event meter item

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?


FSQL Version
Updates every 30 seconds.

Here are the last few lines from the table. You can see that I updated the row in the database to zero a couple of times, but it ignored it.

2084 181 2009-09-02 09:44:07.283 192
2083 181 2009-09-02 09:43:37.287 192
2082 180 2009-09-02 09:43:07.273 192
2081 180 2009-09-02 09:42:37.280 192
2080 179 2009-09-02 09:42:07.277 192
2079 0 2009-09-02 09:41:37.280 192
2078 179 2009-09-02 09:41:07.277 192
2077 0 2009-09-02 09:40:37.280 192
2076 178 2009-09-02 09:40:07.287 192
2075 178 2009-09-02 09:39:37.280 192
2074 178 2009-09-02 09:39:07.273 192
2073 177 2009-09-02 09:38:37.293 192

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.

Let me know if this helps at all…

I just switched to the update last row and got this error on the group when I restarted it:

Group Execution Error
Error executing data query: ERROR [42S22]
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid
column name ‘log_user’.

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.


That did it. My group started without an error and I am able to reset the value, just like you said. I should be good to go now.

Thanks for the help.