2 16 Bit INT's combine to a Float???

DBLD99

Member
Join Date
Oct 2003
Location
USA
Posts
230
I'm communicating over modbus to a DO probe that will give me the PPM and Temperature, using a MVI56-MVM card in a controllogix rack. The problem is the first two registers are 2 16 bit INT's that need to be combined into a float in the Controllogix to be displayed on a screen. Anyone have any ideas to go about this.
The floating point number is a 32 bit IEEE-754 value that is occupying two 16 bit registers. Has one sign bit, eight exponent bits and 23 mantissa bits and is stored in motorala big-endian order. Thanks for anyones time.
 
First, the easy part. The way to get the floating point value back is to use the CPS instruction (synchronous copy). This will do a byte-for-byte transfer from the source to the destination, preserving the bit pattern. The synchronous part is so the -MVM card doesn't change one of the bytes out from under you during the copy. The 'length' fied in the instruction is in destination data type units. So if your detination is a 32-bit float a length of 1 will move 4 bytes (one destination data type size). If the desitnation were an INT a length of 1 would move 2 bytes (one destination data type size).

The tougher part (I think) is the big endian/little endian thing. I'm pretty sure the CLX is a little endian. So you may need to do some byte swapping somewhere to get what you want. Can the -MVM do byte swapping for you?

I hope, this helps.

Keith
 
Yeah the card or the module itself has some bit swapping, but I wasnt sure of what I needed to swap. The module can swap he big endian with the little endian, and the card Im not quite sure on what there trying to do with the swapping it is unclear in the manual. Thanks for you help Ill try what you suggested.

Thanks again
 
I'm pulling this out of memory, but there are a couple of ways this is typically shown. One way is just a selection of 'Intel format' or 'Motorola format'. If this is your selection you want 'Intel format'.

The other method that is sometimes employed is a selection for swapping 'bytes in a word' and 'words in a double word'. I think you want only bytes in a word, but I'm not sure on that one.

In reality you will probably need to do some playing with the number until you get what you want. You can use the calcualtor at this page to give you the integer bytes for a given float:
http://babbage.cs.qc.edu/courses/cs341/IEEE-754.html

Then play with the byte order of your transmission to match the byte order shown. This assumes you can send a fixed floating point number from the module.

Hope this helps.
Keith
 
Someone might want this.
Check and test the following:

COP(MNETR.DATA.ReadData[0],RealTypeMemory,2)
MNETR.DATA.ReadData[0] : -27509
MNETR.DATA.ReadData[1] : 17443
RealTypeMemory : 654.321


COP(RealTypeMemory,MNETR.DATA.ReadData[3],2)
RealTypeMemory : 654.321
MNETR.DATA.ReadData[3] : -27509
MNETR.DATA.ReadData[4] : 17443
 
Last edited:

Similar Topics

I am modifying an existing Omron CJ-2H CPU66EIP using CX-Programmer version 9.63. I simply need a rung of logic that can determine if a bit is...
Replies
20
Views
8,662
Hi eveyone. I need transfer signal from system 1 to DCS via modbus. System 1 only can send 32 bit floating point. DCS receive 16 bit integer. How...
Replies
20
Views
10,543
Hi guys, I have "Light_Status_DINT", which is a DINT logged every 5s. if i trend the DINT itself no issue, i got a nice graph of it. Now i want...
Replies
7
Views
2,320
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,485
All, Forgive my lack of attention to detail, today a student asked me why when he printed his ladder in an RSLogix 500 report, even though he had...
Replies
10
Views
1,877
Back
Top Bottom