Adding a Tag Value onto Itself in Ladder Logic

D

Thread Starter

dschmidt

What is the equivalent plc logic to perform this operation:

Delta = NewValue - OldValue

NewValue = NewValue + Delta

Where the old value is x minutes or seconds old

Examples with ladder logic, structured text, or function blocks would be great.
 
J

James Ingraham

It's difficult to give ladder or FBD examples. The structure text, however, is virtually unchanged from your question, with the exception of adding colons and semi-colons.

Delta := NewValue - OldValue;
NewValue := NewValue + Delta;

In ladder logic, the same idea applies. In your subtract or add block you simply put the tag in as both an input and the output.

Note that this code is almost certainly not what you want. Something like this might be more appropriate:
Delta := Timer.ACC - OldValue;
Elapsed_Time := Elapsed_Time + Delta;
Old_Value := Timer.Acc;

-James Ingraham
Sage Automation, Inc.
 
Top