Increasing an output by a percentage

Rockman

Member
Join Date
Nov 2008
Location
florida
Posts
4
Hello I am fairly new to PLC programming and am trying to figure out how to write a particular program.

I am trying to write a program that will increase an analog output by 5% each time a button is pushed.

When the button is initally pushed I am going to move a value of 5% into a an interger register lets say N7:1. Each each time the button is pushed again I'm going to use the add function to add 5% to what is in N7:1 and then write the result back to N7:1.

In order to output whatever value is in N7:1 at any time I am going to put the value at N7:1 in a scaled output block and scale it 0-100% = 6553-32768.

So when the button is first pressed it will write a 5 into N7:1. When the button is pressed again it will add 5 to the value of 5 in N7:1 and write this total of 10 back into N7:1. This value of 10 will then be referenced to the scaled output block which will give it its corrosponding analog output.

Am I missing something here?
 
scale it 0-100% = 6553-32768.


before we go any further, please tell us where you came up with that range of numbers ... reason for asking 32768 will usually cause a fault if you try to drive an integer location that high in an RSLogix500-type processor ...

and welcome to the forum ...
 
I may be incorrect with these numbers however I thought these were the floating point numbers corrosponding with an analog signal value.
 
Rockman said:
I may be incorrect with these numbers however I thought these were the floating point numbers corrosponding with an analog signal value.

Those are integer values. They will depend on which analog card you have. Can you tell us the part number of the analog module you have and the processor your using.

See pic below for what Ron is talking about ( overflow values)
toohigh.jpg
 
Last edited:
See below for one method to increase number by 5.
The one-shot is there to insure the number only increments once per scan when button is pushed. The limit instruction is there to insure the value stays within limits.

IncreaseNumberby5.jpg
 
How about now for the second question in the homework problem, decrementing by 5% each time a decrement button is depressed.


Is it homework season already?
 
So far the posters have described how to add 5 not 5%. How about MUL N7:1, 1.05, N7:1?

The subtract 5% would of course be MUL N7:1, .95, N7:1.

Just as an exercise, after the above logic is working, try pressing alternating UP/DOWN/UP/DOWN etc. What do you see?

I guess I interpreted "add 5%" as add 5% of the CURRENT value, not 5% of the TOTAL POSSIBLE value.
 
Last edited:
I wondered about the same thing as Bernie, but then I noticed that the OP also said "when the button is first pressed it will write a 5 into N7:1. When the button is pressed again it will add 5 to the value of 5 in N7:1 and write this total of 10 back into N7:1." So then I had the question does he want to add 5% of the value, or does he have a 0-100% range and he wants to add 5% of the range but stated the problem incorrectly?

I'm assuming the latter, 5% of the range.

One way would be to use an up counter with a preset of 20. As long as the counter is not DN, allow it to increment. Use a down counter instruction on the same address to decrease the value, as long as its not zero, then decrement. Then multiply the counter accumulator by 5.

A11060801A.JPG


You could skip the mulitply by five and storage at N7:1 and scale the counter accumulator directly to your output, using 0-20 as the input range instead of 0-100.

However, if this is homework question you might want to consider what subjects you have covered recently in your class. If you have recently covered one shots and add instructons then perhaps the exercise is intended to cover those instructions and Mickey's example should be studied and understood, not just copied. If you have covered counter instructions, then the exercise is probably inteneded to cover counters.
 
Last edited:
Because I have an operating range of 0-100% I want to add just 5% everytime the button is pushed. I realize I made it sound confusing but basically I want to just add in 5% increments of 100 so each time I am looking to add 5.

I think with some of the guidance above I have enough information and I am programming it now to see how it will work.

Thanks for the help.
 

Similar Topics

I have an application where I need to reduce the travel of an actuator and also double the force. How can you do that manually, without the help...
Replies
10
Views
2,467
Hello, is there any way how to increase number of nodes of L24ER, which supports up to 8 Ethernet nodes? I'm thinking about additional Ethernet...
Replies
8
Views
3,557
Does anyone can explain me how to do s-curve (for increasing and decreasing speed of the process ) programming in siemens simatic S7. If...
Replies
1
Views
1,880
Im looking into fitting the new 5700 into some of our panels and im basically looking at what is the best way to increase the amount of ports from...
Replies
0
Views
3,989
I have a servo linear actuator that has a stroke of 0 to 6”. The position feedback from the servo control is 0-10V which corresponds to the 0 to...
Replies
10
Views
2,871
Back
Top Bottom