How do you prevent write access to the outputs of your Modbus slave (S7-1500 / S7-1200)?
In STEP 7 V14 SP1 you can use the following Modbus instructions to define the supporting interfaces of the SIMATIC S7-1500, S7-1200 and ET200SP as Modbus slave or Modbus TCP server:
- Modbus TCP instructions "MB_SERVER" V4.2 for supporting Ethernet interfaces
- Modbus (RTU) instruction "Modbus_Slave" V3.0 and higher for supporting serial interfaces
The Modbus TCP instruction "MB_SERVER" V4.2 is in STEP 7 V14 SP1 in the library "MODBUS TCP" V4.2. The library "MODBUS TCP" can be found under "Instructions > Communication > Other".
The Modbus (RTU) instruction "Modbus_Slave" V3.0 is in STEP 7 V14 SP1 in the library "MODBUS (RTU)" V3.1. The library "MODBUS (RTU)" can be found under "Instructions > Communication > Communications Processor".
For this your project has to be upgraded to at least TIA Portal V14 SP1.
Via the start values of the following static variables you can define the permissible address area for write access to the outputs.
|Variable||Data type||Default value||Description|
|QB_Start||Word||0||Start address of the valid address area of the outputs|
(Byte 0 to 65535)
|QB_Count||Word||0xFFFF||Number of output bytes that can be addressed by the Modbus master or Modbus TCP client|
With "QB_Start" = 0 and "QB_Count" = 10, the output bytes 0 to 9 can be written by the Modbus master or Modbus TCP client.
Select "QB_Count" = 0 to block all output bytes for write access by the Modbus master or Modbus TCP client.
If write access is attempted to blocked address areas of the outputs, the instructions "Modbus_Slave" and "MB_SERVER" issue the error code ("STATUS") 16#8383: "Invalid data address in the request frame".
The instructions "Modbus_Master" and "MB_CLIENT" also issue this error code with use on the other side.
Detailed information about the following instructions is available in the manual "STEP 7 Professional V14 SP1":
- MODBUS (RTU) (S7-1200, S7-1500)
- MODBUS (TCP) for library versions V4.0 and higher of the S7-1200 CPUs and V3.x and higher of the S7-1500 CPUs (S7-1200, S7-1500)
The screens in this FAQ response were created in STEP 7 V14 SP1 (TIA Portal).