Today is...
Tuesday, September 19, 2017
Welcome to Control.com, the global online
community of automation professionals.
Featured Video...
Featured Video
Watch an animation of a conveyor stacking operation demonstrating the use of a move on a gear command.
Our Advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive
Adding a Tag Value onto Itself in Ladder Logic
What is the equivalent PLC logic to perform to add a tag value onto itself?

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.

By James Ingraham on 4 February, 2016 - 2:58 pm

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.