How to Parse Floating Point Data in MODBUS

How to Parse Floating Point Data in MODBUS

Get More IIoT Insights

Click the blue text

Follow us

How to Parse Floating Point Data in MODBUS
How to Parse Floating Point Data in MODBUS

HongKe

IIoT

How Industrial Raspberry Pi Parses Floating Point Data in MODBUS

Introduction

The Industrial Raspberry Pi supports the MODBUS TCP/RTU communication protocol, making it widely applicable in scenarios involving devices such as temperature and humidity sensors, electronic scales, and PLCs using the Modbus protocol. When the Industrial Raspberry Pi acts as a MODBUS TCP/RTU master, it can connect up to 30 slave devices, demonstrating its good scalability.

HongKe Technology

Hong

/

Ke

/

Fang

/

Case

01

Challenges Faced

MODBUS slave devices have 16-bit integer data, but more often use 32-bit floating point data, as 32-bit floating point data allows for more precise control during communication. This type is commonly used in scenarios like weight data from electronic scales, temperature/humidity data from sensors, and motor speed.

However, this process faces the challenge of data parsing: the application of floating point data must follow the IEE745 data conversion rules to achieve conversion and utilization with integer data.

Registers can only store 16-bit data, so floating point data will be split into two parts, stored in adjacent registers, as follows:

1. When reading data, the two register data need to be parsed back into floating point data (as shown in Figure 1);

2. When writing data, the floating point data needs to be parsed into two hexadecimal values to be written into the respective registers (as shown in Figure 2).

How to Parse Floating Point Data in MODBUS

Figure 1. Register data merged into floating point data

How to Parse Floating Point Data in MODBUS

Figure 2. Floating point data written to registers

How to Parse Floating Point Data in MODBUS

02

Solution

To address these issues, HongKe provides a parsing method, as follows:

1. Read two register data and merge them into floating point data using bitwise operations.

How to Parse Floating Point Data in MODBUS
How to Parse Floating Point Data in MODBUS
How to Parse Floating Point Data in MODBUS

2. Write a floating point data by splitting the 32-bit floating point data into two 16-bit integer data using bitwise operations, and writing them into two registers.

How to Parse Floating Point Data in MODBUS
How to Parse Floating Point Data in MODBUS
How to Parse Floating Point Data in MODBUS

03

Conclusion

The Industrial Raspberry Pi uses a Debian system, which is highly open-source and can be programmed using C/C++, Java, C#, Python, etc. There are many methods to convert floating point data into hexadecimal integer data and parse it, and the above is just one of the data parsing methods. This method has a margin of error of ±0.01 and can be applied in scenarios where the precision requirement for floating point data is not particularly high. For other parsing methods, engineers are welcome to add WeChat for communication.

How to Parse Floating Point Data in MODBUS

04

Case Introduction

HongKe’s Industrial Raspberry Pi products feature a real-time Raspbian system, built-in Broadco multi-core processors capable of handling complex tasks such as image processing.

How to Parse Floating Point Data in MODBUS

Additionally, it is compact, flexible, low power consumption, supports development using Python/Java/C/C++/C#, Node-RED visual programming tools, and can achieve CPDESYS soft PLC functionality. It helps users quickly create applications in data acquisition and small control scenarios, realizing industrial IoT and digital production.

How to Parse Floating Point Data in MODBUS
How to Parse Floating Point Data in MODBUS
How to Parse Floating Point Data in MODBUS

HongKe – Industrial IoT

HongKe is a high-tech company with over 3 years of experience in the industrial IoT IIoT industry, collaborating with top global companies including EXOR, Eurotech, Unitronics, Matrikon, KUNBUS, etc., providing advanced solutions such as high-end industrial touch screens, high-end edge computers, IoT development frameworks, PLC and HMI integrated machines, OPC UA, industrial-grade Raspberry Pi, SCADA, etc. All members of the IoT division are professionally trained and certified, with an average of over 3 years of technical experience, consistently earning a great reputation from clients. We actively participate in industry associations, making significant contributions to the promotion of advanced technology. To date, HongKe has provided various solutions from hardware to software for numerous users in the industry and has participated in and assisted many OEM equipment development and migration projects, as well as smart factory and industrial 4.0 upgrade projects for end users.

How to Parse Floating Point Data in MODBUS

Follow HongKe for more IIoT cutting-edge knowledge

Previous Issues

Highlights

RevPi Application Cases · Here

Quickly upload sensor data to the cloud in just 4 steps using CloudRai.Box

● How to achieve industrial protocol and MQTT conversion in low-code/no-code?

● Five possible uses of Industrial Raspberry Pi as a soft PLC

● How Industrial Raspberry Pi combined with CODESYS easily solves three major challenges faced by IIOT

Edge Computing · What You Need to Know

● Want to achieve device service? You need a powerful edge device!

● What is the machine-as-a-service model?

● What characteristics should HMI for the food & pharmaceutical industry have?

● Application of intelligent industrial control screen eX707 in underwater remote-controlled robots

What You Want to Know · OPC UA

● How to solve the headache of DCOM configuration

● A step-by-step guide to mastering all your UA servers using OPC UA data platform

Powerful Data Acquisition and Monitoring System · mySCADA

● Example of myBOX wastewater treatment automation and control upgrade

● Remote monitoring example of intelligent buildings/homes

MQTT Broker · HiveMQ

● Helping AGV carts communicate with control systems

● IAV uses HiveMQ and automotive data to build urban flood warning systems

● BMW car-sharing application relies on powerful HiveMQ for reliable connections

Leave a Comment

×