I am hoping someone can point me/us in the right direction, or offer up some suggestions. We are attempting to write date and time to a Siemens PLC over OPC. For some reason we can only write the “seconds” value, when we try multiple tags everything stops writing. Here’s the setup…
-
We have OPC connections to Siemens S7 PLCs that we need to write the date and time to. Tags in Siemens are structures with DTL datatype.
-
When we import them they show up as Document datatype with a JSON value.
-
We setup UDT with Derived tags using Read and Write jsonGet({source},{TagName}) and jsonSet({source},{TagName},{value}) expressions
-
We have a derived [System]Gateway/CurrentDateTime tag that triggers the script on changeValue
-
Script uses system.data.get functions to pull each item that needs to written to derived tags which sets to the JSON
ts = system.date.now()
day = system.date.getDayOfMonth(ts)
hour = system.date.getHour24(ts)
minute = system.date.getMinute(ts)
month = system.date.getMonth(ts)+1
sec = system.date.getSecond(ts)
weekDay =system.date.getDayOfWeek(ts)
year = system.date.getYear(ts)tagPaths = [
“…myPath to derived tag…/Day”,
“…myPath to derived tag…/Hour”,
“…myPath to derived tag…/Minute”,
“…myPath to derived tag…/Month”,
“…myPath to derived tag…/Second”,
“…myPath to derived tag…/Year”
]
values = [day, hour, minute, month, sec, year]
system.tag.writeBlocking(tagPaths, values) -
When only 1 path and 1 value it works!! ie seconds
-
When multiple paths and values are written it fails
We have tried;
system.tag.writeAsync(tagPaths, values)
system.tag.writeBlocking(tagPaths, values)
trigger tag in tag folder, as a UDT and Gateway Timer Script - they all produced the same result… 1 tag, 1 value will update, multiple will not
This is a strategy that we are looking to use for various data structures between the Ignition and the Siemens PLCs
Anyone have an idea of what is happening, wondering if we should be looking at a different approach.