↑ Solidot slice serial communication module XB6S-C01SP
Thermometers and weighing tables used in food and medical treatment, pressure gauges used in the 3C industry, and the most widely used inverters in the automotive lithium battery and logistics industries all use Modbus protocol communication. However, in actual use scenarios, they cannot communicate directly with the fieldbus and need to be transferred through the module to read the current status of the device or change the output status of the device.
The role of the XB6S-C01SP slice serial communication module of Solidot Technology is just like this. It can convert other bus protocols into serial communication protocols. This article is based on the Modbus communication protocol and explains in detail how to use the XB6S-C01SP module in the Modbus protocol.
1. Definition of Modbus protocol
Modbus protocol is a general communication protocol that has been widely used in the field of industrial control today. Through this protocol, controllers can communicate with each other or with other devices via a network (such as Ethernet).
2. Function of Modbus protocol
Protocols are generally used to specify the conditions and factors required for information transmission, and rules set to achieve communication. For example, A needs to ask B to get some status of B. A sends a set of data to B: 12345. After receiving this set of data, B replies to A: 54321, thus completing a set of data interaction, but these data are not convenient to transmit in common language or font.
At this time, digital transmission is particularly important, but the meanings of the numbers need to be formulated in advance. The formulation of the protocol is to let two people understand a set of data transmitted according to this protocol, thus deriving the Modbus serial communication protocol.
3. Modbus protocol mode
In fact, Modbus transmission is divided into 3 modes:
1. ModbusRTU
2. ModbusASCII
3. ModbusTCP
These three protocols actually belong to the Modbus protocol because the message formats of these three protocols are generally consistent. Among them, the serial port form is the most common RTU type, and TCP refers to the transmission on the network cable end.
4. Modbus protocol communication method
The Modbus protocol belongs to master-slave communication, which means that "one question and one answer" is required. During the communication process, the slave will respond only after the host sends a request command. If the host does not send, the slave will not respond. This is also the limitation of Modbus. When this "one question and one answer" method can occur when one master corresponds to multiple slaves, it is necessary to distinguish each slave station and give each slave station a "name", so the slave station number appears.
5. Specific expression of Modbus protocol
Modbus protocol frame structure = address + function code + data + checksum
1. Address: the slave station "name" we mentioned before - slave station number
2. Function code: specifies what this instruction does, whether it is a query or an execution command
3. Data: used to fill in the location information of the specific command execution
4. Checksum: Since there may be errors in the data area, all data are calculated and added to verify the correctness of the message transmission
6. Modbus Protocol Example
Now that we know the composition of the Modbus protocol, let's analyze two examples of reading and writing.
[Example 1] Read holding register (03)
Send: 01 03 00 00 00 02 C4 0B
Receive: 01 03 04 A0 B0 C0 D0 88 48
Send: Slave station number (01) + Read holding register function code (03) + Modbus starting register address (00 00) + Read register number (00 02) + Modbus checksum (C4 0B)
Reply: Slave station number (01) + Read holding register function code (03) + Read total number of bytes 2*Number of registers (04) + Read register data content (01 02 03 04) + Modbus checksum (88 48)
[Example 2] Write holding register (16)
Send: 01 10 00 10 00 03 06 01 02 03 04 05 06 5D D3
Receive: 01 10 00 10 00 03 81 CD
Send: Slave station number (01) + Write holding register function code (10) + Modbus start register address (00 10) + Write register number (00 03) + Write total bytes (06) + Write register data content (01 02 03 04 05 06) + Modbus check code (5D D3)
Receive: Slave station number (01) + Write holding register function code (10) + Modbus start register address (00 10) + Write register number (00 03) + Modbus check code (81 CD)
7. Use of XB6S-C01SP module
Through the above detailed explanation, we already know how to use the Modbus protocol. Now we need to use the XB6S-C01SP module to replace the serial port to send messages to realize information transmission between devices. The master station uses the XB6S-C01SP module and uses the serial communication line to connect to the computer. The function code message of the above case is used to control the software ModbusSlave (Modbus slave station simulation) and the serial port debugging assistant to read the message to express——
1. First, configure. Here, take the EtherCAT protocol as an example, with the XB6S-EC protocol coupler XB6S-EC2002 of Solidot Technology:
2. Configure the module parameters, set the usage function, baud rate, stop bit, check bit and other parameters respectively, and keep them consistent with the serial port device:
The definition of node parameters is quite special and is also the most important part of configuration parameters. Fill in the required function code, address and other data according to the calculation table and you can finally calculate:
Node_1_Param01(302)
Node_1_Param02(1)
Node_2_Param01(1000603)
Node_1_Param02(1)
3. Fill in the parameter data issued:
After setting the parameters, write to the module and open the serial port assistant to see that the above example message module will automatically help us edit and send it through the serial port.
4. Open ModbusSlave and adjust it to hold the register. At this time, you can read the address (00 10) and then the data sent by the module is transmitted, and write the data A0 B0 C0 D0 to the address, and you can also read the data on the coupler.
Through the above operations, the XB6S-C01SP module replaces the role of manually writing messages and realizes communication with the device.
The above is a detailed introduction to the use of the XB6S-C01SP slice serial communication module of Solidot Technology in the Modbus protocol. If you have any questions, please feel free to ask, we will serve you wholeheartedly!