Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
pk
Sina Institute of Networks & Aesthetics
7 Application Modbus
6 Presentation
5
Session
4
Transport
3
Network
2
Physical RS485
• Data types
– Single bits
– 16-bit registers
• Modbus communications
– Request message sent from the Modbus client to the Modbus server.
– Server replies with a response message.
• Modbus request messages contain:
– An 8-bit Modbus function code that describes the type of data transfer to be performed.
– A 16-bit Modbus address that describes the location in the server to read or write data
from.
– For write operations, the data to be transferred.
The main advantage of the RTU mode is that it achieves higher throughput.
The Modbus frame structure is the same for requests (master to slave messages) and
réponses (slave to master messages).
Modbus RTU
silence Address Function Data Checksum silence Silence >= 3,5 caractères
Modbus ASCII
Valid slave device addresses are in the range of 0 ... 247 decimal. The individual slave
devices are assigned addresses in the range of 1 ... 247. Value 0 is reserved for broadcast
messages (no response).
Request :
A master addresses a slave by placing the slave address in the address field of
the message.
Response :
When the slave sends its response, it places its own address in this address field
of the response to let the master know which slave is responding.
Request :
The function code field tells the slave what kind of action to perform.
Response :
For a normal response, the slave simply echoes the original function code.
Request :
The data field contains additional information which the slave must use to take the action defined
by the function code. This can include items like register addresses, quantity of items to be
handled, etc...
Response :
If no error occurs, the data field contains the data requested.
If an error occurs, the field contains an exception code that the master
application can use to determine the next action to be taken.
Request :
The checksum is calculated by the master and sends to the slave.
Response :
The checksum is re-calculated by the slave and compared to the value sent
by the master.
If a difference is detected, the slave will not construct a response to the master.
Request :
Response :
Parity checking
Even or odd can be optionally applied to each character.
Frame checking
LRC or CRC is applied to the entire message.
Continuous stream
The entire message frame must be transmitted as a continuous stream.
If a silent interval (more than 1.5 character times RTU mode or 1 second ASCII mode) occurs
before completion of the frame, the receiving device flushes the incomplete message and
assumes that the next byte will be the address field of a new message.
The master is configured by the user to wait for a predetermined timeout interval before
aborting the transaction.
This interval is set to be long enough for any slave to respond normally.
If the slave detects a transmission error, the message will not be acted upon.
The slave will not construct a response to the master.
Thus the timeout will expire and allow the master's program to handle the error.