Let's embark on a new chapter in M-series controller programming education, starting with the fundamental course – Modbus RTU communication between Weintek touchscreens and M-controllers!
01. Preliminary Preparations
Software: Sysctrl Studio (PLC programming software)
Utility Manager (HMI programming software)
Hardware: M-series controller (taking M511S as an example)
Touchscreen (taking TK8071iP as an example)
02. Sysctrl Studio Project Configuration
Step 1: Create a new project. Double-click to open the software Sysctrl Studio and create a new project. Click on "Hardware Settings" and make the following settings in the serial port interface. The station number is 1 by default, the baud rate is 9600bps, the protocol is (8,E,1)RTU, and the master/slave mode is set to slave (the touchscreen acts as the master).
Step 2: Create new variables
Open the default POU, right-click in the variable declaration area and select "Add Variable" to create a new variable and assign it to the corresponding address. When assigning the address, pay attention to the allocation device range.
Step 3: After successful compilation, download the project to the controller.
03. Utility Manager Project Configuration
Step 1: New Construction Project
(1) Open the Utility Manager software, select 【Select Model】 in the upper left corner, select the model series corresponding to the touch screen, and click 【EasyBuilder Pro】.
(2) Click on "Open New File" and select the corresponding model "TK8071iP".
Step 2: Basic Configuration
(1) In the pop-up window, select 【Add Device/Server…】
(2) Select 【MODBUS RTU (Zero-based Addressing)】 for 【Device Type】
(3) At point 1, select the interface type corresponding to the COM port. At point 2, the baud rate, data bits, and stop bits must be consistent with the settings in the Sysctrl project.
In the project, the Modbus addresses of variables and touch screen components must correspond one-to-one for communication to be successful.
There are two ways to map addresses: one is the HMI symbol table (Part 4), and the other is standard Modbus address calculation (Part 5).
You can choose any method to map addresses.
04. HMI Symbol Table
Step 1: Generate the HMI symbol table (Sysctrl Studio project)
(1) Click on the menu bar above: [Tools] >> [HMI Symbols]
(2) The HMI symbol interface appears at the bottom. Click on "Add Project Symbol...", select the variable to be added in the pop-up window, and click "OK".
(3) Click on [Check Engineering Symbols] and the variables will be automatically assigned Modbus addresses.
(4) Click 【Generate HMI Symbol Table…】. In the 【Generate HMI Symbol Table】 interface, select Weintek for 【HMI Vendor】, select Serial Port for 【Communication Method】, and select Modbus_Serial for 【Connection Path】. Click 【Generate…】 and save the CSV file to your computer, which will be used in the subsequent touchscreen project.
After configuration, download the project to the controller.
Step 2: Import the HMI symbol table (Utility Manager project)
(1) The name needs to be consistent with the name of 【Generate HMI Symbol Table】-【Connection Path】.
(2) Click on [Project File] >> [Address] >> [User-defined Tags]
(3) Import CSV file
(4) A pop-up window indicates that the import was successful.
Step 3: Create a new component
(1) Create a new indicator light element and bind it to the bool variable data_I0.
(2) Create a new bit state switching switch element and bind it to the bool variable data_M0.
(3) Similarly, create other components and bind the corresponding variables. Text is added here for easy distinction.
Step 4: Download the project
(1) Click on [Project File] >> [Compile] >> [Start Compilation].
(2) Click on [Download (PC->HMI)], enter the touch screen IP address - 192.168.1.111 in the IP field, and click on [Download].
(3) The window displays "All Completed", indicating that the download was successful.
05. Standard Modbus Address Calculation
Address Calculation Relationship Explanation
The table below applies to the Modbus address correspondence for M-series controllers and Weintek touchscreens.
The address conversion method is as follows:
Step 1: Create a new component
(1) Create a new indicator light element and bind it to the boolean variable data_I0. Click on the "Bit Status Indicator" in the top menu bar, select 1x for the corresponding address, and enter 24576.
(2) Create a new bit state toggle switch element and bind it to the boolean variable data_M0. Click on the menu bar above, select 4x_Bit for the corresponding address, and enter 0.
(3) Create a new indicator light element and bind it to the boolean variable data_Q0. Click on the "Bit Status Indicator" in the top menu bar, select 0x for the corresponding address, and enter 40960.
(4) Create a new numerical element and bind the int variable data_int. Click on the [Number] menu in the top bar, select 4x for the corresponding address, and enter 100.
The data type of data_int is int, and the [Data Format] should be 16-bit Signed. In the [Display Format] section, enter 5 for [Decimal places or more], which indicates the number of digits that the component can display on the touchscreen.
(5) Similarly, create other components and bind the corresponding variables. Text is added here for easy distinction.
Step 2: After the components are created, download the project to the touchscreen.
06. Communication Testing
Step 1: Device Connection
This tutorial uses the M controller HCM511S-32MT4-D and the touch screen TK8071iP. The Modbus RTU communication connection method is shown in the figure below.
The pin definitions for the DB9 male connector of the touchscreen COM interface are shown in the table below.
Step 2: Engineering Testing
The Sysctrl project enters monitoring mode, and values are assigned to variables.
At the same time, the touchscreen displays the corresponding values.
✦Control Technology Product Line✦