Two tags are being updated as many machines change speeds.
I want to parse these changes into the respective machine speeds.
example the inputs:
ID tag: 1000054
speed tag: 1001
Then after a few seconds, it might read:
ID tag: 100054
speed tag: 0
ID tag: 100067
speed tag: 0
My machines are like BR1, BR2, PK-5 for a few examples.
I can get the same speed consecutively.
I can get the same machine consecutively.
So my first question is, how do I detect the change correctly for when to run my script?
I don’t want a race condition that leads to reading the wrong speed for an extended period of time.
Let me see if I understand your intention correctly: are you wanting to use the ID tag value as a pointer to which machine’s speed you want to update with the value found in “speed tag”?
Another question that comes to mind is, do the ID tag and speed tag values always update simultaneously? If so, you could create an expression tag that is a concatenation of ID and speed, and run a tag change event script on the expression tag, since its value will change if either source value changes.
yes, and I want to avoid a race condition.
If the speed tag is the same, I don’t think an on-change for speed is triggered as the value is the same.
Scenario 1
Speed comes in the same value, for a different machine.
I don’t think the speec tag will detect a change to trigger a script.
scenario 2
Same machine gets a speed update.
I don’t think the machineid tag will detect a change to trigger a script
I have a hard time describing this. Sorry
Is there a way to have a tag that will indicate if either of those two tags changed?
Or am I worried about a race condition that is not a conflict of concern?
You cannot get rid of the race condition. Any time you read these, in any order, you cannot be sure the fresh value goes with other read just before it.
This is a terrible design for multiplexing. Don't do it. You will get speeds allocated to the wrong machine, randomly.
2 Likes
edit: I pretty much have to find some trigger in the plc that doesn’t have the condition or write one basically.
Thanks again.
Have separate speed tags for each machine, ideally.
Otherwise, you need a trigger tag and echo tag for a proper handshake, and use a scripted OPC read to pull in the speed & machine after the trigger. The PLC must increment the trigger after setting both speed and machine, then absolutely not touch them until Ignition echoes the trigger.
It has a datetime short array of integers. (year, month, day, minutes, seconds all integers)
Rs logix
If I try to make that a tag though, the path doesn’t save.
Seems to not like trying to collect that information.
edit: found a post where a guy used 3 UDTs to get the array. I am going to see if my plc has a trigger I can use for when it captures the date time.
edit: found a tag to use as a trigger to read both ID and speed, to write the speed.