Resetting Event Meters

I am using an event meter in FSQL to keep count of a certain event. I have an SQL update query reset the value to 0 at shift change, but the value in the field I’m resetting does not get to 0, it stays where it was. How can I reset this to 0 when a certain event occurs?



EDIT: I fixed it by using an action item and custom SQL query instead of the built in hour-meter tag function.

[size=75]I have the same question, but I wish to reset a tag being used as an hour meter.

I have a tag in the PLC who’s value represents a certain machine state: Idle=0, Running=1, Faulted=2, Maintenance=3, etc. Whenever this tag changes, one group adds a new record to the table (standard historical logging).

Another other group updates the last record in the same table every second, to accumulate time spent in a specific machine state.

When the machine state changes, the Hour Meter tag doesn’t reset since I am not always going from zero to nonzero and back again. Sometimes it is nonzero to nonzero to nonzero.[/size]

Added an action item in the group that triggers every second with the following SQL query. What it basically does is selects the last row in the DB, finds out what the current MachineState_Time field is at, add one, and save the value back.

UPDATE MachineState
SET MachineState_Time =
   (SELECT     TOP (1) MachineState_Time
   FROM          MachineState AS MachineState_2
   ORDER BY MachineState_ndx DESC) + 1
WHERE (MachineState_ndx =
   (SELECT     TOP (1) MachineState_ndx
   FROM          MachineState AS MachineState_1
   ORDER BY MachineState_ndx DESC))

Maybe you can try something similar for your counts, since I am basically counting as well.



You say you’re using a SQL query to set the value to 0 in the database. Is this occurring in the same group that has the event meter or somewhere else?

I just did some testing with the event meter and it seemed to reset correctly. If you could explain your group setup & reset mechanism a bit, maybe there’s something that will jump out.


Actually, we were able to track down an actual problem. It will be fixed in 4.1.5, to be released wednesday or thursday.