Libraries
9.3 Modbus library instructions
S7-200 SMART
System Manual, 09/2015, A5E03822230-AC
451
You can change the number of retries by finding the symbol
mModbusRetries
in the Modbus
master symbol table and changing this value after MBUS_CTRL has been executed. The
mModbusRetries
value is a BYTE with a range of 0 to 255 retries.
Modbus master execution aborts a response from a slave device if the time between
characters in the response exceeds an assigned time limit. The default time is set to 100
milliseconds which should allow the Modbus master instructions to work with most slave
devices over wire or telephone modems. If this error is detected, the MBUS CTRL Error
parameter is set to error code 3.
There may be cases where a longer time between characters is required, either because of
the transmission medium (for example, telephone modem) or because the slave device itself
requires more time. You can lengthen this timeout by finding the symbol
mModbusCharTimeout
in the Modbus master symbol table and changing this value after
MBUS_CTRL has been executed. The
mModbusCharTimeout
value is an INT with a range
of 1 to 30000 milliseconds.
Single vs. multiple bit / word write functions
Some Modbus slave devices do not support the Modbus functions to write a single discrete
output bit (Modbus function 5) or to write a single holding register (Modbus function 6).
These devices only support the multiple bit write (Modbus function 15) or multiple register
write (Modbus function 16) instead. The MBUS_MSG instruction returns an error code 101 if
the slave device does not support the single bit/word Modbus functions.
The Modbus master protocol allows you to force the MBUS_MSG instruction to use the
multiple bit/word Modbus functions instead of the single bit/word Modbus functions. You can
force the multiple bit/word instructions by finding the symbol
mModbusForceMulti
in the
Modbus master symbol table and changing this value after MBUS_CTRL has been
executed. The
mModbusForceMulti
value is a data type BOOL value and should be set to a
"1" to force the use of the multiple bit/word functions when a single bit/register is written.
The accumulators (AC0, AC1, AC2, AC3) are used by the Modbus master instructions and
appear in the Cross Reference listing. The values in the accumulators are saved and
restored by the Modbus master instructions. All user data in the accumulators is preserved
while executing the instructions.