Followers 0

# Addition of more than 2 values

## 14 posts in this topic

I'm new to the Allen Bradley software and I'm trying to add 3 values together. I have found the addition block but it only allows for 2 values. Is there a way to extend the block or do I need to use the block twice? Thanks for your help

##### Share on other sites
Which software are you using? Have a look at the CPT instruction if available

##### Share on other sites
I'm using the RSlogix 5000, I've looked at the help files with the software but that only gave examples for two values

##### Share on other sites
The CPT instruction will allow you to to everything in one shot, but you have to make sure you follow the correct syntax. To add three variables, the correct syntax would be: (A + B) + C The parentheses are required so that the software knows which operation to do first.

##### Share on other sites
Thanks, I'm guessing the same can't be applied in Ladder Logic? Or at least it would be but two Add blocks in a row?

##### Share on other sites
Yes, the same in ladder logic. Use the CPT instruction. Just make the Source be the formula you want to calculate.

##### Share on other sites
I get it now, Thanks

##### Share on other sites
Gee, wouldn't it be handy if there were some mathematical standard about how to evaluate multi-part expressions like this. Then we could teach it in school so that every 3rd grader would know how it was supposed to work. Oh, wait...

##### Share on other sites
1 person likes this

##### Share on other sites
That's a great video! Thanks for sharing.

##### Share on other sites
Please clarify for me, and excuse my ignorance.... would not the CPT execute the function from left to right regardless ie A + B + C. A, B and C are variables so if A = 8, B = -2 and C =1 then the equation becomes 8 + (-2) + 1 = 7. why do you need the brackets to have CPT (A+B)+C... if you are simply substituting values then in this case executing B + C before adding A is doesnt matter as -2 + 1 = -1 then 8 + -1 = 7. however taking this further so for the following equation A + B * C using the above values the answer should be 8 + (-2 * 1) = 6 so to get the correct answer with CPT you must enter the formula as A + (B * C) other wise CPT would get an answer of 36. (ie (8 + -2) * 6 = 36) I understand why the parentheses are important in this instance but not the first example of A + B + C

##### Share on other sites
thanks for the video! I now wonder sometimes about what Jeremy is doing with his spare time... Edited by a062549

##### Share on other sites
@ Sleepy Wombat: I double-checked to make sure I had my head on straight, and the rules I stated in my first post are those imposed by Allen-Bradley on their older (RSLogix 500) processors. Parentheses required, and they will be added automatically if you don't put them in. It's like a EULA. Either accept and move on, or you can't use the software! In RSLogix 5000, however, they do not require the parentheses, and execute in a specific operational order, and from left to right. Parentheses can be used to override the normal order, but are not otherwise required. The help file for the CPT instruction lays this out. Based on this, your first point A+B+C) is correct. But your second point (A+B*C) is incorrect, as multiplication is a level above addition and will always be done first regardless of parentheses. @ a062549: What do I do with my spare time? Why write posts on the forums!
1 person likes this

LOL...

## Create an account

Register a new account