What is Modbus Communication Basics?
Developed in 1979, Modbus industrial serial protocol makes communication between automation devices possible. It is used with programmable logic controllers or PLCs. It transmits the information over serial lines that exist between electronic devices. The Modbus Master requests the information and the device that supplies the information are the Modbus Slaves. In a standard network, there are up to 247 slaves and one master. Each of the slaves have their own unique addresses. The master has the ability to write information the each of the slaves. The slave device has to wait to be asked for information and cannot give it without permission. The master writes the data to a slave devices registers and also reads the data from the registers.
What Modbus is used for?
This common protocol is used by many devices for efficient, reliable, and simple over many of the modern networks. A giant server can be used as the master for a PLC and then the PLC can be used as a valve, motor, sensor, or other device that is embedded. It is now the standard in the industry when it comes to communications protocol and the most available way to connect industrial electronic devices. Many manufacturer’s use it in various industries. It is mostly used to give off signals from control devices and instrumentation back to system gathering data or main controller. An example could be a system that tells the humidity or temperature back to a computer. A remote terminal unit or RTU within a supervisory control and data acquisition or SCADA system can be connected to a Modbus.
Modbus/TCP can make the definition of slave and master less obvious. That is because the Ethernet can allow for a communication system that works as a peer to peer connection. The client and the server are better known in Ethernet-based networking. When this happens, the slave can become the server and the master can become the client. That allows for more than one client to obtain data from the server. That way there is a chance of having multiple masters and multiple slaves. It allows for a system where the slave and the master are not defined on a physical device.
How does Modbus work?
Serial lines transmit the Modbus between devices. In a simple setup, there is a single serial cable that is connected to two serial posts, the master and the slave. Then the data is sent in bits, which are a series of ones and zeros. They are sent as a voltage. The zeros are positive volts and the ones are negative volts. These bits very quickly sent at a speed of 9600 bits per second called a baud.
Popular terms to know
When dealing with a Modbus communication protocol, you will want to know some popular terms. They will help you understand the concepts better.
- Hexadecimal: Every block of eight bits which is called a byte. It can be represented by pairs of 256 characters from 00 to FF. Long strings of zeros and ones can be difficult to read. The bits are shown and combined in hexadecimal. Each of the block of four bits are represented by one of the sixteen characters ranging from 0 to F.
- ASCII: It stands for American Standard Code for Information Interchange. Every eight bits can be represented and combined by one of the 256 ASCII characters just like every 4 bits can be represented and combined by one of the sixteen hexadecimal characters from zero to F.
How is the data stored in a Standard Modbus?
The information is stored in four tables in the slave devices. Two of these tables store the on and off values or coils and two store the numerical values or registers. The registers and coils have a read-write table and a read-only table.
- Every table has 9999 values
- Every contact or coil is one bit. Plus, it is assigned an address between 0000 and 270E
- Every register is one word that equals 16 bits which equals two bytes. They have a data address between 0000 and 270E.
- Coil and register numbers are thought of as location names that do not appear in the message.
What is a Slave ID?
Every slave in the network gets a unique unit address that is between 1 and 247. When there is data requested from the master, the slave address is the first byte that is sent. The reason why it does that is to tell the master whether to ignore the message or not.
What is the function code?
The master sends the second byte as the function code. It is the number that tells the slave what table to access and if it should write to or read from the table.
What is a Cyclic Redundancy Check or CRC?
The two bytes that are added at the end of the Modbus message designed for error detection. All of the bytes in the message are used to calculate the CRC. The device that is receiving the message calculates the CRC and then it compares it to the sending device’s CRC. It is used for protection. If even one part of the message is incorrectly received, the CRC is different and then the error will result.
What is word and byte ordering?
The way the data is stored in the registers is not defined with the Modbus specification. So, some manufactures have implemented Modbus into their equipment that stores and transmits a higher byte first and then a lower byte next. Other devices transmit and store the lower byte first.
The technology is forever changing and improving. The new methods make it easier for communication between master and slave.