Explaining integers vs floats in modbus

Dan Jobin

Member
Join Date
Jan 2008
Location
Calgary
Posts
3
I have to explain why I need two integers to display a decimal place in an HMI application when sending floats via modbus. Unfortunately the individuals that I am dealing with have zero experience with PLCs, integers, floats, modbus and the like. Does anybody know of a document which explains this in laymen terms? Thanks for your help.
Dan.
 
Rather than thinking in terms of integers, think in terms of bits. An integer can be 16 bits or 32 bits, but it takes 32 bits to encode a float.

To further confuse things, there are some HMIs that let you stick a decimal point on an integer. For example, the HMI might let you display the integer 12345 as 12.345. In that case, the HMI is not reading a float from the PLC
 
Dan Jobin said:
I have to explain why I need two integers to display a decimal place in an HMI application when sending floats via modbus. Unfortunately the individuals that I am dealing with have zero experience with PLCs, integers, floats, modbus and the like. Does anybody know of a document which explains this in laymen terms? Thanks for your help.
Dan.

Very simply (and taking some liberties), a float requires two pieces of information: the mantissa and the exponent, therefore you need two 16 bit registers.
 
Try counting pennies.

If I have 1,754 pennies, I also have an equivalent in dollars, $17.54. I don't actually have dollars, I have the equivalent amount, in pennies, a total count of 1, 754 pennies

A penny is 1/100 of a dollar. So, 1,754 pennies is a total count of 1,754 hundreths (of a dollar).

That value of 1,754 can be communicated as an integer value, a whole number.

When the sender sends a count of 1,754, that raw value is interpreted at the receiver end as 1,754 pennies.

But what if the goal is to know how many dollars the penny value represents?

The receiver could establish a decimal point and infer a dollar sign and produce an equivalent value of $17.54. All done with an integer value

In the industrial comm world, as others have pointed out, some devices allow a decimal point to be fixed for display of an integer value, to do just this. Others don't. Without a displayed decimal point, one is stuck with solutions like adhesive labels on displays, for correct interpretation of the value.

Floating point is best desribed as values that include an exponent (or some call it engineering notation).

1,754 pennies = $17.54
17.54 = 1754 * 10^-2 which is a similar to a floating point number.

In floating point, two values are needed. In the example above, the two values are 1754 (a mantissa) and -2.00 (the exponent)
The sender and receiver would have to agree (in the example) that the mantissa value is assumed to be multiplied by the value 10 raised to the exponent.

Dan
 

Similar Topics

Hello automation experts, I'm trying to learn about servo axis control in AB ControlLogix PLCs (L33ERMS). Attached is an example of a servo...
Replies
4
Views
1,075
Hey everyone, In the middle of deciphering STL code in S7 plc and I'm confused. I interpret the following code to be load the register "#Step"...
Replies
11
Views
2,066
Hi all, I have volunteered to teach the electrical merit badge to a group of boyscouts Saturday and i'm kind of stuck on something. I can...
Replies
17
Views
5,718
Hello All, I am currently updating an existing vessel that has 6 valves for a customer. I'm new to plc's but picking it up pretty well. I trying...
Replies
4
Views
2,294
Greetings to all ... in a recent post, a new member made this polite request: (a clear-cut case of "be careful what you ask for") ...
Replies
8
Views
7,424
Back
Top Bottom