What is ModBus? What are the differences and connections with RS485 protocol?
[Copy link]
Overview
RS485 is a serial data transmission standard widely used in industrial implementations. When implementing RS485 communications, the Modbus protocol is usually used. This distinguishes RS485 from the RS232 protocol which communicates by transmitting in ASCII characters. To work with devices using the RS485 protocol, it is important to understand Modbus.
content
What is RS485 communication?
What is a Half-Duplex System?
What is Modbus?
- Modbus message
Modbus message format
Serial transmission mode
What is RS485 communication
What is RS485 communication?
RS485 is a protocol similar to RS232 for implementing serial data communications. The two protocols use different electrical signals to achieve data transmission.
One of the reasons why the RS485 interface is used in industrial environments is its ability to serve multiple devices connected to the same bus .
Resolve the need to have multiple interfaces available when querying multiple devices. This can be accomplished by using a bus terminator, moving a switch, or screwing a small resistor onto the terminals. (Be careful to ensure the correct interface is used, as RS485 and RS32 protocols are not fully compatible.) Build a gateway between the RS232 and RS485 interfaces (It is common to see RS485 protocols connected directly to a USB, GSM, or Ethernet port. This less expensive approach eliminates the need to use any additional components)
Devices using RS485 ports usually adopt the Modbus protocol.
The attached table summarizes the characteristics of the RS485 protocol.
RS485 provides half-duplex transmission on balanced lines and can cover distances up to 1.2 km.
What is a Half-Duplex System?
A half-duplex system consists of one or more transmitters and receivers, where communications are initiated by a transmitter that issues a request to a specific receiver. The sender then waits a predetermined length of time for a reply or determines that no further replies will be received from the receiver.
RS485 networks are built on a master/slave framework. The master plays the role of a transmitter , sending requests to the designated slave, which acts as a receiver. The master listens for a response , and if it does not get a response within the appropriate time frame, it terminates the communication.
What is Modbus?
Modbus Messages
01) The principle of Modbus message.
In a Modbus RS485 network, when a master device sends a query to a connected slave,
Communication begins. The slave spends time monitoring the network for queries specifically addressed to it.
After receiving a query, it will perform an action or respond to the master. Queries are initiated only by the master.
The Modbus protocol gives the master the option of addressing a message to a specific slave device or communicating with all slave devices simultaneously. This is done using a special "broadcast" address.
Read and write operations are sent via Modbus messages using coils. Coils consist of 16-bit words and binary registers. Slaves can only respond to received messages and cannot initiate communication with the master .
Each slave device connected in parallel to the RS485 bus is assigned a unique Modbus slave ID. All Modbus communications begin with the sending of the slave ID to alert the slave device to accept the query or to inform the master which device provided the reply.
In the same way as an RS232 connection, the slave and master devices need to be configured correctly. Parameters such as speed and parity need to be synchronized throughout the network.
02) Modbus message format
The message format used in Modbus communication between the master and slaves is defined in the protocol.
A Modbus query consists of the device (or broadcast) address, a function code that defines any requested operation, the data to be returned with the request, and an error checking field.
The Modbus response consists of a field that verifies that the requested action has been taken, the data sent with the response, and an error detection field. If the slave device cannot fulfill the request or an error affects the reception of the message, the slave device will create an error message as its response.
Serial transmission mode
Modbus communication uses two different serial transmission modes: ASCII and RTU.
Modbus ASCII mode: Sends each 8-bit message as two ASCII characters.
Advantages of ASCII mode include the ability to easily monitor messages on a text console. This mode also allows one-second intervals to be accepted without initiating a timeout.
Modbus RTU (Remote Terminal Unit) mode transmits messages in a different format. This time an 8-bit message contains two 4-bit hexadecimal characters. Data using this transmission mode needs to be sent in a continuous stream and has better throughput at comparable baud rates than ASCII mode.
Thank you very much for taking the time to come here. Welcome to leave a message in the comment area and stay tuned for more exciting content.
|