Floating Point Registers - Understanding

sgsims

Member
Join Date
Jun 2005
Posts
12
I am new to using floating point registers w/ Alen Bradley products and I seem to be having some trouble getting the output I desire.

Can someone tell me what the registers should look like if I use the DIV function to divide 3 by 2 and put the output in F8;0?

According to the IEEE standard there should be something in both F8:0 & F8:1 resgisters which are 16 bits long each. I expect to see the binary out put for 1.5 according to the IEEE standard or 1.5 if I select decimal for the radix. All I see is 1 if I select decimal for the radix or a 1 in the first bit of F8:0 if I select Binary as a Radix.

Am I mis-understanding something about floating point registers and/or am I making this too dificult?
 
I think this is the same question you asked in this thread:

http://www.plctalk.net/qanda/showthread.php?t=22574

You probably want to keep this all as one thread or you will have info scattered all over the place and that's hard to follow.

From your previous thread it sounded like you are doing this in a simulator. I think your simulator is messing with you. All Allen-Bradley floating point elements are 32-bit values. Also, the DIV instruction you posted in the other thread should work correctly. The SLC, PLC5 and CLX platforms all hanlde automatic type promotion to the 'highest level' data type. So, for example, if you divide a float by an integer the integer gets promoted to a float before instruction execution and the result is a float.

Now, in the example you list below, if you divide two integer constants the result will be an integer regardless of the destination data type. The conversion in this case happens after the operation. Try dividing 3 by 2.0 and see what you get. But as I said above your simulator (if it is a simulator) may be giving you incorrect information.

Keith
 
In addition to that, F8:0 is an ENTIRE FLOATING POINT NUMBER. F8:1 is a COMPLETELY SEPERATE FLOATING POINT NUMBER.

AB is kind enough to make their data types intrinsic, rather than only giving you a bunch of bytes or words, and leaving it up to you to make sure you don't over-write parts of your values.

A MOV instruction in AB is much more than just moving a bunch of bits from one place to another; it also performs type-conversion. Moving a FLOAT to an INT will first convert the float (32 bit real approximation) to an integer (16 Bit whole number), and then store it in the destination. Going the other way will expand an integer out to the floating point approximation.

They COPY operations will actually copy byte for byte, so you will need to allocate (for example) two INT registers (Nx:something) if you copy one FLOAT into it.
 
Floating point operations in the AB PLC are easier than in almost any other PLC.

The AB PLC performs the type cast before the division, but your WINdoze PC performs the type cast after the division by default unless it was programmed specifically to do it before by the author of the simulator software (which does not appear to be the case). Therefore the simulator is performing an integer division and then storing the integer result as a real. That is the reason I told you on the other thread to enter your constants as floating point numbers. In other words, DO NOT enter 2 or 3, enter 2.0 or 3.0 - forcing them to be treated as floating point values by the simulator before the division.

Also F8:0 and F8:1 represent two seperate 32 bit floating point numbers.

Take a look at the Tech note from Allen Bradley:
http://domino.automation.rockwell.com/applications/kb/RAKB.nsf/0/85C2838CBFC456D285256AFB00695031?OpenDocument



Here is a utility so you can see what the bit pattern of an IEEE floating point number should look like:
http://babbage.cs.qc.edu/courses/cs341/IEEE-754.html
However, in a real AB PLC you cannot look at the bit pattern of a float - you must copy it to two consecutive integers and then set the integer file radix to binary.
 
Last edited:
Thank you all for the information! From your information it does seem like it is a simulator problem.
 

Similar Topics

I am having trouble using floating point numbers. When I use the DIV function and specify an F8 register location for the output it rounds the...
Replies
6
Views
6,312
I need to check an axis actual travel position, and to compare it to the master travel position. To do this I have to multiply the axis travel...
Replies
6
Views
2,576
We have AOIs for projects, which handle material dosing (by hand or by pipes and pumps), obviously they have comparison between setpoint and...
Replies
50
Views
14,262
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,639
Hi, In my ladder logic, I've got a data register D60 whose value is -0.001 (when using monitor mode to see values). D406 is 0.250. But then...
Replies
5
Views
1,325
Back
Top Bottom