I have a machine status tag (M_STAT) from the PLC which is an Integer, 0=Stopped, 1=Running, 2=Faulted, and is being logged OnChanged to the database.
Is there a tag history function or script function to find the durations for each of the three states in the past 12 or N hours, without needing to create additional tags?
Do you mean to the Ignition Historian? If so, then no. You will have to retrieve the records as stored and then write a script to calculate the totals.
You also now have the additional problem of figuring out what state the machine is in at the start of the period of interest - particularly if it never changes state during the period.
The historian doesn't extrapolate data to the start and end timestamps and this makes it of little use (in my opinion) for many applications. As a result we're using a dedicated table to record tags onChange and on a gateway scheduled event (every 15 minutes in our case) so that we always have a value for the start of any shift pattern (which will always start / end at :00, :15, :30 or :45). The data table columns in our case are
- timestamp
- machineId
- runStatus
- stopCode (what was the first-out alarm that caused the machine to stop)
- countGood
- countTotal
- productCode
That gives a pile of useful information for OEE, etc.
2 Likes
Yes I mean Ignition Historian. I was hoping there would be something quick. I am going to create 3 new boolean tags for the 3 states. And write on change script at the M_STAT tag, turn on the associate bit and off the other bits. And use Ignition DurationOn to get the durations. But I can't use this for past data.
Don't do that.
Instead, create expression tags with an expression like
{[~]MyTag} = 1
This will be much more efficient that firing up a script.
1 Like
Yes, that's much better. Thanks!