Hello everyone, good evening! How have you all been recently? Has the pandemic affected you in any way?
Today is still a technical article: Siemens PLC Communication – Modbus RTU Communication – New Features of S7-1200 Modbus (RTU) Instructions V4.
Modbus RTU Communication:
S7-200 smart Modbus RTU master station communication (√)
S7-200 smart Modbus RTU slave station communication (√)
RS485/232 communication ports and DP connector connection methods (√)
S7-1200 Modbus (RTU) instructions V3 basic functionality (√)
S7-1200 Modbus (RTU) instructions V4 new features,
Starting from TIAV15 version, the Modbus (RTU) instruction set has been updated to version V4.0 and above;
Note: The S7-1200 firmware needs to be at least version V4.2;
Taking V16 as an example, as shown in Figure 1-1, the Modbus (RTU) instruction set is version V4.4.
Figure 1-1 Modbus RTU V4 Instruction Set
The V4 version of the Modbus RTU instructions has the following important functional updates.
Modbus_Master Instruction Changes:
1. The DB of the DATA_PTR interface can support “optimized block access”
Modbus_Slave Instruction Changes:
1. The DB of the MB_HOLD_REG interface can support “optimized block access”;
2. You can choose to restrict read access to the input-output process image area;
3. You can customize the data area accessed in the DB, instead of the default IQ area and MB_HOLD_REG.
The DATA_PTR parameter points to the DB or M address to be written to or read from. If using a data block, a global data block must be created to provide a data storage location for reading and writing the Modbus slave.
Since instruction version V4.0:
This parameter can point to an optimized DB data block, in which single elements or arrays of the following data types are allowed: Bool, Byte, Char, Word, Int, DWord, DInt, Real, USInt, UInt, UDInt, SInt, or WChar.
MB_HOLD_REG points to the Modbus RTU holding register, which can be in the M storage area or DB data block.
Example: Using V16 TIA Portal software, configure the 1215 CPU with the CM1241 RS422/485 module as the Modbus RTU master station, and the 1214 CPU with the CM1241 RS422/485 module as the Modbus RTU slave station;
The 1215 CPU writes the Modbus master station program in OB1, creating the optimized DB data block DB3-Master, and fills DATA_PTR with the optimized DB block area:
Figure 1-2 1215 CPU Master Station Modbus Programming
Figure 1-3 Optimized Data Block DB3-Master
The 1214 CPU writes the Modbus slave station program in OB1, creating the optimized DB data block DB8, and fills MB_HOLD_REG with the optimized DB block area:
Figure 1-4 1214 CPU Slave Station Modbus Programming
Figure 1-5 Optimized Data Block DB8
The REQ pin of the master station triggers, and the master station reads the holding register 40001 of the slave station, with a length of 5 words, the reading result is shown in Figure 1-6:
Figure 1-6 Data Read by Master Station
Modbus_Slave V4 Background DB Data Content
As shown in Figure 7:
Figure1-7 Modbus_Slave V4 Background Data Block
The user program can modify the variables circled in red in Figure 7:
Red indicates the variables added to the Modbus RTU V4 instruction set by Modbus_Slave, requiring the version to be TIA PORTAL V15 or above, CPU version V4.2 or above:
QB_Read_Start
QB_Read_Count
IB_Read_Start
IB_Read_Count
Data_Area_Array
Black indicates the variables added to the Modbus_Slave V3 instruction set by Modbus_Slave V3, requiring the version to be TIA PORTAL V14 SP1 or above, CPU version V4.1.1 or above:
QB_Start
QB_Count
Blue indicates the variables of Modbus_Slave V2 in the Modbus_Slave V3 instruction set (i.e., the initial version), requiring the version to be TIA PORTAL V13 SP1 or above, CPU version V4.1.1 or above:
HR_Start_Offset
Extended_Addressing
Today, “Siemens PLC Communication – Modbus RTU Communication – New Features of S7-1200 Modbus (RTU) Instructions V4” is shared by Xiao Zhi. You can bookmark it for use. If you encounter any problems or have any questions, you can add Xiao Zhi to chat privately or leave a comment. If you like it, please follow Xiao Zhi, like and share, thank you!
We are serious about online activities! Learning course packages are available at a discount! Helping everyone learn!
Xiao Zhi Control Education official website:http://plc.czzkplc.com/czplc/home Free materials and courses can be viewed on the website!
The mini program can be purchased!