Interpolating tag history to get count for a time or period

I have a tag’s value being logged (in the default historian) every time the run status changes (stop-to-run and run-to-stop). The production rate is fairly constant so interpolation should give a reasonably accurate cycle count. The cycle count does not reset at end of shift / batch.

What is the best way to get an interpolated count of machine cycles for a period of interest? I’ll be using these for a dashboard display so efficiency would probably be the important parameter.

Here’s an example of something that doesn’t quite work.

Figure 1. Test tables.

All three tables are looking at the same tag.

  1. The DateTime selector is set to 11:00.
  2. This table returns data from 30 minutes before 11:00 (10:30) until 12:30.
  3. The ‘AsStored’ data shows a count at 10:54 and the next at 11:08. There is no record any closer to 11:00.
  4. Same as (2) but with 1 minute periodic period setting.
  5. The value for 11:00 looks about right about mid-way between the readings either side of 11:00 at (3).
  6. This has the same binding as (4) but with the period set to 10 minutes and the time period is set to 11:00 to 12:00.
  7. The first value returned is that of 11:09 in table (2).

It’s not at all clear what’s going on behind the scenes.

Is it possible to -

  1. Retrieve an interpolated count value for 11:00?
  2. Retrieve interpolated count values for 11:00 and 12:00?
  3. Retrieve the interpolated count difference between11:00 and 12:00?

Further testing gives:

Figure 2.
The Figure 2 tag history binding is set to

  • Query mode: Periodic.
  • Period: 1 MIN.
  • Time Range: Historical.
  • Start Date: = time setting.
  • End Date: = time setting.

Is this my best approach?

Many thanks.

I think the Event meter in transaction groups was made for this. Check out this video.

Also, I think this will solve a problem I’ve been working on: the hour meter will measure how long a condition is true.

Thanks, Bryan, but that’s not quite what I want. I want to be able to return a reasonably accurate shift production count between two specified times. I’ve updated the question with a screengrab from a test application.