How does PLC5 convert single floating point to two integers?

wildswing

Member
Join Date
May 2005
Location
Sault Ste Marie, Ontario
Posts
281
Just curious. Does anyone know the specifics of how the PLC5 converts a single floating point to two integers and back using the COP command? Is it some standard formula?

From floating point to integer: SOR COP #F8:0 #N7:0 2 EOR
and from integer back to floating point: SOR COP #N7:0 #F8:1 1 EOR
 
The copy instruction doesn't 'convert' anything, and that is really the power of the instruction. The COP command does a direct byte-for-byte transfer from the source to the destination. The float will be in IEEE format. Once you copy it to a pair of integers it is unintelligable when you look at the two integers as raw integers. You need to look at the whole 32-bit quantity as a float for it to make sense.

The real beauty of this comes in if you need to transport some floats in a block of integers or if you data transport mechanism only supports integer transfers. The copy will do a byte-for-byte copy of the float into two successive integers. you can transfer the data and re-assemble the float on the other side.

Keith
 
A single precision floating point number occupies 32 bits. Bits 0 to 22 are the mantissa of the number. Bits 23-30 are the exponent normalized to 128, and bit 31 is the sign bit. When you execute the command COP #F8:0 #N7:0 2 then the floating point sign is stored at N7:0/15, the exponent is at N7:0/7 thru N7:0/14 and the first seven bits of the mantissa are stored in N7:0/0 thru N7:0/6. The remaining 16 bits of the mantissa are in N7:1. It is an exact bit for bit copy from four bytes of memory in one location to 4 bytes of memory in another location.

Here is a tech note on how floating point numbers are stored in a PLC: http://domino.automation.rockwell.com/applications/kb/RAKB.nsf/0/85C2838CBFC456D285256AFB00695031?OpenDocument

Here is a handy web utility that lets you see exactly how a floating point number looks in binary: http://babbage.cs.qc.edu/courses/cs341/IEEE-754.html
 

Similar Topics

Plant PLC has no reasonable stop start sequencer. There is 3 states, Available, Start & Stop. A 10 sec timer exists in the Stop Ladder that is...
Replies
8
Views
2,701
I am updating a project used panelview 1000, it connected a controllogx, but it not directly read/write controllogix's tag, controllogix map tags...
Replies
0
Views
4,618
We just had a sub (node) lose communication on our DH+. My co-worker mentioned that this might be due to the # of RSlogix applications that were...
Replies
8
Views
3,421
I am trying to connect with a Schneider plc which has a firmware version only available in Somachine v4.2. In Machine expert After taking upload...
Replies
0
Views
112
Back
Top Bottom