Questions about the MODBUSRTU communication protocol?

1. What is the difference between ModBusRTU communication protocol and ModBus communication protocol?

The ModBus protocol is an application layer message transmission protocol (OSI model layer 7), which defines a protocol data unit (PDU) that has nothing to do with the communication layer, that is, PDU = function code + data field.

The ModBus protocol can be applied to different types of buses or networks. Corresponding to different buses or networks, the Modbus protocol introduces some additional domains and maps them into application data units (ADU), that is, ADU=additional domain+PDU. Currently, Modbus has the following three communication methods:

1. Ethernet, the corresponding communication mode is MODBUSTCP.

2. Asynchronous serial transmission (various media such as wired RS-232-/422/485/; optical fiber, wireless, etc.), the corresponding communication mode is MODBUSRTU or MODBUSASCII.

3. High-speed token transfer network, the corresponding communication mode is ModbusPLUS.

2. Questions about the MODBUSRTU communication protocol?

Modbus is mainly composed of station address (one byte) + function code (one byte) + first address (two bytes) + number of access words (two bytes) + check code (CRC16 or LRC two bytes) in total It consists of 8 bytes. In fact, programming in VB is very simple. Just add MSComm from the assembly. The hard part is verification.

3. What are modbus, rtu, and modbusrtu?

The modbus protocol is a standard protocol in the industrial control industry. It was formerly written by Modicon and has now been acquired by Schneider.

Modbus is divided into two protocols: serial port protocol (modbusrtu) and network port protocol (modbustcp) protocol. General industrial computer only supports rs232 or RS485 serial port mode. At this time, the protocol stack of industrial computer only has modbusRTU protocol. When he receives data from the serial port, he will directly control it according to the data in the message. If you need to use the modbusTCP protocol for transmission, you need to use a PLC with a network port.

The specific frame format is as follows:

ModbusRTU address domain function code data error checking

modbusTCP destination address protocol id length unit number function code data

Simply put, tcp is processed by RTU, while RTU is another concept, not included in the modus protocol, and is the abbreviation for monitoring equipment in the industrial control industry.

Fourth, some questions about the commands sent by the modbus_RTU protocol host

01 Read coil status (Read coilstatus)

02 Read input coil status (Readinput status)

03 Readholding register

04 Read input register (Readinput register)

05Write a single coil (Forcesingle coil)

06 Write a single register (Presetsingle register)

15Write multiple coils (Forcemultiple coils)

16 Write multiple registers (Presetmultiple registers)

What do these mean

Answer: 01 Read the status of the logical coil group

02Read discrete coil group status

03Read the binary value of one or more holding registers

04Read the binary value of one or more input registers

05 Change the state of the logic coil

06 Change the binary value of a single register

15 change the binary value of multiple registers

16 Specify the binary value of multiple operating registers

5. OPC to modbusRTU mode I currently have an OPC server with many tags in it. The tags are from AB. How to connect the tags to modbus?

Profibus, Fielbus, Modbus, CC-link, etc. are the communication protocols supported by various PLC hardware. This is the same as the hardware attributes of various manufacturers. Only now the computer configuration software supports PLC of many kinds of agreements. You understand it the other way around.

Protocols such as Profibus, Fielbus, Modbus, and CC-link are a communication protocol. Generally, you do not need to program it, just as if you use a computer, you do not need to write an IP protocol, just follow it.

To follow means that you must set up the hardware according to the communication protocol when configuring the PLC or DCS hardware according to the protocol supported by the manufacturer. In fact, this is very simple. This simply means that you learn programming, and the focus is to write programs that perform control actions. The hardware communication protocol does not require you to write by yourself.

6. What is modbusrtu master?

It is to choose RTU mode, because MODBUS is divided into ASCII mode and RTU mode, MASER is set as the master station, usually the PLC side, the inverter is set as the slave station, but also pay attention to the settings of the master station and the slave station address.

7. Why does Modbusrtu have no start and end marks?

Since each byte of the Modbusrtu frame is a hexadecimal number, the value range is 00~FF. If 02 and 03 are used to represent the start and end tags like ModbusASCII, they will conflict with the values ​​2 and 3, and it is impossible to judge whether it is a tag or Value, data cannot be unpacked.

8. Conversion from modbustcp to rtu?

Please check the frame format carefully:

ModbusRTU address domain function code data error checking

modbusTCP destination address protocol id length unit number function code data

Write a TCP to RTU program and put it in the device as a modbus bridge

9. The MODBUSRTU communication line is burned?

Use a multimeter to measure the communication line. The voltage should not exceed 5V. It should be no problem. Generally, you will not burn things. When connecting, distinguish between positive and negative. Many products B are positive, take a look.

10. How to set the touch screen modbusrtu?

It is usually realized by self-programming through macro instructions, of course, there are also those that support RTU. In the communication type menu

11. How is the floating point number stored in the MODBUSRTU protocol? How to convert the value read in the floating point number register into the required floating point number?

The byte format saved by floating-point numbers is as follows:

Address +0 +1 +2 +3

