Posted 8 Dec 2014 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 this post Link to post Share on other sites
Posted 8 Dec 2014 Which software are you using? Have a look at the CPT instruction if available Share this post Link to post Share on other sites
Posted 8 Dec 2014 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 this post Link to post Share on other sites
Posted 8 Dec 2014 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 this post Link to post Share on other sites
Posted 8 Dec 2014 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 this post Link to post Share on other sites
Posted 8 Dec 2014 Yes, the same in ladder logic. Use the CPT instruction. Just make the Source be the formula you want to calculate. Share this post Link to post Share on other sites
Posted 8 Dec 2014 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 this post Link to post Share on other sites
Posted 8 Dec 2014 Reminds me of this: https://www.youtube.com/watch?v=y9h1oqv21Vs 1 person likes this Share this post Link to post Share on other sites
Posted 8 Dec 2014 That's a great video! Thanks for sharing. Share this post Link to post Share on other sites
Posted 9 Dec 2014 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 this post Link to post Share on other sites
Posted 9 Dec 2014 (edited) thanks for the video! I now wonder sometimes about what Jeremy is doing with his spare time... Edited 9 Dec 2014 by a062549 Share this post Link to post Share on other sites
Posted 10 Dec 2014 @ 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 Share this post Link to post Share on other sites