Increment / Decrement Logic

The Plc Kid

Member
Join Date
Feb 2009
Location
Macon, Georgia
Posts
3,233
I am trying to create a panelview 900 screen with a increment button,decrement button and numeric entry setpoint.

I am having trouble coming up with the best/simplest way to work out the logic in the slc 5/04.

I want inc/dec button to increase percent by 1 if presses and climb 1,2,3,4,5,etc if held in and be able to just key the value in the numeric entry. how can i get both functions from one button and stay simple?

Anyone have an example of something like this?
 
I would use a one shot to do the single increment, and a timer to do the hold down stepping.

For the single add:
XIC [PV Button] OSR B3/0 ADD 1 [PERCENT] [PERCENT]

For the continuous add:
XIC [PV Button] XIO [Timer_Done] TON [Timer] 0.01 100
XIC [Timer_Done] ADD 1 [PERCENT] [PERCENT]

The timer will just keep rolling along and resetting itself as long as the button is held down.
 
Kid,
When you get that going, can you post the code so that we can look at it.
I know that I've done it in a convoluted way with a couple of timers, increasing the increment value when one timer timed out.
I'd like to see how this is done with RSLogix speak.

I don't understand the [PERCENT] [PERCENT]
Thanks
 
I think PERCENT is just a variable he's using in the program. It may function as a percent in his program but as far as the increment/decrement algorith goes it's just a number.

Another modification to this is (as GBradley mentioned), instead of the constant '1' as an adder, making it a variable (ADDER). Add yet another timer, if the button is held for more than a certain amount of time then increase ADDER and reset this second timer. If it continues to be held then at the next timeout increase ADDER again. The increase could be linear or exponential (first time to '10', the next time to '100' etc).

If the button is released then reset ADDER to 1.
 
Last edited:
I did a similar thing on a PV600 using a CTU instruction. To increment the value of the existing production count, I added a 1 to CTU.ACC using a one-shot and the ADD instruction. The funny thing was that I couldn't decrement (SUB instruc.) a 1 from CTU.ACC. I had to add a -1 to get it to work.
 
Here's one possible method of the INCREMENT function.

Of course this simplistic form will crash if the button is held too long but you get the idea.
 
Kid,
When you get that going, can you post the code so that we can look at it.
I know that I've done it in a convoluted way with a couple of timers, increasing the increment value when one timer timed out.
I'd like to see how this is done with RSLogix speak.

I don't understand the [PERCENT] [PERCENT]
Thanks

The [PERCENT] [PERCENT] is really just a variable. I could have easily said: ADD 1 N7:0 N7:0, its just how it's written in AB text in RS500.

The ADD instruction needs 3 variables:
Source A = 1
Source B = [PERCENT]
Destination: [PERCENT]

Just adding 1 to itself.
 
Thanks Bernie,
I liked your first example best, but I like how you added the
Condition in the second example.
LES
Less Than (A<B)
Source A N7:10
0<
Source B 32000
32000<

This is so that it doesn't fault.
I've done something similar, not as pretty, but it works just the same.
I use 32700, because I like to live that much closer to the edge ;-)

Thanks for the ideas.
 
I didn't use that type of test in the first one because the adder could grow to be very large. More that 67 will overflow with your test. I set up, but didn't post, an add which didn't test and went for it anyway and, if the overflow occured (S:5/0 set), corrected it, setting the number to a max value, then reset the overflow flag.
 

Similar Topics

Hi, I have a stand alone inspection unit with no PLC but I can send 24v input signals to the machine PLC to show a good read and a bad read when...
Replies
9
Views
777
All Looking for a way to use a momentary relay closure and the digital inputs to increase or decrease the speed of a Powerflex VFD. I looked...
Replies
3
Views
2,802
hi guys, i am new plc programming learner. i stucked in one of the excercise problem of speed control of servo motor using increment/decrement...
Replies
3
Views
3,815
Hello, This is probably a no brainer but I am having a mental block. I want to adjust a word value up/down based on two inputs, the adjustment...
Replies
11
Views
3,688
Hi, Am I being daft (again)? I want to increment a tag (Integer) by 1 each time a button on the HMI is pressed. Before the button press, the...
Replies
22
Views
2,361
Back
Top Bottom