PLC5 Float Question

yang1216

Member
Join Date
Jun 2009
Location
BeiJing
Posts
84
Hi,all.
I have a PLC5 question about float format.
We used Remote IO to communicate with a Mettler Toledo scale which has a float output. The Mettler Toledo guy tell us to use the following instruction "COP #I:151 #F85:44 1". And it works.
I was confused. How can a 16 bit INT translate to a Float?
I have used CLX to do the same thing. In that case I used two INT to construct a FLOAT.
So, can anybody tell me why?
 
Because the number of words copied depends on the size of the DESTINATION register. It is still assembling two INT words into one single FLOAT.

Your input value looks wrong, but using it anyway, F85:44 is being formed from I:151 and I:152.
 
To clear up your confusion...

The COP instruction will not convert a INT value to FLOAT, it just performs a straight bit-for-bit copy from source to destination.

You say your FLOAT value looks correct, and that is because the bit patterns coming in from the scale have been bit-copied in the scale to two INT words I:151 and I:152.

These words are just being used to transport the bit patterns into the PLC, and consequently looking at the data in them will give you nonsense.

However, when bit-copied to a float, the original data context is restored, and looking at the float value is appropriate for the bit patterns it contains.

Using MOVs would destroy the data, since it would interpret the input data as INTeger values, and try to convert them to FLOAT.
 
For more information on how floating point numbers are stored in binary see http://en.wikipedia.org/wiki/Single_precision_floating-point_format

Data in computer memory is nothing but bits. Ones and Zeros. Data types such as Integer and Floats are tools to make programming simpler and also to help us humans interpret the data. Copying the data with the COP instruction doesn't change the binary data in any way and copying from integer to data just sets up the data typing for the 32 bits of information from the scale.
 
Last edited:

Similar Topics

Hey guys, I have run into a bit of a hiccup. I am trying to store a large number (45123456) to a PLC5/30. This is actually a Product Order number...
Replies
3
Views
1,807
I have the following logic in A/B PLC5 CPT F8:5 (((F8:3 * 86400.0) + (N7:13 * 3600.0)) + (N7:14 * 60.0)) + N7:15 F8:3 = 13936 N7:13 = 16 N7:14 =...
Replies
17
Views
4,900
A recent challange I worked out tonight was getting a float, which represents the number of counts for an indexing drive to move, split into a low...
Replies
3
Views
4,398
I'm getting values from a Crompton Switchboard Integra in the HEX form in a PLC5/40 and I need to convert it to IEEE 754(floating so operators can...
Replies
1
Views
4,028
I'm getting values from a Crompton Switchboard Integra in the HEX form and I need to convert it to IEEE 754. I've been succesful in a way to do so...
Replies
1
Views
3,767
Back
Top Bottom