PLC programming - Adding numbers question

programist

Member
Join Date
Jan 2014
Location
World
Posts
23
All,

I was wondering. How do you add a number to another number(say level input) only once, to keep it constant.

Example: You have Num1, which is some kind of input reading from a sensor. You want to add 100 to that number. So instead of X it will show X+100.

ADD instruction works every scan. What's the best way without using ONS.

Thanks!
 
Use OSR?

Seriously, the one-shot instructions are there for precisely that purpose, to set a bit on the edge of an event which may last for more than one scan.
 
Your example doesn't make sense.

If you are reading from a sensor, and want to put an offset of 100 on it, you'll have to do that every scan as the sensor reading will constantly change, so you'll need to constantly add 100 to it to maintain it.

If you just needed an initial sensor input + offset as a reference, then yes an ONS/OSR would be what you would use. Of course you could always add a latch to ensure it only happens once, but the ONS/OSR is simple and obvious.
 
Not sure we have enough info of your application. If you're continuously monitoring Num1 and you always want an offset of 100, you'd need a second variable, say Num2 (Num2=Num1+100). If your capture of Num1 is event driven, then again you'd use a second variable Num2 but only add the 100 at the time of capturing Num1's value. Do this with a oneshot (ONS or OSR as already stated).
 
To clarify, I want to put an offset on analog input (num1). I thought there might be a function already build it for that. (example: Num2=Num1+100 with one shot).
 
Like Paully and Steve said, just use ADD since your input change with every scan you need to add this offset every scan, that's the very definition of doing an offset
 

Similar Topics

Hello colleagues, Some time ago I started my adventure with programming. With your help and the courses, things are starting to come together...
Replies
13
Views
682
Dear All, I need a sample PLC program to count the output pulse of a mass flow meter so that a specific amount of mass (for example 100gm)can be...
Replies
2
Views
148
Hi Please I have zeilo smart relay #SR2A201BD but I don't have it's programming cable. Can I use any general usb/rs232 converter? Or need...
Replies
3
Views
161
Hi, Does anyone have thoughts or know of, can point in the right direction any published materials with a plumbing centric point of you explaining...
Replies
1
Views
164
@ All: what is your best guess on a potential range in increase in efficiency in % (i.e. saved programming hours, greater output, etc.) when...
Replies
5
Views
349
Back
Top Bottom