Академический Документы
Профессиональный Документы
Культура Документы
Note
Use with CM1241
The use of this instruction with a CM1241 is only possible from firmware version V2.1 of the mod‐
ule.
Description
The Modbus_Master instruction communicates as Modbus master via a port configured by the Mod‐
bus_Comm_Load instruction. An instance data block is automatically assigned when you add the
Modbus_Master instruction in your program. The MB_DB parameter of the Modbus_Comm_Load in‐
struction must be connected to the (static) MB_DB parameter of the Modbus_Master instruction.
Parameters
-1-
Modbus_Master: Communicate as Modbus master (S7-1200, S7-1500)
Compatibility_Mode
• FALSE = as per Modbus specification, not compati‐
1) Bool FALSE ble
• TRUE = compatible
o For FC1 and FC2: The data read from the re‐
ceived frame is written word for word to the
addressed CPU memory and exchanged byte
by byte.
-2-
Modbus_Master: Communicate as Modbus master (S7-1200, S7-1500)
You program can write values to the Blocked_Proc_Timeout and Extended_Addressing tags to control
the Modbus master operations.
-3-
Modbus_Master: Communicate as Modbus master (S7-1200, S7-1500)
If multiple calls of the Modbus_Master instruction with different settings for MB_ADDR, MODE, DA‐
TA_ADDR or DATA_LEN are placed in your program, you must ensure that only one of these calls is
active at any given time. Otherwise, the error message 16#8200 is output (interface is busy with an
ongoing request).
If a call cannot be processed in full, the watchdog is activated by the Blocked_Proc_Timeout parame‐
ter and terminates the ongoing command.
REQ parameter
FALSE = no request; TRUE = request to send data to the Modbus slave
Enable the requested transmission. This transmits the contents of the buffer to the point-to-point com‐
munication interface.
You use the DATA_ADDR and MODE parameters to select the Modbus function code.
DATA_ADDR (Modbus start address in the slave): Specifies the start address of the data that is ac‐
cessed in the Modbus slave.
The Modbus_Master instruction uses the MODE input instead of a function code input. The combina‐
tion of MODE and DATA_ADDR specifies the function code that is used in the actual Modbus frame.
The table below shows how the MODE parameter, the Modbus function code and the Modbus ad‐
dress range in DATA_ADDR are related.
Modbus functions
0
40001 to 49999 1 to 125/124 1 03
0 to 9998
40000
1
to 465535 1 to 125/124 1 0 to 65534
-4-
Modbus_Master: Communicate as Modbus master (S7-1200, S7-1500)
- 1 -
Reset slave event counter
1 word per request using data diagnostic code
81 08 0x000A
- 1 -
Words per request Read input words
104 04
0 to 65535 1 to 125/124 1 0 to 65535
3 to
10,
12 to
79,
82 to - - Reserved
103,
105
to
255
1 Inextended addressing, see the Extended_Adressing parameter, the maximum data length is
shorter by 1 byte or 1 word depending on the data type of the function.
2 MODE 2 allows you to write one or more output bits and one or more holding registers using the
Modbus functions 15 and 16.
MODE 1 uses the Modbus functions 5 and 6 to write 1 output bit and 1 holding register, and Modbus
functions 15 and 16 to write multiple output bits and multiple holding registers.
-5-
Modbus_Master: Communicate as Modbus master (S7-1200, S7-1500)
DATA_PTR parameter
The DATA_PTR parameter points to the DB or bit memory address in which reading or writing is per‐
formed. If you use a data block, you must create a global data block that provides the data memory
for read and write processes on Modbus slaves.
Note
S7-1200/1500 - The data block addressed using DATA_PTR must support direct addressing
The data block must permit direct (absolute) and symbolic addressing.
Note
Using function code 5
Function code 5 is used to set or delete individual bits.
When a bit is set, the value "16#FF00" must be specified in the first word of the addressed DB or
bit memory area via DATA_PTR.
• With S7-1200, the value "16#0100" can also be specified to set a bit.
• To reset a bit, the value "16#0000" must be specified in the first word of the DB or bit memory
area addressed via DATA_PTR.
All other values are rejected with ERROR = TRUE and STATUS = 16#8384.
See also
Modbus_Slave: Communicate as Modbus slave
-6-