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.
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.