Follow+Star Public Account, don’t miss wonderful contentAuthor | strongerHuangWeChat Public Account | Embedded ColumnRecently, some friends asked about Modbus issues. This article briefly describes some common problems with Modbus.You may not know what Modbus is. In fact, Modbus is widely used in real life and is present in almost all industrial electronic device systems.
What is Modbus?
Modbus is a communication protocol developed by Modicon (now Schneider Electric) in 1979 for PLCs, primarily used for network communication between industrial electronic devices.Modbus is an application layer communication protocol that operates at the 7th layer of the OSI (Open Systems Interconnection) model. It provides client/server communication between devices connected on different types of buses or networks.Modbus consists of one Master and up to 247 Slaves in a communication network.For more information about Modbus, you can refer to:https://modbus.org/
What is Modbus Used For?
Modbus is an open communication protocol that you can apply to your devices free of charge.Modbus is a widely used standard communication protocol. If you and other manufacturers’ devices all adhere to the Modbus standard protocol, you can communicate and transfer data.
How Does Modbus Work?
Modbus typically communicates over UART serial 485. The simplest communication between one master device and one slave device is done via serial Tx and Rx for data transmission.The underlying serial communication is the familiar “0” and “1” communication, on which the Modbus communication protocol is added to facilitate protocol parsing and multi-device networking.In a master-slave configuration, each slave device has a unique address, allowing the master to communicate with the corresponding slave by parsing the slave address.
What is Modbus ASCII?
Modbus ASCII is one of the transmission modes in the Modbus protocol, with another mode being Modbus RTU.After Schneider Electric acquired Modicon, they introduced the Modbus TCP protocol.Protocol Format:
What is a Slave Address?
A slave address (or slave station ID) is a unique address assigned to each slave device to facilitate identification during communication establishment by the master. The slave address is typically set at the factory.
What is a Function Code?
The function code is an element of the Modbus communication protocol, with the second byte sent by the master being the function code. This is what you see when reading and writing coil registers.Here are some common function codes:
What is CRC?
Standard communication protocols generally include a checksum to ensure that the transmitted data is error-free. Checksums, such as checksum and CRC check, are common in embedded device communication protocols.Modbus uses CRC cyclic redundancy check, with the checksum information located in the last two bytes of the message.Here is a recommended reading: How to Implement a Custom Serial Communication Protocol?References:http://www.simplymodbus.ca/crc.xls
What is Word/Byte Order?
Byte order refers to whether the high byte or low byte is transmitted first. For example: 0x1234, which consists of two bytes, is typically transmitted as 0x12 and 0x34.In communication, byte order can be an issue, but the Modbus specification does not precisely define how data is stored in registers.Since the Modbus standard protocol does not specify this, developers need to agree on whether to transmit the high byte or the low byte first during development.
In Conclusion
Modbus is a widely used standard communication protocol. Students in industrial automation, electronics, and embedded systems are encouraged to take some time to learn about it.Due to time constraints, this article only covers some basic content. For more detailed introductions and specifics of the protocol, please visit the official website.https://modbus.org/(The public account does not support external links, please copy the link and open it in your browser)———— END————●Column “Embedded Tools”●Column “Embedded Development”●Column “Keil Tutorial”●Selected Tutorials from Embedded ColumnFollow the public account and reply “Add Group” to join the technical exchange group according to the rules, reply “1024” for more content.Click “Read Original” for more shares.