I have a boolean tag for indicating status of the machine.
True - means the machine is running
False - means the machine is down.
Blinking (changing state true /false) - Idle time
Now the first two status is very easy, but the 3rd status is a little bit tricky on how am I going to detect wether this boolean tag is blinking.
Basically the condition is, if it is blinking or changing state for 5 seconds then the status would be IDLE.
I am hoping someone in this forum have the same scenario I have, expression alone cannot do it. I wanna know how you guys do it.
Any tips and suggestions would be highly appreciated.
Thanks in advance.
Regards,
Hello Henrol,
You could do a count of how many times the tag change using the value change scripting. Write this value to a memory tag and if the value is over a said amount send the value 'IDLE' to where you want it. Then reset the memory tag in an interval of time that seems appropriate for the situation.
This sounds like either a misunderstanding or bad design. Usually, machine status is characterized by an integer: 1-ON, 2-OFF, 3-ESTOP, 4-IDLE, etc.
From there you would display it as a blinking LED based on the integer. I would check your data sources and see if your machine state has this characterization available, that is, check and see if your boolean tag is an expression tag or an opc tag. If it is an expression tag, find the opc tag that it refers to.
4 Likes
Thanks for the tip! Highly appreciate it.
1 Like
Yeah I agree with you, we are not the supplier of the PLC program (siemens) so it is what it is, we have to adjust what it's in there.
I'm curious. Where is this information being used? Is it for display in a chart, or is it some sort of static indication like a label?
...or is it for use outside the UI such as in a report?
I imagine this will have to be scripted, so shedding some light on the use area could generate simpler or more direct solutions.
This might get you out of a hole - but note the warnings.
Create an expression tag to monitor the machine status bit. Use the expression,
if({[~]statusBit} && now() - {[~]statusBit.Timestamp} > 5000, 2, // Running
if(!{[~]statusBit} && now() - {[~]statusBit.Timestamp} > 5000, 0, // Stopped
1 // Idle
)
)
It relies on the calculating how long the statusBit has been in that state from its OPC timestamp. This may give an erroneous reading if the tag server is restarted or anything funny goes on, but in general it should be good enough, I suspect.
Note also that when the statusBit changes state we have to assume the machine is in idle state until we've seen it in that state for > 5 s at which point we can announce "Running" or "Stopped".
2 Likes
Yes it is for display only.
So the customer is like providing us behaviour of the machine for different state, and one of them is Idle (blinking DO). So yeah, its kinda rare, but we have to face it.
I like this idea.
Short and simple.
What I've done is I use gateway scripts to check wether a change of state (blinking) is greater than specific value.
It works as it is, but this one is simplier, thank you for this, I will try on it!