Floating point vs integers

J

Thread Starter

Jim

In designing Modbus slaves how much time should be put into avoiding using floating point in favor of integers? Also, if one were to use floating point how much time should be put into using IEEE-754 as opposed to using any other format? (In this case the PIC18 ...)
 
I'd avoid using floats over Modbus wherever possible. If you can represent your number in 1*10^-n units you are better off. For instance represent your number as 1234 fixed point could be interpreted as 1.234 or 0.1234 depending on your defined units.
 
One advantage of floating point is that the very low analog values (4th, 5th 6th digits to the right of the decimal point) flicker noticeably because industrial analog values never hold that steady down in that region.

That flicker can be handy when using Modbus over wireless because of the tendency of the gateway device to hold the last value 'forever' even if its wireless connection to the field device is severed/lost/down.

I know of applications where the Master compares the most recently read Modbus value from the gateway with the last several values for that same point. If more than 3 successive values are identical, it is assumed that the wireless link from the field to the gateway is down and that the value is 'last valid', not a current value.

Yes, I know many wireless systems offer status bits or hard relay status alarms, but others don't and the test for valid data is checking for dither in the low order data value digits.
 
M
From a user point of view - I always appreciate a nice float implementation. I have integrated numerous SI devices including MultiLins, Analyzers, Flow Computers, CCC controlers, Modicons and AB PLC 5s, SLCs and CLXs: most frequently on Honeywell HPM SIs.

If your slave is going into Oil and Gas, Petrochem or Pulp and Paper then I would highly recommend you provide a Honeywell SI compatible float implementation.

I do not have good details but in general a Honeywell SI card can read "Word Swapped IEEE" Floats in 2 word at adresses 20001-29999. These are extensions to the base protocol. Honeywell also provides support for some type of IEEE floats at 70001-79999 and 80002-89999.

From my side I generally hack around with it until I find the right register combo to get the data I need. For example I found that an analyzer, Daniels I believe, implemented floats compatible with the 7x or 8x registers.

Good Luck!
 
L

Lynn August Linse

Floating point down in small PIC-sized devices is becoming more common.

The problem with integer can be that of changing scaling. For example, some power meters return Amp or Kwh with a multipler based on the current-transformer (CT) used as they attempt to maximize the 16-bits of data. So you read a KWatt value as 17456 ... what does that mean? You need to understand the CT size, as you might use divisor of 250, 62.5, 31.25, etc. This is one more thing to go wrong!

With floating point, the value is 'auto-scaling' and the host doesn't need to understand the physcial details of the installation. A value of 1267.35 Kw is understandable without needing to understand the CT size.

Obviously, some things are easy to scale and understand - if your temperatrue sensor supports -46 to +400 DegF, then returning 7524 when it is 75.24 DegF is natural (divide by 100). But what happens if the probe is changed to a -200 to +2100 DegF probe? 2100 x 100 is no longer 16-bit.

I would evaluate your situation:
1) are there natural scaling for your process which never changes? If so, scaled integers are easiest.
2) does your processor have a IEEE-754 floating point library? (Don't use any other form; don't try to roll your own)
3) do you have the code space for a floating point library?
4) is your process slow enough to allow your small processor to churn away at the software emulation required?
 
> In designing Modbus slaves how much time should be put into avoiding using floating point in favor of integers?
> Also, if one were to use floating point how much time should be put into using IEEE-754 as opposed to using any other
> format? (In this case the PIC18 ...)

Thanks for the valuable input! I do appreciate it. For my application it looks like I can use integers and avoid floats. Worst yet was the floats would NOT of been the standard IEEE754 format (the internal solution proposed here was to use PIC18 floats).

Volts (0-60V), Amps (0-40A) could easily be expressed with 2 decimal places (x100). I also have a date/time clock which could be used to make sure the polling device knows we are alive.
 
Top