Introduction:
The MODBUS - rtu remote water meter is a kind of support the MODBUS communication protocol for remote transmission, collection, management, measurement, monitoring, and other functions of intelligent water meter, is one of the cable remote transmission of water meter, brought water supply unit and water stability, effective communication methods, at the same time, let both sides feel convenient measurement and management.
In general, modbus-RTU remote water meter we use adopts Modbus-RTU communication protocol, which defines the calibration code and data serial number of water meter in detail, all of which are necessary for data exchange. Generally, the Modbus-RTU communication protocol we use is the master-slave connection, that is, the signal on a communication line can be transmitted along the opposite two directions, providing a more accurate and faster communication mode for staff, so that people quickly enjoy the measurement advantages brought by science and technology.
This water meter uses modbus-RTU communication protocol, which defines the verification code, data sequence, etc., which are necessary contents for specific data exchange. The MODBUS protocol uses a master-slave reply connection (half duplex) on one communication line, which means that signals travel in opposite directions on a single communication line. First, the signal from the main computer is addressed to a unique terminal device (slave machine), and then the reply signal from the terminal device is transmitted to the main computer in the opposite direction.
MODBUS protocol only allows communication between the host (PC, PLC, etc.) and terminal devices, and does not allow data exchange between independent terminal devices, so that terminal devices do not occupy the communication line when they are initialized, but only respond to the query signal reached the local machine.
The modbus-RTU format does not contain the start and end characters, but requires an additional waiting time. The waiting time is not less than 3.5 characters.
(1) Transmission mode
The information is transmitted asynchronously in bytes. The communication information transmitted between the host and slave is in 10-bit format, including one start bit, eight data bits (the least significant bit is sent first), no parity bit, and one stop bit.
(2) Data frame format
Address code | Function code | Data area | CRC check code |
1 byte | 1 byte | N bytes | 2 bytes |
*Address code: The address code consists of one byte (8-bit binary code) at the beginning of the frame, and ranges from 0 to 255 in decimal notation. Only 1 to 247 is used in the water meter. Other addresses are reserved. These bits identify the address of the user-specified terminal device that will receive data from the connected host. The address of each terminal device must be unique, and only the terminal addressed will respond to the query containing that address. When a terminal sends back a response, the slave address data in the response tells the host which terminal is communicating with it.
Function code: The function code tells the addressable terminal what function to perform. The following table lists the function codes used in this series of meters, as well as their meanings and functions.
Function | Function | Operation |
03H/04H | Read data register | Gets the current binary value of one or more registers |
10H | Preset multiregister | Sets binary values to a series of multiple registers |
*Data area: The data area contains the data required by the terminal to perform specific functions or the data collected when the terminal responds to queries. The content of this data may be numerical values, reference addresses, or setting values. For example, the function code tells the terminal to read a register, and the data area needs to specify which register to start from and how many data to read. The embedded address and data varies according to the type and content of the slave machine.
CRC check code: The error check (CRC) field takes up two bytes and contains a 16-bit binary value. The CRC value is calculated by the transmission device and then appended to the data frame. The receiving device recalculates the CRC value when it receives the data and then compares it with the value in the RECEIVED CRC field. If the two values are not equal, an error occurs.
The process for generating a CRC is as follows:
1. Preset a 16-bit register 0FFFFH (all 1s), called CRC register.
2. Xor operation is performed between the 8 bits of the first byte in the data frame and the lower byte in the CRC register, and the result is stored back to the CRC register.
3. Move the CRC register one bit to the right, fill the highest bit with 0, and move the lowest out and detect.
4. If the lowest level is 0, repeat the third step (next shift); If the least significant is 1, xOR is applied to the CRC register with a preset fixed value (0A001H).
5. Repeat steps 3 and 4 until 8 shifts. This completes a complete eight bits.
6. Repeat steps 2 through 5 for the next octet until all byte processing is complete.
7. The final CRC register value is the CRC value.
There is also a method of calculating CRC using preset tables, which is characterized by fast computation but requires large storage space. This method is not described here, see related resources.
Communication application format details
(1) Function code 03H: read register
This feature allows users to obtain data and system parameters collected and recorded by the device. There is no limit to how much data a host can request at a time, but the data cannot exceed the specified address range.
The following example is the basic data collected from machine reading 1 on 01 (2 bytes per address in the data frame). The collected data is the total water consumption (occupying 4 bytes) and its address is 00H.
The host transmission | Send message | From the machine | Receive message | |||
Address code | 01H | Address code | 01H | |||
Function code | 03H | Function code | 03H | |||
Thestarting address
| High byte | 00H | The number of bytes | 04H | ||
Low byte | 00H | Register data
| High byte | 00H | ||
Register quantity
| High byte | 00H | Low byte | 12H | ||
Low byte | 02H | Register data
| High byte | D6H | ||
CRC check code | High byte | C4H | Low byte | 87H | ||
Low byte | 0BH | CRC check code | High byte | 44H | ||
Low byte | 34H |
Note:1. Read and write properties: "R" read-only, read parameters with 03H command; "R/W" can be read and written, and the write parameter is 10H command. Disallow writing to addresses that are not listed or do not have writable attributes.
2. The mailing address and communication rate of the table are given before delivery and can also be read by the software provided by the company. It can also be set by protocol.
3. The reading measured in the table takes up 4 bytes, in m3. If the read value is 0012D687H (1234567), the metering value is 1234567×0.01=12345.67m3.