MicroLogix 1400 Float max value

bearsgone

Member
Join Date
Jun 2010
Location
chico
Posts
49
I have a program that totalizes gallons every day. Starting last week counter stopped working. It seems that once I reached 18 million number, counter stopped. In RSLogix 500, it shows 1.86096E+007 and assigned to F8:44. If I set the value to be say 17 million, everything works, but as soon as it reaches random number in 18 mill or above, no value is added. Based on what I am reading I should be able to put in any value up to 2bil. Should I use something else instead of Float?

Thank you for any help
 
You have reached a limit that the representation of floating point numbers allows.

It is called "precision", and what you are trying to do is to add a number that is very small compared to the bigger number.

The bigger number has started to drop off its least significant precision, so that it can display its large value.

When you try to add the smaller number to it, it is adding it into the part that is no longer considered "significant", so it has no effect on the larger number.

One way around this is to use a counter (or cascaded counters if you need to go higher counts), and use multiplication to achieve your total.
 
The 1400 can use the Long data type - though it's not in the default files. (Actually considering your '2 billion' note you may have been thinking about this.)

Range -2147483648 to 2147483647 - over 2 billion

But like anything there are these limits. Compared to floating point you gain significant digits at the loss of full range.
 
Last edited:
I am using cpt to add values:

What I tried:

Create Long data file, however, when I try to add float value to Long value in CPT, I get Operand sizes do not match?

If i try to use counters I get to get total:

Float + Counter I get Addressmust be specified to the word level?
 
Don't use the float at all if you can help it.

Are you adding a float value to the previous Long to get the new Long value? I had no problem doing that.

CPT L9:0 F8:0 + L9:0

Float + Counter I get Address must be specified to the word level?

I'm not sure what you are trying here but the current value of a counter is Counter.Acc (eg C5:10.ACC)
 
I have made a change however the issue still exists. here is what I have now:

ADD F8:21 L9:0 = L9:0

It stops adding around 16900000 give or take 100k. Not sure what is going on

Is there some kind of issue with Micrologix with storing values higher than 16mil?
 
MicroLogix tries to hide the dirty work of data type conversions from you, which sometimes obscures the problems, too.

When you add a Float to an Integer, the controller will do the math in Floating Point format, and generate a Floating Point result. Because you have a Long Integer as the destination, the Floating Point result will get converted to a Long Integer only after the ADD has been performed using IEEE 754 math.

Therefore the ADD instruction you showed suffers from the same IEEE 754 rounding error as a Float + Float = Float calculation would.

If you need all integer math, use Integer registers only.

What is the actual value of F8:21 in this case ?
 
A note about the above: I don't actually know the innards of the MicroLogix operating system, but the explanation I made makes sense based on my experience with MicroLogix and SLC-500.

I don't think the order in which you list the operands in an ADD instruction makes a difference in the data type that is used internally, but I am not certain.
 
Floating value is a value that is read from a transfer meeting when it is running. It is basically grand total calculator
 
I mean, what's the value of F8:21 ?

If it's "1.0" gallons, then you can use Integer math instead.

If it's some other non-integer number of units, you need to find some other way to do your math.
 
Your PLC uses something called an IEEE-754 floating point format to represent floating point numbers. You have a 24 bit mantissa in that format. That means the largest number you can represent with single digit precision is 224-1, or 16,777,215.

What I mean by single digit precision is that if you put that number into a float and try and add 1 to it you cannot make the number increment, no matter how many times you try. You can add a 2, or a larger number. Eventually however you reach a point where you loose precision in the 10's column, then in the hundreds column.

Precision is something all computers deal with, not just PLCs. Its best to accept it as a fact of life and then learn about it so you can know how to handle it. This has been discussed on the forum many times - do a search on IEEE-754.


There are some different fairly simple ways you can deal with this. One is to use a long integer as has been mentioned. Another way to deal with it is to change units. For example, instead of totalizing gallons you can totalize cubic feet, or cubic meters, or acre-feet.
 
Two approaches -

1 - Starting with the float measurement do a MOV Float to an Int ('N') register. The MOV command will round the float. The decimal part (assuming it tends to vary a lot) will average out. Note that this Int will hold just this one reading. Then just add the Int register to a Long accumulating register. The loss of precision will probably be minimal.

2 - Add the float reading to another accumulating float as you are now doing. But then add another rung just after. If the float is GEQ some value (let's say 1000.0) then add '1' to a Long value and subtract 1000.0 from the accumulating float. Thus you will preserve several decimal places but strip off exactly 1000.0 each time this fires. Obviously the Long will have the count of 1000's.
 

Similar Topics

I've run into a problem with my Panelview C600 and modbus comms to a Micrologix 1400. I can set up a numerical entry on the screen, and it works...
Replies
4
Views
3,241
Hi all, I'm communicating with a modbus device which sends data in 32 bits data. You can see the structure in this example: N7:4...
Replies
6
Views
4,562
I have an Allen Bradley MicroLogix 1400. I am trying to display a value onto an HMI, however my HMI will not accept a Long (i.e. L10:2) as an...
Replies
6
Views
10,569
Hi all, I am communicating with a modbus device which sends data in 32 bits format. The MSW represent the integer part of the value and the LSW...
Replies
3
Views
5,573
I'm using a SLC typed write from the ControlLogix5572 to the MicroLogix 1400, with path: 2, (MicroLogix IP). The ControlLogix equipment has a...
Replies
0
Views
42
Back
Top Bottom