Content SEEE EEEE EMMM MMMM MMMM MMMM MMMM MMMM

Here S stands for the sign bit, 1 is negative, 0 is positive

E offset to the power of 127, binary order code = (EEEEEEEE) -127.

The mantissa of M24 bits is stored in 23 bits, only 23 bits are stored, and the highest bit is fixed at 1. This method uses the least number of digits to achieve higher effective digits and improves accuracy. Zero is a specific value, and the power is 0 and the mantissa is also 0.

The floating point number -12.5 is stored in the storage area as a hexadecimal number 0xC1480000. The value is as follows:

Address +0 +1 +2 +3

Content 0xC1 0x48 0x00 0x00

The conversion between floating-point numbers and hexadecimal equivalent saved values ​​is quite simple. The following example illustrates how the above value -12.5 can be converted. Floating point saving value is not a direct format. To convert to a floating point number, the bits must be saved according to the above floating point number format table

Separate as listed, for example:

Address +0 +1 +2 +3

Format SEEEEEEE EMMM MMMM MMMM MMMM MMMM MMMM

Binary 11000001 01001000 00000000 00000000

Hexadecimal C1 48 00 00

The following information can be obtained from this example:

The sign bit is 1, which means that a negative power is 10000010 in binary or 130 in decimal, and 130 minus 127 is 3, which is the actual power. The mantissa is the following binary number 10010000000000000000000

There is an omitted decimal point and 1 on the left of the mantissa. This 1 is often omitted in the storage of floating-point numbers. Add a 1 and the decimal point to the beginning of the mantissa to get the mantissa value as follows:

1.10010000000000000000000

Next, adjust the mantissa according to the exponent. A negative exponent moves the decimal point to the left. A positive exponent moves the decimal point to the right. Because the exponent is 3, the mantissa is adjusted as follows:

1100.10000000000000000000

The result is a binary floating point number, and the binary number to the left of the decimal point represents the power of 2 at the position, for example: 1100 means

(1*2^3)+(1*2^2)+(0*2^1)+(0*2^0)=12.

The right side of the decimal point also represents the power of 2 at the position, but the power is negative. For example: .100... means (1*2^(-1))+(0*2^(-2))+(0*2^(-2))...=0.5.

The sum of these values ​​is 12.5. Because the sign bit is set to indicate that the number is negative, the hexadecimal value 0xC1480000 represents -12.5.

12. RS-485 equipment complies with MODBUS-RTU protocol. How to use the computer to read the information?

Use the computer's serial port, connect a 485 converter, connect to the device's 485 interface, and then find a serial port software, send modbus messages according to the register address on the device data, modbus messages are sent through the serial software, message format: 0103 00 00 00 01 840A read register command.

13. How to write data sent by vbmodbus to modScan32rtu?

Determine which of the two software is the master and which is the slave. Then determine whether the communication protocol is RTU, ASCII or TCP. If it is TCP, use the socket control. COM control is used for RTU\ASCII. Then send and receive data to the corresponding port according to the protocol and analyze it.

14. What is the difference between ModBusRTU communication protocol and ModBus communication protocol?

Modbus protocol includes MODBUSRTU

15. How does the modbusrtu communication protocol judge the timeout?

Set a flag to indicate whether it is timed out; use a timer, and the timing duration is the time to send 3.5 characters (of course, the time can be longer for insurance); set the timeout flag in the timer; every time it is received in the serial port interrupt The timer is cleared at one byte; the main program performs corresponding processing according to the timeout flag.

16. How to understand the 1.5 and 3.5 character interval in RTU mode of MODBUS protocol?

There must be a certain time interval between sending two frames of data to ensure that the receiver UART can distinguish. This time interval in MODBUSRTU mode requires 1.5 and 3.5 character intervals, that is, the time for transmitting 1.5 and 3.5 characters. It is related to the set communication parameters and is calculated as:

If the serial communication parameters are set to (Note: the start bit is fixed at 1): data bit 8, parity bit 1, stop bit 1, baud rate 9600bps, then the time to transmit one character (ie 1 byte) is: (1+8+1+1)/9600=0.00114583s=1.1454583ms

1.5 character interval=1.5x1.1454583ms=1.71818745ms

3.5 character interval=3.5x1.1454583ms=4.00910405ms

17. MODBUSRTU test software?

Recommendation: modscan32 and the latest mobuspoll

18. With MODBUSRTU protocol, the host computer communicates with the instrument, and the data read and write are correct. Why are the written parameters lost when the instrument is powered off? How to save it?

Two possibilities:

1. If the parameters set on the meter cannot be saved after power off, it can basically be determined that it is a meter problem;

2. Some meters also need to write confirmation parameters to a fixed register after writing parameters. To ensure that the written parameters are true, you need to check the instrument communication part manual.

Conecting Terminals Without Screws

Conecting Terminals Without Screws,Cold Pressing Terminals,Low Pressure Cold Shrinkage Terminal,Cold Shrinkage Cable Terminals

Taixing Longyi Terminals Co.,Ltd. , https://www.txlyterminals.com

Posted on