IEEE 754 Float To 2xInteger Conversion and Back Again

christo

Member
Join Date
Jun 2007
Location
Tasmania
Posts
3
Hello there,
I have a MicroLogix 1100 PLC (modbus master) reading data from an Crompton Integra 1534 Power Meter(modbus slave).
The Integra 1534 arranges the IEEE 754 floating point data into two 16 bit registers which I read into the Micrologix. I am having difficulty tring to re-assemble the two 16 bit registers back into the Floating Point value in the Micrologix1100
Any suggestions would be greatly appreciated.
 
what you are saying looks like the attachment.
i have the file from one doc telling me how to communicate from AB to some Indramat. from all the **** around i found the conversion the most helpful. take a look.
 
Thanks for the attachment pimpim32.
The original floating point value on the Integra Meter was 49.971 Hz, The value subsequently read into the corresponding PLC registers were N21:64 = 16968 (High Word)and N21:65= 11685 (Low Word).
When trying to use your flow chart I am not sure what you mean or how you determine the Number of Decimal Digit.
Regards
Christo
 
I am not sure about the micro, but in a SLC or PLC sometimes you can simply use the COPy instruction. If your destination is a float, put 1 for the length and the processor will copy two consecutive integers, bit for bit, into the floating point address.


It is worth a try anyhow, you may want ot look up the COPy command specific to your CPU to make sure the same holds true. I know this is a method I have used to get floats over RIO using block transfers with integer destinations.
 
The number of decimal digit is given by your device. Check the specs. In my case it was 4. See the attached code.
At that time I used a SLC and I never tested with a Micro.

Now last night I tried to use the emulator and I got nowhere
icon8.gif
, so I cannot really guarantee it will work.

Never tried the CPW also but looks like it should work.

If I will have time tomorrow I will try to test your figures at work.
For me 49.971 should be something like low = -24578 and high =7
Your figures are way to far from mine.
(Think also that 16968 (High Word) * 65536 = 1111997880, so either your decimal digit is around 8, either you got something wrong)
 
Peter Nachtwey said:
...another handy tool is
http://babbage.cs.qc.edu/IEEE-754/32bit.html one needs to convert the decimal to hex to use this tool.

Thats a fantastic tool to help you determine what word order is needed for the conversion in your PLC. Try the 32 bit hex pattern in each of the possible word orders and see which one gives you the correct result.

To convert decimal numbers, use this one:
http://babbage.cs.qc.edu/IEEE-754/Decimal.html


I use it frequently.

For 49.971 you should have 4247h in one word and E24Dh in the other word.

49.971 is yet another of those floating point numbers that is not represented exactly in IEEE754. The value in memory is actually 49.970997. Very close, but not exact. 3F7D70A3% :) of the time it doesn't matter, just something to be aware of for that 1% of the time when it does matter.
 
Last edited:
Solution

Thank you all for your input.
I was able to come up with a solution, albeit a long winded one.
I used the CPW instruction to copy the two integer values (16 Bit) into a two individual long registers (32 Bit). I then used the Bit Shift Left Instruction to move the upper word, currently occupying the lower 16 bits of the upper word long register, 16 bits to the left, so they occupied the top 16 bits of the upper long register.
I then used a masked move instruction to move the lower 16 bits of the lower word long register into the lower 16 bits of the upper long word register. The mask was used as not to overwrite the upper word values. So as result I was able to reconstruct the binary floating point back into a 32 bit format. It was then a simple matter of using the CPW instruction to copy the reconstructed 32 bit value located in the Upper Word Long Register into a Float register. It is important that when you use the CPW instruction to copy the Long register into the Float register that you use a Length of 2 otherwise you will get garbage for a result.

Regards
Christo
 

Similar Topics

Hello !, I have a Profibus PA net with Pepperl&Fuchs DP/PA coupler and a IM308C DP master in Simatic CPU 944 rack; the profibus net works ok, but...
Replies
0
Views
2,893
I am looking for a VB App that will convert the integer value from the PLC (i.e.N7:0 and N7:1) to floating point(i.e. F8:0). I am aware of the...
Replies
0
Views
2,514
Looking for some explanation/history between North American electrical symbols standards (how they relate, what are the latest, what is the...
Replies
3
Views
1,723
Hello! Long time lurker and gatherer of information - love this forum. I am trying to find some sort of tag naming standard if it exists...
Replies
18
Views
8,420
Back
Top Bottom