Help with addition

shawn_75

Member
Join Date
Apr 2010
Location
KY
Posts
432
MicroLogix 1500 I need to add the .ACC of eight count down instructions when an operator pushes a button. After these are added together, I need to calculate a running sum of items used since the button was pushed. This part is easy as it is one SUB instruction. I can use the SUM instruction over and over until all eight .ACC values are added together but is there a better way?
 
Could you use the CPT (Compute) instruction instead of numerous ADD instructions?

I can't remember if RSLogix 500 has the CPT instruction, and if it is supported on the 1500.
 
Unfortunately compute is not an option in ML1500 nor in ML1000 (all I ever get to work with) which is why I suppose I had never noticed that instruction before.
 
...but is there a better way?


That is the sixty-four-thousand dollar question...

Brute method or some clever bit of programming legerdemain? Seven simple adds? Or a for/next loop using indirect addressing and a pointer (assuming that all the counters were sequential)?

For just 8 data elements, by the time you programmed a for/next loop and something to increment the indirect address you would have it done if you just programmed 7 ADD instructions. Besides, the 7 adds will execute faster than anything else you could do. If you feel like that would be cluttering up your ladder then put the 7 adds in a subroutine and call it when necessary, since you're likely to never look at that bit of code again.

A for/next loop will require two MOVs, 8 adds for the sum, 8 adds for a pointer, 8 compares, 8 jumps, and you'll use seven instructions to program it, so it doesn't save you anything.
 
Last edited:
If you feel like that would be cluttering up your ladder then put the 7 adds in a subroutine and call it when necessary, since you're likely to never look at that bit of code again.

Now that is an approach I like. This will also give me some practice with JSR.

Thanks!
 

Similar Topics

Guys, I want to add another PLC SLC 5/04 to an existing DH+ network. How do I go about doing that? I have the blue hose. Do I just tied into...
Replies
5
Views
1,716
Hi all, hope you are having a great day, I am in need of your help to create a AOI or program that does this kind of job: I have a IO Link...
Replies
0
Views
45
please help me . I have to make this ladder diagram and I can’t figure it out :(
Replies
12
Views
292
Hi Everyone, i was hoping for a little help with this module. i have data that needs to be read from a different plc through the Modbus plus...
Replies
11
Views
203
Hello, I am trying to replicate a piece of logic on the PLC5 onto an SEL RTAC. I am using ladder on SEL and FBD. I am having issue on the ladder...
Replies
13
Views
218
Back
Top Bottom