Historical Usage from Meter Values

I have an ignition project setup where I am trending the value of a water meter over time. Every thirty minutes, the register value of the meter is stored. I am trying to figure out a way to use this data to show the usage for given periods.

I created an easy chart and can view the reading at the meter over time. However, I cannot seem to figure out how to display the amount of water used for a given hour; only the value of the meter at the start of the hour and the end of the hour.

I tried creating a pen that took the maximum value in a period and one the took the minimum value in a period. I then created a calculated pen that took the difference. However, every time I tried this, I got a null exception error from java.

Does anyone have a suggestion on how to do this? Thanks

This is a common requirement when handling time-series recordings of totalizers. Unfortunately, Ignition’s default database (MySQL) doesn’t support the windowing functions that everyone else uses to compute deltas from totals on an interval, and Ignition’s tag history functions won’t do it either. Two options:

  1. Use PostgreSQL or Oracle or SQL Server – anything that supports window aggregates – and query the tag history yourself. Use the LAG() function to access the previous row’s value vs. the current row’s value.
  2. Use jython to post-process a dataset from system.tag.queryTagHistory() to compute delta time and delta total for each pair of rows returned. Use intervalHours=1 and aggregationModes=[‘LastValue’] to get the ending value for each hour.

Thanks for the help. I was able to get it working using your second method. I am fairly new to ignition and as I get into it more, I constantly amazed at some of the richness of the features but also dumb-founded at some features that seem to be missing.

Is it possible to insert a scripted dataset into an easychart? Or do I have to use one of the other charts that has the data object exposed?

Thanks again,
Dan

[quote=“danFromNj”]but also dumb-founded at some features that seem to be missing.
[/quote]To be fair, this stuff isn’t exactly easy.[quote=“danFromNj”]Is it possible to insert a scripted dataset into an easychart?[/quote]No, but you could create a view in your database with the appropriate calculations and use a DB pen.[quote=“danFromNj”]Or do I have to use one of the other charts that has the data object exposed?[/quote]This would be the path of least resistance if you’ve already worked out how to generate the dataset.