1. Introduction
Modbus communication is a widely used communication protocol, commonly applied in variable frequency drives, smart instruments, and other intelligent devices. This article uses the S7-200SMART series PLC as the Modbus master and the Siemens V20 variable frequency drive and Omron E5EZ intelligent temperature controller as slaves to share how to use a custom Modbus RTU communication function block to achieve fast and efficient Modbus communication program design. At the end of this article, reference programs and packaged Modbus RTU communication function block library instructions will be provided, which can be added to your software library for convenient future use.
2. Introduction to Custom Modbus Communication Function Block Instructions
The following figure shows a custom Modbus communication function block instruction. When performing Modbus communication, regardless of the number of slaves, only one instruction is needed, which can be used in conjunction with a data block to define the communication data.
3. Design of the Communication Program
(1) Hardware Requirements and Wiring
(2) Control Requirements Description
Implement control of the Siemens V20 variable frequency drive, including speed adjustment, operational status feedback, running speed feedback, output current, and output voltage monitoring. Monitor the current temperature value (PV) of the Omron E5EZ and adjust the set value (SV). The corresponding Modbus register addresses for communication are shown in the figure below.
Note: Communication parameters can be set according to the Siemens V20 and Omron E5EZ manuals. For the V20, communication parameters can be quickly set by configuring the link macro Cn11. It is important to ensure that the variable frequency drive and intelligent instrument have the same data bits, stop bits, start bits, parity bits, and baud rate.
(3) Define Communication Data on the Data Page
On the data page, define the communication data and the addresses for reading and writing data in units of 10 bytes, as shown in the figure:
(4) Communication Program
Call the custom Modbus communication function block instruction to complete the design of the communication program, as shown in the figure below:
The called library instruction needs to be assigned a library storage address. This custom Modbus communication block occupies 594 bytes of address space, as shown in the figure below. Ensure that the assigned library storage address is not used elsewhere in the program.
The V20 control program is primarily used to complete the control command assignment and speed conversion program for the V20 variable frequency drive, as shown in the figure below:
4. Conclusion
By using this custom Modbus communication function block instruction, there is no need to consider the use of Modbus communication library instructions and the design method of communication polling; you only need to define the required communication data area. For more information about this custom Modbus communication instruction library and the examples in this article.
You can scan the QR code below to download more communication case studies
In the next article, we will share the method for building custom Modbus function blocks.