Sign in to follow this  
Followers 0
Emach

Compact Logix Math Instructions

9 posts in this topic

Hi guys, A quick question regarding instruction efficiency on compact logix PLCs. I translated an old SLC-5/04 program over to a Compact Logix L32E and stumbled upon this. In the SLC program I calculate flow deviation using a MUL instruction followed by a DIV instruction and then adding and subtracting the allowed deviation from the setpoint. Is it more efficient to use the two separate CPT instructions to calculate the high and low limits in the Compact Logix or should I stick with the MUL, DIV, ADD, SUB since it’s such a simple equation? I do this computation or something very similar maybe half a dozen times in a program that’s around 200 rungs spread amongst 10 ladder files. XIC T4:0/DN BST MUL N7:12 N7:13 F8:1 NXB DIV F8:1 100.0 F8:1 NXB ADD N7:12 F8:1 N7:44 NXB SUB N7:12 F8:1 N7:45 BND T4:0 is my power on delay timer N7:12 is the flow setpoint N7:13 is the flow deviation % as an integer F8:1 is the math holding register N7:44 is the high flow limit N7:45 is the low flow limit Cheers, Emach

Share this post


Link to post
Share on other sites
Personally I would write something like this in structured text and make it an Add On. In my opinion, for what that's worth, the worst thing anyone can do is make a CLX program look like an SLC. CLX has a all of the tools that you need to write a clean well organized program with good tag structure. Using SLC nomenclature isn't helping you to learn CLX

Share this post


Link to post
Share on other sites
Structured text requires buying another language pack from AB, or having the higher level of RSLogix (which we don't). We had to buy a language pack license for some DriveLogix projects that came into the plant from AB with FBD code. If structured text and FBD were included in the Standard software, I might be inclined to use it, but since our maintenance guys only have access to LAD, I won't for anything that I write. I agree that using "SLC-like" tags (like an array called "N7[whatever]") is not the best way, unless you have to interface with an old HMI that doesn't support tags (like the PanelView Standard or some old TCP units we still have in service). As for the original question, the individual instructions are easier to see sometimes. I remember coming across this question a number of years ago for a SLC. As I recall, the CPT was no more efficient than discrete instructions. Even if there is a significant difference, considering the power of newer processors, I think it's fine to use whichever method is easier to debug, troubleshoot, and decipher at 2AM 5 years from now.

Share this post


Link to post
Share on other sites
+1 for the above. Bubba will not like Structured Text. I would also stay with what you have already.

Share this post


Link to post
Share on other sites
For the integer values, declare them as DINT, not INT. Calculations with DINT's will be faster, due to the internals of the compactlogix.

Share this post


Link to post
Share on other sites
Just a quick note- A couple of routines that I use on a regular basis would be huge in ladder so I wrote them in structured text. The largest is something like 250 lines long. While not complex, the routines have a lot of equations and if / then statements. I use them enough that I eventually converted them to Add Ins. For me STX and FBD are just tools in the box and I use them on every program. We make use of PID loops in CLX. Lots of them. The PID_Enhanced FB is orders of magnitude better (for our needs) than the standard PID loop. For me STX and FBD are just tools in the box and I use them in every program. The "bubba's" that I work with all have STX / FBD. Even when I was doing integration work the "bubba's" that worked for the numerous companies that I did work for had STX and FBD. My point was more about making the routine and ADD IN than the language used. ADD IN's can be created from ladder. Edited by Michael Lloyd

Share this post


Link to post
Share on other sites
Emach, Try the whole thing in one Compute Statement. You may be surprised what will fit in there. Bob A.

Share this post


Link to post
Share on other sites
Using CPT would almost certainly take longer to execute than the individual simple math instructions as posted, and if this math was done every scan, I would probably not use CPT. However, you are triggering the computation with a timer.dn bit, so the neatness of the CPT would probably gain favor, since you will not be hitting every scan with the additional processing time of the CPT. Making it an Add-On Instruction would be slower than using CPT. Edited by daba

Share this post


Link to post
Share on other sites
+2. Making it easy for Bubba to follow in ladder is worth the loss of efficiency.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0