Logix Designer data conversion

ceilingwalker

Lifetime Supporting Member
Join Date
Mar 2010
Location
Phoenix, AZ
Posts
1,586
Hello, I have read some previous posts here about converting data in RSL5000. Some recommend using COP and others the MOV instruction. I have an analog input module with an INT. I need to convert that to a real number with 2 decimal places. What is the preferred way to accomplish this? Also, I have an analog output module and I want the HMI to send a real number (again with 2 decimal places), then convert that back to an INT that the module can read. It is for an 1769-L24ER-QBFC1B, the embedded IO. I am using Studio5000 v.30. Thank you.
 
Use the SCL instruction. If you need only two decimal places (I'm assuming for display on an HMI), only configure the numeric display to display two decimal places.
 
Hello, I have read some previous posts here about converting data in RSL5000. Some recommend using COP and others the MOV instruction.

Be very clear about this - MOV will convert values from one data-type to another.

If the source is an integer data-type (SINT, INT, or DINT), and the destination is a REAL, it will be converted.

If the source is a REAL, and the destination is an integer (SINT, INT, or DINT), the REAL will be rounded before storing in the destination tag.

I've made some informative posts recently about Logix5000 systems rounding, they use a method called "round-to-even", which catches a few people out.

A COP instruction is dumb, it does no conversion of data-types in any fashion. It simply copies a number of bytes from the source, to the destination. The number of bytes copied is calculated as the LEN of the COP instruction * the number of bytes of the destination's data-type. In the wrong hands COP can be very destructive, especially if the destination is an element of a UDT tag.


I have an analog input module with an INT. I need to convert that to a real number with 2 decimal places. What is the preferred way to accomplish this?

You can use SCL, or the easier to use Add-On Instruction SCP. Usually installed in the Samples with Studio5000 installation ((I think it's in the sample application "Mosquito_Station" ??)).
 
Just a word of warning with using SCL. It enforces minimum and maximum values which may not be desirable.

As an example. You have a 4 -20 ma input module that natively scales 4000 to 20000 = 4 to 20. And you want an engineering level of 0 to 100%. So you SCL 4000 20000 0 100. That's all fine, but suppose your level input goes to 3.9ma. The card will have 3900 in its raw data register. But the resultant of the SCL won't be negative, it will be 0%. That may be desirable, or it may be that you want to know it's negative and alert someone to check calibration. Granted, some analog modules have out of range alarms that you could use instead, but some don't. Just a small caveat with using SCL, and for that reason, I almost always use a CPT instruction instead to scale analog.
 
Just a word of warning with using SCL. It enforces minimum and maximum values which may not be desirable.

As an example. You have a 4 -20 ma input module that natively scales 4000 to 20000 = 4 to 20. And you want an engineering level of 0 to 100%. So you SCL 4000 20000 0 100. That's all fine, but suppose your level input goes to 3.9ma. The card will have 3900 in its raw data register. But the resultant of the SCL won't be negative, it will be 0%. That may be desirable, or it may be that you want to know it's negative and alert someone to check calibration. Granted, some analog modules have out of range alarms that you could use instead, but some don't. Just a small caveat with using SCL, and for that reason, I almost always use a CPT instruction instead to scale analog.

Actually, I respectfully disagree. There's a limiting function that CAN be enabled (default is cleared), but if it wasn't enabled in the above example the OREF would be -0.625.
 
Actually, I respectfully disagree. There's a limiting function that CAN be enabled (default is cleared), but if it wasn't enabled in the above example the OREF would be -0.625.

You are correct! I honestly don't recall that feature being always there on SCL. Might be the old RSLogix500 SCP I was thinking of. Thanks for the correction. Carry on.
 
You are correct! I honestly don't recall that feature being always there on SCL. Might be the old RSLogix500 SCP I was thinking of. Thanks for the correction. Carry on.

No, neither SCL or SCP will limit the output, both are just "straight-line" scaling instructions.

Just to clarify things....

Logix500

SCL
: Uses the Y = mX + c method to scale X to Y. You had to do some math to determine the "scale factor" m, and the offset c, to put into the instruction.

SCP : Uses the formula shown in the picture to scale In to Out, and is therefore much easier to use. You just provide the 4 "parameters" InRawMin, InRawMax, InEUMin, and InEUMax.

Logix5000

SCL : Not available in Ladder, only in Function Block and Structured Text. Bizarrely, and a strange twist for Rockwell, it uses the SCP type formula to scale In to Out.

SCP : Not available in any language, but can be added (>=V16) as an Add-On Instruction, as already noted. It too, of course, uses the same formula to scale In to Out as the Logix500 SCP, and Logix5000 SCL instructions.

In Logix5000, there is no SCL or SCP in ladder, but the SCL instruction in FB and ST is actually the same algorithm as the Logix500 SCP, not SCL !!

If all else fails, you can always put that "SCP" equation into a CPT instruction. Use REAL tags to stop "rounding" errors.

2017-09-16_085046.jpg
 
And here is aforementioned CPT that uses the "SCP" type equation above.

Could be useful for anyone with a pre-V16 controller, where Add-On Instructions were introduced.

2017-09-16_091908.jpg
 

Similar Topics

Hi all! looking for help converting an 8 bit word SINT tag into decimal. I have an IFM SBN246 flow sensor wired in my controller (L310ER) and it...
Replies
4
Views
2,184
Hi Guys, Not critical, I was wondering if there was a way to check/affect multiple Data Type Elements at once. I am finding it hard to put into...
Replies
5
Views
2,129
How do I organize the template for my controls. I am new to Logix Designer but have used RS500 and RS5000. My new Logix Designer has Toolbars...
Replies
8
Views
252
Hello, Im building project with 1756-L82ES controller and 1756-IB16S card but i cant find it when trying to add the card to IO configuration...
Replies
3
Views
145
Does anyone know how to set the background colors of instuction blocks (TON, MOV, etc)?
Replies
1
Views
142
Back
Top Bottom