Two 16bit integers that represent one 32bit float

Ash Tillotson

Member
Join Date
Jul 2015
Location
Savannah
Posts
16
I have a MicroLogix 1400 that I am using to communicate with Micro Motion Coriolis meter. I wrote some simple logic that grabs the temp via Modbus RTU. The problem that I have is that the temp is in two 16 bit integers but i need it in one 32bit Float.
Can anyone share a Ladder formula?
thx,
ash
 
Try using the COP or CPS functions to copy (with a length of two) the array of INTS (array[0] and array[1] or whatever you're using) into a tag of type REAL. the copy functions preserve the bit order. You may need to flip the order of the arrays to get it to display properly (copy make array[1] array[0], and array[0] array[1]).
 

Converting from Integers into Floats

In all versions of RSLogix, the COP (COPy) function is used to convert between integer and floating point data the syntax is:

COP <SOURCE> <DESTINATION> <LENGTH>

Please keep in mind that the LENgth parameter is for the destination table or array.

In this example, a float value of '12.34' will be represented as '28836 and 16709' in the ProSoft card. You will need to create a COP statement that copies both Integer values into a single Real tag/table.

MCM.DATA.ReadData[x] is a (16bit) Int data type.
Specifically, MCM.DATA.ReadData[0] will contain the value 28836 and MCM.DATA.ReadData[1] will contain 16709.
FloatData[0] is a Real data type.

It is the data type of the Destination of the COP statement that dictates the Length parameter. A Length of '1' means the logic will use 2 consecutive integers starting at MCM.DATA.ReadData[0] to create 1 float.

Not all pairs of integer values will comprise a valid float, so it is possibly the resulting float value is not valid. There may be an issue with the order in which the bytes/words were placed when converting to a float. You may need to try a different ‘Swap code’ parameter for each MCM command. It can swap the two words, the bytes, or both.


This is still a little confusing.
All I have to work with is N7:0 and N7:1 for my two integers
I was trying to copy them into F8:3
I'm not understanding the "MCM command" or the "ReadData" function with brackets but it looks like I need "real tag Table"
not sure what that is either...
Can you dumb it down a little?
thanks,
ash
 
It looks like the "MCM" part is an application specific thing in regards to the Prosoft stuff. Don't worry about it too much. Part of the reason that it is confusing is that is a tag for Logix5000 not Logix500. Logix5000 lets you use custom names for tags instead of register addresses like N7:0 and F8:0.

Try this:

"COP N7:0 F8:3 1" - copy N7:0 to F8:3 with a length of 1.
 
It looks like the "MCM" part is an application specific thing in regards to the Prosoft stuff. Don't worry about it too much. Part of the reason that it is confusing is that is a tag for Logix5000 not Logix500. Logix5000 lets you use custom names for tags instead of register addresses like N7:0 and F8:0.

Try this:

"COP N7:0 F8:3 1" - copy N7:0 to F8:3 with a length of 1.

I keep getting "Error: Operand sizes do not match"
any thoughts?
 
It looks like the "MCM" part is an application specific thing in regards to the Prosoft stuff. Don't worry about it too much. Part of the reason that it is confusing is that is a tag for Logix5000 not Logix500. Logix5000 lets you use custom names for tags instead of register addresses like N7:0 and F8:0.

Try this:

"COP N7:0 F8:3 1" - copy N7:0 to F8:3 with a length of 1.

It looks like the MicroLogix has a slightly different instruction set. See the "CPW" instruction on page 225: http://literature.rockwellautomation.com/idc/groups/literature/documents/rm/1766-rm001_-en-p.pdf



Try using this similarly to what we described above.

EDIT: Looks like Mickey beat me to this.

lol, that's ok, I was reading a post on here from 2002 where it was posted that CPW was a special addition to the Micrologix instruction set.
I really appreciate you guys helping.
sincerely,
ash
 
just got back into office to test.

My results:
N7:0 = 554A
N7:1 = 42BF

I moved N7:0 to N7:2
I then used CPW N7:1 to F8:3 length 1

my result is: 2.394399e-41
my expectation is the actual temp: 95.6665802001953125

Still no go.
any ideas?
 
Have you tried length 2? I'm wondering that because your two source values are of type INT (16 bits) you will need to use length 2 (16 bits * 2 = 32 bits --> which is float length).
 
What happens when you use CPW N7:0 to F8:3 length 1?

My results when I don't swap around is:
N7:0 = 554A
N7:1 = 42BF

3.05959e-41

While watching N7:0, (the least significant short), it will fluctuate and go negative. I'm wondering if i need to convert the two signed shorts to unsigned shorts then use CPW.
 

Similar Topics

The analog array has 16 individual bits and each bit is an alarm. SCADA is having issues getting the BIT bool value. However they can get the...
Replies
9
Views
997
Hello, I'm using Compact Logix L33 in RSLogix 5000. I'm trying to message over modbus register that is 16bit UINT. In Rslogix 5000 do I message...
Replies
3
Views
1,498
Hey all, I have an AcuDC energy meter which provides data on voltage, current, and power over RS-485/Modbus RTU. It provides float values in two...
Replies
8
Views
2,041
I am having problems expressing an ANALOG OUTPUT 16bit INT word (0-10V Proportional Valve Voltage) as a REAL decimal number. From my...
Replies
6
Views
9,143
:banghead: Got my E-Designer 7 yesterday, and using E-410 landscape to read some data (currently) from FX1S-15MR-ES/UL. I am able to read IOs...
Replies
1
Views
2,502
Back
Top Bottom