Store large float on PLC5

mutabi

Member
Join Date
May 2009
Location
OH
Posts
90
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 that I want to save so we can capture it using an OPC server.

The number would be entered through a Panelview more than likely. However when I manually type the number into a floating point location to run some tests, it changes it to 4.5412346e+7. Needless to say, this is not good. Is there any way around this?

I was under the impression that since floats are 32 bits, it would accurately store the number. Maybe since the Processor is 16 bits, the floats are limited? Perhaps I am all kinds of wrong.

Any help would be appreciated.
 
You're encountering the "floating" part of IEEE 754 Single-Precision Floating Point.

You simply cannot maintain "a number of decimal places" with Floating Point. It's just the way it works. Every number is an approximation in Floating Point, even though a number might appear to be the same as an integer.

Because you are not using any math on this, I recommend using two adjacent Integer addresses. PanelView terminals allow you to define a data entry as a DWORD or LONG data type, but address only the first "N7:xx" element of the two that it will store the value to.

Most OPC servers let you use the same trick of defining an OPC item as a DINT or DWORD but addressing the first of two Integer data table addresses.
 
You can probably use string instead as I have done in the past hwen handling RFID tags in PLC 5. However, ST files chew up memory like no tomorrow.
 
A float has a 23 bit mantissa plus one implied bit. The remaing bits are for the sign and the exponent. That means that the largest float you can store and keep resolution in the decimal 1's position is 224-1. For number larger than that you have to sacrifice resolution. All computers, not just PLCs, are like that. Same is even true for 64 bit floats, its just a bigger mantissa.

I believe there are some technotes about how to use 32 bit integers on PLC/5s in the AB knowledgebase.
 

Similar Topics

I'm running into a problem when trying to use the RSLinx Backup Restore Utility where it throws an error when it tries to restore a backup. The...
Replies
6
Views
571
Hi y'all I have a KTP400 connected to a s7-1200. Now i have on my screen the encoder value which comes from my SEW movitrac. under there I have...
Replies
2
Views
387
This was asked in another forum and taken down due to being a 'backdoor', but this has useful info that might be useful to someone in a pinch. I'm...
Replies
6
Views
608
Hello all, I'm using a 5069-L330ER in a project and I need to essentially capture some data that will be shown as a trend on a screen. The data...
Replies
9
Views
962
Hi all, I am working with an IO link sensor (measuring current across motor)and need to read in and store the sensor values for 5 seconds, then...
Replies
13
Views
1,213
Back
Top Bottom