In this tutorial, you will learn how to communicate a STRING type variable via the Modbus TCP/IP protocol, using the P2 Series HMI as master and the XP340 PLC as slave. If you have not yet configured the Modbus network, please refer to this tutorial: P2 HMI - Modbus TCP/IP with Nexto
Components
Software: FvDesigner; Mastertool IEC XE; Mastertool X.
PLC: XP3xx; NX30xx; XF3xx.
HMI: P2 Series.
Tutorial Sections
1. ARCHITECTURE
2. DEVELOPMENT
2.1 PLC Configuration
2.1.1 Creating variable in Mastertool
2.1.2 Adding the variable to Modbus
2.2 HMI Configuration
2.2.1 Creating variable in FvDesigner
2.2.2 Adding Text Input Display object
2.2.3 Configuring the Text Input Display object
3 ASCII TABLE
4 RESULT
4.1 PLC
4.2 HMI
1. ARCHITECTURE
In this tutorial, the Ethernet port of the XP340 PLC was connected to the Ethernet port of the P2 HMI using the NX9202 cable. Both devices must be on the same IP range or have routing configured to allow communication between them.
2. DEVELOPMENT
In this example, an application will be developed for exchanging STRING type data via Modbus TCP/IP, with the P2 HMI acting as master and the XP340 PLC as slave.
2.1 PLC Configuration
2.1.1 Creating the variable in Mastertool
A variable of type ARRAY OF INT will be created. Each position of the array has 16 bits, which is equivalent to two ASCII characters, since each character occupies 8 bits (1 byte).
In Xpress line PLCs, such as the XP340 used in this tutorial, the memory organization is little endian. This means the least significant byte is stored first, requiring attention when assembling and interpreting the string characters.
2.1.2 Adding the variable to Modbus
After creating the variable in the PLC, it must be mapped in the Modbus table so that the HMI can perform reading and writing of the corresponding registers.
2.2 HMI Configuration
2.2.1 Creating variable in FvDesigner
In FVDesigner, create a variable of type Unicode String.
The variable address must be configured according to the Modbus mapping defined in the XP340 PLC.
2.2.2 Adding Text Input Display object
Insert the Text Input Display object on the screen, which will be used to display and edit the string content.
2.2.3 Configuring the Text Input Display object
Associate the object with the variable created in the Tag Library.
In the Text Type field, select the option ASCII String, so that the HMI correctly interprets the characters received via Modbus.
3 ASCII TABLE
To write words in integer variables, it is necessary to convert each character to its corresponding value in the ASCII table.
As mentioned previously, Xpress line PLCs use little endian architecture, meaning the least significant byte is stored first. Therefore, when writing two characters in a register, the byte order must be observed to ensure the string is displayed correctly.
4 RESULT
4.1 PLC
4.2 HMI
Comments
0 comments
Please sign in to leave a comment.