Modbus 16-bit words and PLC 32-bit Float / Real

drbitboy

Lifetime Supporting Member
Join Date
Dec 2019
Location
Rochester, NY
Posts
8,088
The topic of reading or writing floating-point values via Modbus seems to come up regularly, and it is to my mind not that difficult.

That said, it is opaque and somewhat tedious to deal with, there may be few diagnostic tools available, and not everyone natively reads the bits of IEEE-754 format.

To try to ameliorate that, I wrote a Visual Basic (VB) application to return all possible byte- and word-order combinations from a single floating-point value; one of them should be the correct value; see below. The idea is straightforward: say you are reading two 16-bit words from a Modbus server, and a naive COPy on the PLC from a word pair to 32-bit float yields 5.900879e-39, when you know the value is around 12.0. You can use the app (first image below) to create a minimal Modbus pseudo-server (RTU) that sends all 24 four-byte possible combinations (48 words; 96 bytes) of the data that yield that value. The second image shows a MicroLogix program using a MSG instruction as a Modbus client to retrieve the 48 16-bit words and COPying them into 24 32-bit REALs. You can see that F254:5 and F254:16 are both 12.00006 (two of the four bytes are the same) and is likely to be the right answer, and the hexadecimal values show in the VB app (top image) would guide you to understanding how to achieve that result.

At some point I'll put this on Github and the Download area here; it should be possible to add Modbus TCP capability.

yyy.png

xxx.png
 

Similar Topics

Hi, Im doing a project with a Power meter that offers Modbus TCP and each signal is a 32bit Float.¨ I tested the float in Modbus Poll and...
Replies
22
Views
3,086
Hi eveyone. I need transfer signal from system 1 to DCS via modbus. System 1 only can send 32 bit floating point. DCS receive 16 bit integer. How...
Replies
20
Views
10,588
Hello, I'm using Compact Logix L33 in RSLogix 5000. I'm trying to message over modbus register that is 16bit UINT. In Rslogix 5000 do I message...
Replies
3
Views
1,512
Hello, First, please excuse my question I am new to Modbus. I have a CX-5140 control unit from Beckhoff and an instrumentation device that...
Replies
3
Views
3,121
I've got a project where I need to send a 64 bit integer that is in 8 consecutive modbus registers to another device as a string. I see the...
Replies
16
Views
7,939
Back
Top Bottom