Hello Guys , i have this Cumulative Energy Tag
This value is increasing continuesly. I want to have the Daily Cumulative Energy instead of Having the Total Cumulative Energy. What is the Best possible way to do it ?
Not sure if it is the best possible solution, but I would create an additional memory tag that stores the cumulative energy on the day previous. Then have a expression tag that subtracts the previous day value from the total cumulative energy.
Have a script that updates the previous day value, once every 24 hours.
Note: This solution would not give a 24 hour rolling value but a value that resets to 0 at the start of each day, which I believe is your goal?
Hi Nathan , thank you for the replay , Can you guide me please ? I have limited Scripting experience. i dont mind reseting the value to Zero since it will be logged Daily , So at the logs will appear for each days the Energy produced.
I strongly advise logging (in a database) the cumulative reading. Then you can calculate consumption over any period you want including current daily total (live tag reading - period start count). It also means that if the logging fails for any reason you will be able to interpolate for the missing data.
I also recommend doing this logging to your own table on a gateway scheduled event rather than using Ignition's historian. The historian doesn't do interpolation well and you won't get an exact value for midnight, etc. Set up the table with columns id, t_stamp, meterno, kwh, kvar
and anything else that might be useful.
Transistor is correct, if you're using a database already, that is likely a better solution.
You could have a Daily Scheduled Gateway Event
that every day at 00:00 sets that tag to 0.
It would set it to 0 and you would have a daily cumulative energy tag.
I also would do it in another tag, not in the same one so you wouldn't lose information.
Don't do this. You can, and eventually will, lose data in the brief interval between reading the last value and writing zero. And you are screwed if anything interferes with running your script.
Non-resetting totalizers and counters are the most robust way to handle quantities as opposed to rates. The OP has the most robust source data. Don't recommend breaking that.
(Snapshotting the single non-resetting value more often than once per day increases your resolution without requiring additional real-time code in the source device. Hourly or every 5-minutes is common.)
What do you mean with:
Also, if you have the tag that OP showed and you create another tag that does what I said. You really don't lose data, you simply have a copy that could (rarely) have a small data error (that I don't know if is viable to lose).
I really encourage doing something like @Transistor said, but I think that op is looking for something easy. If he considers that making a copy and being able to lose a bit of data is viable, it is a good idea (in my opinion).
Is there a chance to show me an example ? I will appericate it very much.
Hope this helps.
However, take into account all the things that have been said in this thread. You could lose information.
And really important, create ANOTHER tag, do not do it in the one you have!!!
Take care.
PS: This is a solution, but is not a good long-term solution
If you do that, it's better to just copy the non-resetting value to it, and use subtraction to display the delta. Never any data loss.
Only the PLC that is doing the accumulation can "atomically" copy a day's total and reset to zero without losing whatever happens during the communication round trip.
I think not. I would down-vote this if the forum supported it.
If the OP doesn't mind losing that tiny bit of data... Is an easy fix.
Also, the only thing that I think that could go wrong is if the system is down and it doesn't reset the tag at 00:00 so you could have multiple days data.
He means exactly what transistor suggested. Do not reset the reading, instead log the value with a timestamp in the database, ie snapshot. Then in a query you can determine the delta between the values and timestamps.
thank you Daniel for this , The value is coming Directly from A Power Quality Analyzer
Daniel Hi again . it Seems it is complicated for me to implement this. Is It possible to do it with a simple Query Tag , to Request this every day at a specific Time ? What i mean i can pull this value 01:00 in the morning.
Why would you want to use a Query Tag? Do you need it? Do you have the daily value store in the database?
Have you setup a database table to log your values yet? If not, read @transistor's post again. First step is to get a DB table to log your values periodically.
Do you have the SQL Bridge Module?
yes i have setup a mysql database. But Ignition drops them in there all together. I dont know how to split it and make my tables as i want them. Sqlite it is much easier but you have limitations