105BCommunication processor
12.5 Modbus communication
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05
611
Modbus slave communication rules
●
MB_COMM_LOAD must be executed to configure a port, before a MB_SLAVE instruction
can communicate through that port.
●
If a port is to respond as a slave to a Modbus master, then do not program that port with
the MB_MASTER instruction.
●
Only one instance of MB_SLAVE can be used with a given port, otherwise erratic
behavior may occur.
●
The Modbus instructions do not use communication interrupt events to control the
communication process. Your program must control the communication process by
polling the MB_SLAVE instruction for transmit and receive complete conditions.
●
The MB_SLAVE instruction must execute periodically at a rate that allows it to make a
timely response to incoming requests from a Modbus master. It is recommended that you
execute MB_SLAVE every scan from a program cycle OB. Executing MB_SLAVE from a
cyclic interrupt OB is possible, but is not recommended because of the potential for
excessive time delays in the interrupt routine to temporarily block the execution of other
interrupt routines.
Modbus signal timing
MB_SLAVE must be executed periodically to receive each request from the Modbus master
and then respond as required. The frequency of execution for MB_SLAVE is dependent
upon the response timeout period of the Modbus master. This is illustrated in the following
diagram.
6WDUW
LQWHUYDO FKDUDFWHUWLPHV
0DVWHUVHQGV
5HVSRQVH
GHOD\WLPH
6ODYHVHQGV
5HVSRQVH
WLPHRXWSHULRG
6WDUW
LQWHUYDO
$'5
)&
'DWD
&5&
&5&
$'5
$'5
)&
'DWD
&5&
The response timeout period RESP_TO is the amount of time a Modbus master waits for the
start of a response from a Modbus slave. This time period is not defined by the Modbus
protocol, but is a parameter of each Modbus master. The frequency of execution (the time
between one execution and the next execution) of MB_SLAVE must be based on the
particular parameters of your Modbus master. At a minimum, you should execute
MB_SLAVE twice within the response timeout period of the Modbus master.