Detecting a change in an integer value Step7

rpop91

Member
Join Date
Mar 2012
Location
Detroit, Mi
Posts
44
Hey again guys,

Having all kinds of issues this week. Is there a way to detect when an integer value changes? I need to set a BOOL every time the value of an integer changes. Is there a function block already for this?

Any help would be greatly appreciated.

Thanks guys!
 
I don't know how to express it in Step 7 but my way is like this:

If 'current integer' is not equal to 'previous integer' then turn on bit.

Move 'current integer' to 'previous integer'.
 
I do this with two rungs.
Rung A:
NEQ PRESENT_VALUE STORED_VALUE, XIO FIRST_SCAN, OTE THEY_CHANGED

Rung B:
*CREATE A HISTORICAL VALUE OF THE PRESENT_VALUE, FOR EVALUTATION NEXT SCAN*
MOV PRESENT_VALUE STORED_VALUE
 
I don't know how to express it in Step 7 but my way is like this:

If 'current integer' is not equal to 'previous integer' then turn on bit.

Move 'current integer' to 'previous integer'.

.. and here is the source code for a function block

Code:
FUNCTION_BLOCK FB 2
TITLE =
VERSION : 0.1


VAR_INPUT
  iValue : INT ;    
END_VAR
VAR_IN_OUT
  bChanged : BOOL ;    
END_VAR
VAR
  iStoredValue : INT ;    
END_VAR
BEGIN
NETWORK
TITLE =

      L     #iStoredValue; 
      L     #iValue; 
      <>I   ; 
      S     #bChanged; 
      T     #iStoredValue; 
      SET   ; 
      SAVE  ; 

END_FUNCTION_BLOCK
 
What they're saying in Ladder Logic...

2v3pn4g.png


On rung 5 (the rung you're looking for the change on), the only relevant instructions to you are the EQU and the MOV.
 
I do not have S7 here at the moment but it would be like this, you need to either reset M10.0 at some point or just make it an out M10.0 and it will be on for one scan of the PLC
So you just compare an integer with the last saved one & if it changes then it either sets a bit or equals a bit for one scan (if using an OUT coil)and then updates the saved integer so it is the same it will not trigger again until the value in DB10.DBW10 changes.
You can use any integer tags i.e. symbolic, DB.DBWxx or MWxx

Check.png
 

Similar Topics

I've been called to a site to assist with an ASi fault. The line has been down for a couple of weeks following a failure of the ASi power supply...
Replies
6
Views
1,317
I am looking at an application where I will need to detect small hairline cracks in stamped metal parts. The sensing will need to be done in the...
Replies
10
Views
1,147
Hello everybody, I am working on a project which has HMI FTView SE 13 (Local) and controllogix L71 PLC. I have a question how does PLC detect a...
Replies
0
Views
516
So, we have one servovalve that is very critical to machine operation and idea is (or was) to detect if valve gets disconnected from analog output...
Replies
11
Views
2,921
I had bought a used PLC before but I had to return it. Once in a while its run mode shut off momentarily. I had the PLC on my desk. (No I/Os...
Replies
22
Views
5,397
Back
Top Bottom