TechTalk – RSLogix 5 : Converting Data Type Floating To Integer

This is a task each and every PLC5 programmer (in RSLogix5) has to do at least once in their programming life….. convert integer to float and vice versa in RSLogix5.

Converting Integer to Float
Use the CPT function block as shown below.

Xybernetics RSLogix 5 : Converting Data Type Floating To Integer

In the example above, floating point in F8:21 is converted and stored in N4:14 using the CPT block.
And N4:14 is used in PID block as PID blocks in RSLogix only accepts integers.

Converting from Float to Integer
Use the MOV function block as shown below.

Xybernetics RSLogix 5 : Converting Data Type Floating To Integer

In the example above, the integer in N22:200 is converted to a floating point using MOV (into PD16:6.SP, PID setpoint)

Alternate Way
We could also use COP to convert from floating point to integer and vice versa but if your destination file cannot accept “#” (as such for PID1:6.SP), you will not be able to use the COP block.
This is how you would use COP block to convert from floating point to integer.

Xybernetics RSLogix 5 : Converting Data Type Floating To Integer

And this is how you would use COP to convert from integer to floating point.

Xybernetics RSLogix 5 : Converting Data Type Floating To Integer

Reference
Rockwell Knowledge Base 18807 – RSLogix software_ Reading Integer from Float data
Rockwell Knowledge Base 18912 – Converting Floating Point or REAL Datatypes into Integers