OPC UA Source timestamp

Hi, is it possible to set the source timestamp for an OPC UA event/message manually, ie via FB call or similar? Thanks

Hi, I don’t think that’s possible. Out of interest, what would be the application for this? If there is additional timestamp information to be provided with a process value - perhaps the time in the past that a sample was taken, for example - then you could create a STRUCT data type as the OPC UA variable, with the data value and the additional timestamp information as fields in that struct. Does this help? ~ Martin.

We’re getting timestamped messages from subsystems in a proprietary format. We need to pass on the events with opc ua, including the timestamp. Sadly, the struct solution has already been rejected by the customer…

Hmm, it sounds like the subsystem needs its own OPC UA server, which would provide its own “source” timestamp values to OPC UA client(s). The idea of using the PLC’S built-in OPC UA server as a “proxy” OPC UA server for multiple data sources would probably not be practical. The quote below is from the documentation for the Unified Automation embedded OPC UA stack, which we happen to use for our OPC UA server (my italics):

The source timestamp is used to reflect the timestamp that was applied to a Variable value by the data source. It should indicate the last change of the value or status code. The source timestamp must be always generated by the same physical clock.

If the OPC UA server in the PLC was also acting as the OPC UA server for one or more sub-devices, then the “source timestamp” would be generated from different physical clocks, i.e. the clocks in each of the sub-devices, plus the clock in the PLC for locally sourced variables. This would break the rule above, which (I think) comes from the OPC UA specification. It seems like the solution in this case is to ask the device manufacturer for an OPC UA server for their device, or else write your own - although that would be a lot of work that probably isn’t worth the effort in this case. ~ Martin.



Ok, I guess I will look into some OPC UA stack in C / Python /Rust then, and call it from 61131. Customer wants his timestamps, rules or not :smiling_face: Thank you for your excellent support so far Martin!

There is a list of open-source OPC UA implementations here: https://github.com/open62541/open62541/wiki/List-of-Open-Source-OPC-UA-Implementations You might also be able to run an OPC UA server in a docker container using balena-engine on the PLC. ~ Martin.