Sign in to follow this  
Followers 0
Ben Dee

SLC to CLX Transition

5 posts in this topic

I have a SLC program I am Converting to CLX program. The SLC program is using the Status registers S13 and S14 which are math registers. I don't understand what to do with these in the CLX program. Is there any help someone could offer?

Share this post


Link to post
Share on other sites
S13 and S14 return different values depending on what math instruction you use them with, so how you handle the conversion depends on that. Here are two examples. Example 1: If you are using them with a MUL instruction, they return a Long (32 bit) answer. In CLX, Longs (called DINTs) is the standard way to store values, so you probably don't need to do anything, as long as the destination address is a DINT. Example 2: If you are using them with a DIV instruction, they return the integer part of the quotient and the remainder of the division, rather than a rounded quotient. In CLX, the DIV instruction returns the integer part of the quotient (not rounded), and the MOD instruction returns the remainder. You'll have to use one or both of those two instructions to get the information you want. If you post a little more information, or a screen shot of the code you are converting, I could help further.
1 person likes this

Share this post


Link to post
Share on other sites
password to open file is 911GLITON1.RSS

Share this post


Link to post
Share on other sites
This program is doing a whole bunch of division and then storing the unrounded quotient and remainders from the math registers into other registers for some purpose. Look at rungs 93-95: In rung 93,the DIV instruction divides the contents of N7:81 (7910) by 100, and puts the rounded quotient (79) into N7:11. At the same time, the truncated quotient (also 79, in this case) is placed in S:14, and the remainder (10) is placed in S:13. Rungs 94 and 95 simply do something with that data before it's overwritten by the next math instruction. That set of three rungs, or something very similar, is repeated multiple times in your code. Here's how to handle it. In ControlLogix, the DIV instruction actually gives you the truncated quotient (any remainder/decimal is truncated). The MOD instruction gives you the remainder. So here is the SLC code: DIV N7:81 100 N7:11 MOV S:14 N9:165 MUL S:13 10 N9:166 Here is the closest CLX code: DIV N7[81] 100 N7[11] MOV N7[11] N9[165] MOD N7[81] 100 TempReg MUL TempReg 10 N9[166] Please note that the value in N7[11] will be an truncated quotient, not a rounded quotient as in the original code. If you need a rounded quotient, you'll have to jump through a couple of hoops.

Share this post


Link to post
Share on other sites
I inserted the section of the program using the S13 and S14 registers into a test clx using the MOD instruction. Seems to work fine. Thanks to everyone. Perhaps I can help someone out in the future.

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