MODBUS question about sending value

chikichaka
Posts: 14
Joined: Tue Aug 09, 2022 7:53 am

MODBUS question about sending value

Postby chikichaka » Tue Dec 13, 2022 5:46 am

I'm developing MODBUS slave device.
so I would like to send float value like 0.123.
I tried to send value to master by MODBUS example from IDF.
Is this right?
Whenever I send 0.xxx, master device read like 0.xxxxxx
Is there anyway that I send just 0.xxx
https://ibb.co/M6DtwwB

ESP_alisitsyn
Posts: 211
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: MODBUS question about sending value

Postby ESP_alisitsyn » Mon Dec 19, 2022 2:11 pm

Hello, @chikichaka ,

Unfortunately, it is not possible to get exactly the same floating point value on these two different platforms.
The ModbusPoll is compiled on Windows and uses the Visual Studio floating point library. The ESP-Modbus uses the gcc compiler with its floating point library. The difference can be hidden in floating point library or in the printf() implementations of the used c libraries. The Windows one prints only 17 significant digits or so, and fills with zeros if more are requested. glibc's prints the correctly rounded value.
The result is the 4 byte IEE754 floating point value is represented differently on these two platforms.

Who is online

Users browsing this forum: MicroController and 116 guests