Trigger an output when a number changes

Need a bit more information, for example, how often will it change, how long do you keep the output on for,
Do you want to do this every scan of the plc?
How do you intend to turn off the output.
 
Reply:

Number that changes is the line speed. so it won't change regularly. may be 20 times a day. I would like to check for changes in the line speed every scan cycle or every second and move the previous line speed value to a different tag every time the speed change. Thank You
 
NEQ LineSpeedAct LineSpeedMem BST MOV LineSpeedMem LineSpeedPrev NXB MOV LineSpeedAct LineSpeedMem BND

If you need to keep track of all changes, then you'll need some kind of queue (like a FIFO) instead of just MOV to another tag.
 
My method, in Rockwell land, is:

NEQ(CurrentValue, TempValue) OTE(ValueChanged) MOV(CurrentValue, TempValue)

Every time CurrentValue changes, the ValueChanged BOOL will come on for one scan.
 
The problem with monitoring conveyor speed, if you are monitoring an analog input from the conveyor, is that the value will change almost every scan. You would have to program in a range or average, then watch that over time.

I have programs monitoring a process, like conveyor speed or hydraulic pressure, and at a time interval (1/2 second to 2 seconds) adjust the output up or down to keep it as close to the setpoint as possible, and it does change the output almost every pulse of the timer.
 
I have programs monitoring a process, like conveyor speed or hydraulic pressure, and at a time interval (1/2 second to 2 seconds) adjust the output up or down to keep it as close to the setpoint as possible, and it does change the output almost every pulse of the timer.


I will wager that control scheme is chasing the noise and adding to it. If the control scheme was changed to only make the adjustment when the measured value was outside a deadband bracketing the setpoint, the variation would be less. It can be shown this is the true for a similar case: a PID controller with noise in the PV.



That said, this is an academic point, because the current level of variation is probably acceptable.
 
Last edited:
The other posts are valid, it could change every scan so yes a range would be best.
Here is a quick ladder (no idea what PLC you are using).
Caveats:
It only updates the last value if there has been a detected change as if the change is less than the upper/lower limits then it could creep up without detecting a change. for example if updated every scan and if the change was less than any limit and you update the last value then this becomes the last value so it could gradually creep say from 100 to 1000 in increments of less than the range.
However, by only storing the last value when there is a change outside of the limits will it update, this means from the last change if the current value is > or < then it will increment the count.
I have incorporated a count of the change rather than set a bit this seems a better idea if you want to know how many changes there are in a shift.
Also notice on first scan of PLC the last value is updated to the current.

Change.png
 
The problem with monitoring conveyor speed, if you are monitoring an analog input from the conveyor,


I read the question from the OP differently. The way I understood it is that the value he wants to store is the previous setpoint value every time an operator changes the speed setpoint e.g. via a HMI screen or some up/down push buttons. That would be much easier than a speed value that is being read from the process (either via an analog input or for instance by counting pulses from a rotation guard sensor on a digital input). A speed input read from field sensors is likely to be changing slightly all the time so would need decent filtering to reduce jitter. Without filtering one might expect a new value stored just about every scan.



Perhaps ranasingheum can elaborate on what it is exactly that he wants to store.
 
Yes you may be right, it would be simpler just remove the ranges, compare the actual with the last & update the last with current, and increment the count.

Change.png
 
I read the question from the OP differently. The way I understood it is that the value he wants to store is the previous setpoint value every time an operator changes the speed setpoint e.g. via a HMI screen or some up/down push buttons.

That was my take on the OP also.

I had to mention the IF part if he was monitoring the feedback.
 
Number that changes is the line speed. so it won't change regularly. may be 20 times a day. I would like to check for changes in the line speed every scan cycle or every second and move the previous line speed value to a different tag every time the speed change. Thank You
I don't forum is asking the right question.
What EXACTLY is changing the line speed?
Is it the measured line speed or the set point line speed?
This makes a huge difference.
 
Is it the measured line speed or the set point line speed?
This makes a huge difference.

I'm surmising it's the set-point too, otherwise how could he predict how many times a day it will change ?

But until he returns to clarify .....
 
This should work for both setpoint and measure. Just set hysteresis value big enought if needed.



value_plus_hyst:= saved_value + hysteresis
value_minus_hyst:= saved_value - hysteresis



input_changed:=0; //oneshot bit


if input > value_plus_hyst
then
saved_value:= input;
input_changed:=1;
end_if;

if input < value_minus_hyst
then
saved_value:= input;
input_changed:=1;
end_if;
 

Similar Topics

Hi i would like to ask! Im using Omron CP1E PLC May i know how to use one input to trigger two outputs alternatively? Meaning press X0 on, Y0...
Replies
11
Views
398
Hi, I'm using CX Programmer and just seeing what the best way to trigger an output from the plc clock time would be. I need this to come on at 9am...
Replies
4
Views
1,742
Most I have come across is two loads switched on simultaneously using a single output point. Typically, an indicator lamp and a relay coil...
Replies
8
Views
2,905
I am trying to trigger an output twice after a duration of time. The operator has to trigger a laser from the HMI. This fires the coil. Which...
Replies
3
Views
1,530
Hi everybody, I'm using SIEMENS S7 212, one imput (I0.0) which was use in the program will indicate ON on the input LED display when pressed...
Replies
7
Views
1,960
Back
Top Bottom