Master Modbus communication to increase the efficiency of industrial equipment data transmission by 50%
RS485 is not a communication protocol, but an interface standard. It has two siblings: RS232 and RS422.

The correct wiring method for the 485 interface is a hand-in-hand daisy chain connection. If the communication distance is relatively long (such as over 100 meters), a 120Ω resistor should be connected in parallel at both the start and end of the network to reduce signal reflection at both ends. Normally, if the distance exceeds 100 meters, consideration should be given to adding terminal resistors, and if it exceeds 1000 meters, consideration should be given to adding RS485 bus repeaters.

How many RS485 devices can be connected to one RS485 bus? The specific number depends on the load capacity of the RS485 converter. Generally, the load capacity of RS485 chips falls into three levels, which can support 32, 128, and 256 devices respectively. Typically, the load capacity of the RS485 converter we use is 32 devices.
ModbusRTU is a communication protocol at the application layer, while RS485 is an interface standard at the physical layer. When we talk about ModbusRTU communication, we usually refer to it being based on RS485. However, the ModbusRTU protocol can also be based on RS232/RS422, or even Ethernet TCP/UDP. At the same time, RS485 is not exclusive to ModbusRTU. Any protocol can be transmitted over RS485. Whether one master can communicate with multiple slaves depends on whether the protocol level has designed device addresses. The implementation of one master communicating with multiple slaves requires two conditions: support at the physical layer and support at the application layer. Both are indispensable. For example, if we use RS232 at the physical layer, even if the application layer uses the ModbusRTU protocol, one master communicating with multiple slaves cannot be achieved. (RS232 operates in a one-transmitter-one-receiver mode)

Communication speed is primarily influenced by two factors: the volume of data and the speed of the hardware layer. The volume of data refers to the amount of data that needs to be transmitted, while the speed of the hardware layer is closely related to communication devices and network infrastructure. The speed of the hardware layer is related to both baud rate and communication distance, as the master-multiple-slaves polling mechanism inevitably leads to a decrease in communication efficiency.
There are three types of communication protocols: one is standard protocol, such as Modbus protocol; another is brand protocol, such as Siemens S7, Mitsubishi MC protocol; and the third is custom protocol. The general message format of ModbusRTU is as follows:

[1] Slave address: Who is this message sent to or from.
[2] Function code: What to do, read/write/coil/register.

[3] Data section: Provide corresponding parameters in conjunction with the function code.
[4] Verification section: Ensure the correctness and integrity of the message.
Read output coil

【1】Slave address: 0x01 indicates to read data from slave 1.
[2] Function code: 0x01 indicates that the data being read is from the output coil storage area.
[3] Starting address: Hexadecimal 0x00 0x13 corresponds to decimal 19, indicating that reading starts from coil 19. The Modbus address corresponding to this 19 is 00020. (Note: The Modbus address follows the numbering rule of "offset + 1". Hexadecimal 0x13 (decimal 19) is the "actual offset address" of the coil. The Modbus address needs to be obtained by adding 1 to the offset, that is, 19+1=20, corresponding to the coil address 00020 (coil addresses are usually represented in the format of 000xx).
- Address type differentiation: In Modbus, the address range of coils (discrete outputs) starts by default with "00001" (not 0). Here, "00001" corresponds to the actual offset address 0 (hexadecimal 0x00).
- Conversion logic: Actual offset address (decimal N) → Modbus coil address = N + 1. Here, N=19 (0x13), so 19+1=20, which is formatted as 5 digits as 00020.) [4] Number of coils: Hexadecimal 0x00 0x1B corresponds to decimal 27, indicating that the number of coils read is 27.
[5] CRC Check: 0x8D 0x4C represents the result of the CRC check performed on all the preceding data.
The master station sends this message to read the status values of the output coil storage area of the No.1 slave station, with Modbus addresses ranging from 00020 to 00046, encompassing a total of 27 coils. Upon receiving this message and understanding the master station's intention, the No.1 slave station will respond with a response message as follows:

[1] Slave address: 0x01 indicates the message responded by slave 1.
[2] Function code: 0x01 indicates that the response is for a 0x01 function code message.
[3] Byte count: 0x04 indicates that the returned data consists of 4 bytes.
[4] Byte 1 to Byte 4: The specific data returned are 0xCD, 0x6B, 0xB2, and 0x05, respectively. These four bytes correspond to 32 coil values, with the first 27 coil values corresponding to the values from 00020 to 00046.
[5] CRC Check: 0x00 0x02 represents the result of the CRC check performed on all the preceding data. Upon receiving the response message, the master station acquires the desired data. The specific correspondence is as follows:
0xCD=1100 1101 corresponds to 00027-00020
0x6B=0110 1011 corresponds to 00035-00028
0xB2=1011 0010 corresponds to 00043-00036
0x05=0000 0101 corresponds to 00051-00044
[Explanation: To convert byte 0xCD (11001101) into a Modbus address, the core is to first clarify the Modbus address type (bit address/register address), and then convert according to the "byte-to-address mapping rule" - Modbus does not have a universal "byte-to-address" standard, and the key lies in the "starting reference + address type" defined by the device.
The most common scenario: conversion to Modbus bit addresses (discrete inputs/coils, 1 bit = 1 address)
In Modbus, 1 byte equals 8 binary bits, with each bit corresponding to a "bit address" (such as the discrete input 1xxx area, coil 0xxx area). The conversion is done in 3 steps:
- Determine the "base address" of the byte
Assuming device definition: The starting bit address reference for this byte is N (refer to the device manual, such as common references 20, 100, etc.), and 1 byte occupies 8 consecutive bit addresses.
- Allocate addresses by bit
Byte 0xCD=11001101 consists of 8 bits (bit 0 to bit 7), with the corresponding address being:
Bit 0→N, Bit 1→N+1, Bit 2→N+2, Bit 3→N+3, Bit 4→N+4, Bit 5→N+5, Bit 6→N+6, Bit 7→N+7
Example: If N=20, then the 8 bit addresses are 20~27 (i.e., "00020-00027" you saw before, written in reverse order as 27-20 for annotation convention).
- Supplement the address area prefix
Discrete inputs (read-only) are prefixed with 1→10020~10027; coils (readable and writable) are prefixed with 0→00020~00027 (devices often omit the prefix and directly write 00020~00027). 】 (Note: The original text appears to be an incomplete or unfinished sentence, hence the translation is also incomplete or placeholder. If the original text is incomplete, the translation cannot be completed either.)
So far, a Modbus communication interaction has been completed.










