Adding old values to history logs?
I have a Modbus RTU communication to my AC800M controller. AC800M receives messages every 5 days. One of these Modbus messages can contain 5 values for a certain signal, one value per day for the last five days.
Is it possible to somehow put these values in 800xA history logs (OPC-log)?
I mean, at the moment the Modbus message is received, add 5 values to the log, where the oldest value should be placed "5 days ago" in the log?
Voted best answer
Regular logs takes their timestamps from the OPC server's internal clock. Hence, you can not inject "old" data into such logs.
I believe that you might be able to inject data with user defined timestamps using a Calculation and a labdata log.
Your calculation must read the values and timestamps from the PLC (or calculate the timestamps itself and set it on the output the example uses NOW() to set present time but with appropriate formula I assume any time can be provided). The lab data logs are written when the calc code has executed. To supply 5 entries into the same log, the calc must run 5 times in a row, each time providing a new set of value/timestamp.
Calcs can be triggerd by cyclic schedule, or on OPC DA update. Hence, the whole logic can be driven by the PLC if you like. The PLC prepare value+timestamp on two properties and write a trigger on a third property which the calc triggers on. Wait some time, set new values and give new trigger. Just have to figure out how to calculate the timestamp, e.g. Integer Long from OPC and then convert into whatever the calc need inside the calc. Avoid strings if possible.
Labdata logs does not collect data, data has to be supplied by "external force" via OPC HDA interface, e.g. from a Calculation. The log period is set as "number of samples" instead of a time period. A trend will display labdata just as if it had been read from a regular log.
I never tried it before, but from a developers point of view is it possible.
OPC HDA supports updating data.
Now I have a solution!
It was abit of a pain, but it kind of works.
A calculation aspect is triggered from application in PLC.
This calculation gets a value, timestamp and quality from application in PLC and injects them in a LogConfiguration that is based on a "Lab Data" log type.
The only thing that does not work is when a subtraction of an amount of time from a point in time results in "the month before". Those timestamps will be rejected by log.
Thanks alot Stefan Strömkvist for the "halmstrå" !!! ;-)