Ignition – Creating a Downtime Tag Using Machine Running Status

How can I create a downtime tag in Ignition using an existing Running tag, where 0 indicates the machine is stopped and 1 indicates it is running?

I tried creating a memory tag to track downtime, but I'm running into an issue where the timestamp stays at its original value instead of updating when the machine starts running again. As a result, the downtime continues accumulating rather than resetting each time the machine resumes running.

I'm looking for a way to have the downtime timer start when the Running tag changes to 0 and automatically reset when it changes back to 1, so it accurately tracks how long the machine has been stopped during each downtime occurrence. And also having the time be saved so I can create a report

Typically, you'd make an expression tag named Down with the expression [.]Running = 0 and turn on history.

For reports, use the "DurationOn" aggregate mode on the Down tag in a history query.

I'd do it with two tags. [.]StoppedAt and [.]Downtime. Add a change script on [.]Running when it transitions to stopped it writes the time into StoppedAt. Then Downtime is a simple expression, if running then 0 otherwise the time between StoppedAt and Now.

A nice feature that isn't widely discussed is the Timestamp field native to all tags. I have a tag for tracking the current state and then I use this expression to get the # of seconds the machine has been in that current state.

secondsBetween({[.]State.timestamp}, now())

Be aware if the PLC connection blinks, or the gateway restarts, or even just the tag itself restarts, the timestamp will change.

If you really want to be correct, use history. Or some kind of DB table.