Technical characteristics of MODBUS bus control system - Database & Sql Blog Articles

Spot Remarks 2017+
RF cable can be customized for other specifications
Photocoupler

The MODBUS communication protocol is an industrial fieldbus communication protocol, which defines an information frame structure that can be identified and used by a device controller. It is independent of the physical layer medium and can be carried in multiple network types. The MODBUS protocol defines communication participants as "master" and "slave". The communication of data and information follows the master/slave mode. When it is applied to a standard MODBUS network, the information is transmitted directly. The smart devices in the MODBUS bus network are connected via an asynchronous serial bus, allowing only one controller to act as the master and the remaining smart devices as slaves. With the command/response communication method, the primary station issues a request, the secondary station answers the request and sends back data or status information, and the secondary station cannot send the information by itself. The various information frame formats defined by the MODBUS protocol describe the process by which the master controller accesses the slave device, specify how the slave responds, and check and report transmission errors. Each slave in the network must be assigned a unique address, and only the slaves that meet the address requirements will respond to commands from the master.

Due to the low development cost of MODBUS bus system, it is easy to use, and many industrial controllers, plcs, displays, etc. all have MODBUS communication interfaces, so it has become a recognized communication standard. Through the MODBUS bus, it is very convenient to connect control devices produced by different manufacturers into an industrial network for centralized monitoring.

MODBUS was originally designed for PLC communication, and it exchanges information between the PLC and the outside world through 24 bus commands. The communication functions corresponding to these bus commands mainly include data transmission of AI/AO and DI/DO. But not many MODBUS devices control only use a few of these commands and do not respond to the rest of the commands.

1.MODBUS communication format

The MODBUS protocol defines two transmission modes, RTU (Remote Terminal Unit) and ASCII. In RTU mode, 1-byte information is sent as an 8-bit character, and in ASCII mode as two ASCII characters. For example, when sending the character "20", it is "00100000" when using the RTU mode. In ASCII mode, it becomes "00110010" + "00110000" ("2" and "0" of ASCII characters). It can be seen that the RTU mode is about twice as efficient as the ASCII mode when sending the same data. In general, the amount of data is small and ASCII is mainly used for text; when the amount of communication data is large and it is a binary value, the RTU mode is often used.

The primary station can send a communication request (or command) to one or all of the secondary stations at a time, and the primary device strobes the secondary device through the address field of the message frame. The content and sequence of the message frame sent by the primary station are: slave address, function code, data field (data start address, data amount, data content), CRC check code; information content and sequence of the slave station response and the master station The information frames are basically the same. In addition to defining the communication function code, MODBUS also defines an error code to mark the error message. After receiving the error code, the primary station takes corresponding measures according to the cause of the error. The data content of the slave acknowledgment responds according to the function code. For example, function code 03 requires reading the contents of the holding register in the slave device.

MODBUS part function code

2. Implementation of CRC check

In the RTU mode of MODBUS communication, the last two bytes of the information frame are specified to pass a CRC (Cyclic Redundancy Check) code. The sender shifts all the bytes of the address field, function code and data field in the information frame in a prescribed manner and performs XOR (exclusive OR) calculation to obtain a 2-byte CRC code and includes the CRC check code. The information frame is transmitted as a continuous stream. The receiver performs the calculation in the same way when receiving the information frame, and compares the result with the double byte of the received CRC code. If it is consistent, the communication is considered correct, otherwise the communication is considered incorrect, and the slave will send a CRC error. answer.

The RTU mode generally adopts the CRC-16 redundancy check method, and the check code of the CRC-16 is 16 bits (2 bytes), wherein the low byte is first and the high byte is after. There are two ways to implement the CRC check: calculate according to the definition formula of the CRC check, or establish a CRC check value table in the program. It is easier to implement the former in the program. Here you need to use the CRC generator polynomial X16+X15+X2+1. The code group coefficient corresponding to the polynomial is 18005H (hexadecimal), and the highest bit is removed, and the corresponding 16-bit remainder is 8005H, which is the CRC-16 constant. The CRC-16 check process is as follows: each bit of the CRC register is preset to 1; the register value is XORed with the 8-bit information frame data, and the result is stored in the register; the CRC register is shifted from high to low. , the zero bit is added to the highest bit (MSB), and the least significant bit (LSB, which has been shifted out of the CRC register after shifting) is 1, if the register is XORed with the CRC-16 constant, otherwise if the LSB is zero, then No XOR is required. The above-mentioned high-to-low shift is repeated 8 times, and the first 8-bit data is processed, and the value of the register is XORed with the next 8-bit data and the same 8-time shift is performed as before. The value in the CRC register after all character processing is completed is the final CRC value. When the CRC is added to the message, the low byte is added first, followed by the high byte.

3. Link characteristics

The physical layer of the MODBUS standard can use RS-232 serial communication, but RS-422 or RS-485 is often used in long-distance communication. In the case of multi-point communication, only RS-485 mode is adopted, so the MODBUS system in RTU mode adopts shielded twisted pair cable, and the communication distance can reach 1000m. Up to 31 slave devices can be configured on one bus. The information exchange on the transmission line is half-duplex, that is, only one device can transmit information at the same time, and the primary station waits for the slave to respond before sending the next instruction, thereby avoiding line conflict.

The transmission format of the RTU mode is 1 data bit, 2 stop bits, and no parity bit. Communication data security is guaranteed by the control parameter CRC-16 code. The RTU receiving device determines the start of a frame by the elapsed time between receiving characters. If there are no new characters or no completed frames after 3 and a half characters, the receiving device will give up the frame and set the next character as new. The beginning of a frame.

Coat And Jackets

Coat And Jackets ,Long Trench Coat,Sheepskin Jacket,Beige Trench Coat

GUANGZHOU LIWEI ELECTRONICS CO.,LTD , https://www.gdliwei.com