The virtual HMI is to realize the display and button functions through creating a display window in computer, receiving and analyzing the serial port commands and simulating the HMI.
The virtual HMI provides a mean of software virtual debugging, which can ensure that the method of application and the display effect of some command can be tested through the “serial port debugging tool” and “virtual HMI” in the Intelligent TFT LCD Module 4.3 development tool under the condition without real HMI and user’s mainboard.
Figure 1.1 System Chart of Virtual HMI
After the interface engineering is completed by the Intelligent TFT LCD Module 4.3 development tool, the virtual HMI can be started. The mouse can simulate the function of the touch screen. The virtual HMI can be connected to the user’s mainboard through the serial port, which can realize the software and hardware joint debugging of the user’s mainboard. It can also make communication debugging with the serial port debugging tool in the Intelligent TFT LCD Module 4.3 development tool or with the user Keil software simulator through virtual serial port software (such as VSPD).
1. Touch control: rotation adjustment;
2. Display control: display of basic figures (part) and list;
3. Register: 0x01(brightness control), 0x60-0x6e(video playing), 0xEA(calibration of touch panel);
4. Description of pointer, OS and Modbus.
In Intelligent TFT LCD Module 4.3 development tool, the online communication debugging of serial port debugging tool and virtual HMI is shown in Figure 1.2, is to control the display of “virtual HMI” through sending commands by “serial port debugging tool” to realize the virtual debugging of HMI.
Figure 1.2 Virtual Debugging of HMI
1. Intelligent TFT LCD Module4.3 development tool ( including serial port debugging tool and virtual HMI )
2. Virtual serial port VSPD software
The above two software can be directly downloaded from our company’s website or through contacting with our sales staff. The debugging procedure of virtual HMI is shown in Figure 1.3.
Figure 1.3 Operation Procedures of Virtual HMI
The Intelligent TFT LCD Module4.3 development tool provides the serial port debugging tool, as shown in Figure 1.4. Compared with the serial port debugging assistant that we always use, this serial port debugging tool can automatically produce HMI command, which is more convenient for debugging.
Figure 1.4 Serial Port Debugging Tool
①: used for displaying the commands that are sent in blue color and received in red color, which make us clearly check the sending and receiving communication records of the serial port debugging tool.
②: used for setting up the basic parameters of the serial port, such as the serial port number, Baud rate, CRC verification and frame header, and controlling the operation status of the serial port in opening or closing.
③: command selection area allows six forms of command to be sent, which are write register, read register, write variable memory, read variable memory, write curve buffer zone and self-writing commands. Once the user chooses the corresponding command form, the user must fill out the corresponding data in accordance with the corresponding command form.
④: when the above three steps are filled out, the user can click “send” button in the sending control area to achieve the sending of command, and the user can choose automatic sending with the automatic sending period of 1s.
Except for being used for virtual HMI debugging, the serial port debugging tool also can be used as a serial port debugging assistant to realize the real object debugging by using the serial port to connect with HMI.
The Intelligent TFT LCD Module4.3 development tool provides the function of virtual HMI, as shown in Figure 1.5. The interface engineering currently designed will be read into the display window after opening the virtual HMI.
Figure 1.5 Virtual HMI
①: The serial port setting area is the key to control whether the virtual HMI can make serial port communication with other software or devices. Two parameters of the serial port number and Baud rate are mainly needed to be set and this step is completed by clicking the “Open” button after setting up well.
②: The communication record area is mainly used to display the commands that are received and sent. The received legal commands are displayed in green, and the received illegal commands are displayed in red, and the command automatically sent by the virtual HMI is shown in blue. With the communication record, it is convenient for us to quickly locate the error of the serial port commands.
③: The virtual HMI operation area is to simulate the real HMI. The mouse is equivalent to a touch screen, which can realize touch control and display control so that we can adjust the code in accordance with the display effect.
1.3.1 Installation of Virtual Serial Port Software VSPD
(1) Decompress “virtual serial port VSPD software” and operate “vspd.exe”, as shown in Figure 1.6.
Figure 1.6 VSPD Installation Procedures
(2) Choose the default installation path, click next step until the completion of installation, as shown in Figure 1.7.
Figure 1.7 Completion of Installation
(3) There will be the icon of virtual serial port software in the computer desktop after the completion of installation, as shown in Figure 1.8, then review the document of “Read before use” to guarantee its normal operation.
Figure 1.8 Display of Desktop Icon
The creation and binding of a pair of virtual serial port can achieve the virtual communication between the serial port debugging tool and the virtual HMI.
Figure 1.9 Open VSPXD Software
In the upper left corner of the interface, the physical ports directory indicates the physical hardware serial port of current computer. Note: The physical hardware serial port cannot be connected to the virtual serial port channel.
As shown in Figure 1.10, select COM7 in First port menu and COM8 in Second port, then click Add pair, at this time, a pair of bound serial port will be occurred in Virtual ports directory, as shown in Figure 1.11.
Figure 1.10 Create and Bind Channel
Figure 1.11 Generate a Pair of Virtual Serial Port
It only needs to select the corresponding virtual serial port and then click “Delete pari” to delete the virtual serial port, as shown in Figure 1.12. This step does not need to be operated now.
Figure 1.12 Delete a Pair of Virtual Serial Port
Open the serial port debugging tool software and click “Refresh”, then the channel will add two options of COM7 and COM8, as shown in Figure 1.13, which represents that the virtual serial port has successfully created.
Figure 1.13 View the Virtual Serial Port
(1) Newly build or open an existing Intelligent TFT LCD Module project, and open the serial port debugging tool after the completion of compiling to choose COM7 and set up Baud rate, then click “Open” button, as shown in Figure 1.14.
Figure 1.14 Set up Serial Port Number of Serial Port Debugging Tool
(2) Operate virtual HMI, and select serial port channel COM8 and set up Baud rate, then click “Open” button, as shown in Figure 1.15. Then the COM7 of the serial port debugging tool and the COM8 of the virtual HMI can be matched.
Figure 1.15 Set up Serial Port Number of Virtual HMI
(3) Start Debugging
As shown in Figure 1.16, we send the command of changing to No.1 instrument through serial port debugging tool. Select “Write Command” in the command selection area of serial port debugging tool with setting the initial register to 03 and the write data to 00 01, then click “Send” button.
Figure 1.16 Online Debugging
It can be seen from the figure:
The communication record edit box of the serial port debugging tool will display the blue commands: A5 5A 04 80 03 00 01;
After the virtual HMI receives the commands, the communication record edit box will display the red commands: A5 5A 04 80 03 00 01;
Then a communication is finished.
The example just showed is that the serial port debugging tool sends commands to the virtual HMI, and the following example is that the virtual HMI returns the commands to the serial port debugging tool.
Click the “Increment Adjustment Button” on the virtual HMI, and the communication record edit box of the virtual HMI will display the blue commands:
A5 5A 06 83 01 20 01 00 01;
At the same time, after the serial port debugging tool receives the commands, the communication record edit box will display the red commands:
A5 5A 06 83 01 20 01 00 01;
Then the return of HMI command is completed.
Figure 1.17 Online Debugging
In the actual debugging process, if we don’t have real hardware and the modification of engineering picture in each time need to re-download the picture which wastes time, at this point, we can directly connect the Keli development environment with virtual HMI. When user uses the Keil program to debug the simulation, the virtual HMI display will also change with the operation. Since the virtual HMI is exactly the same as the real HMI function, such a debugging mode definitely bring the convenience for the developer, as shown in Figure 2.1.
Beginners can quickly complete the binding of Keil to the virtual HMI by following the procedures below.
Figure 2.1 Binding Debugging of Keil Development Environment and Virtual HMI
We have generated a pair of virtual serial ports COM7 and COM8 in the previous chapters, then we need to connect the virtual HMI to COM8 and map the Keli software simulator serial port to COM7, then the online connection of COM7 and COM8 is completed after setting up some properties. Of course, if your computer can’t virtual COM7 and COM8, you can virtual COM5 and COM6, as long as it doesn’t conflict with the existing serial port channel. The steps are as follows:
1. Write a debugging initialization file COMDEBUG.ini. The contents are as follows:
MODE COM7 115200,0,8,1
The function of the first command is to set the COM7 property to 115200 baud rate, no odd-even check, 8 data bits, 1 stop bit; the function of the second command is to map the serial port of the software simulator to COM7.
1. Create a new notebook named COMDEBUG.txt in the arbitrary directory of Keil program project, then copy in the above content to notebook, as shown in Figure 2.2.
Figure 2.2 Debugging Initiation File
2. Change the notebook suffix .txt to .ini, the needed COMDEBUG.ini debugging file is generated, as shown in Figure 2.3.
Figure 2.3 Generate ini Debugging File
Note: If the notebook in your computer does not show the expanded-name of the suffix .txt, then you should select the folder options and conceal the selection of “Hide the expanded-name of the known file type”, as shown in Figure 2.4. For the WIN7 system, click on “Organize” in the file bar and select “Folder and Search Options” to pop up the interface, as shown in Figure 2.5.
Figure 2.4 Folder Options
Figure 2.5 File Bar Options
Open Keli software and click configuration options, as shown in Figure 2.6, then select Debug in the popped window to select COMDEBUG.ini as initialization file, as shown in Figure 2.7.
Figure 2.6 Enter Configuration Options
Figure 2.7 Import Initialization Document
Virtual HMI Setting
After opening the virtual HMI, select COM8 as serial port channel and set the Baud rate as 115200 to make the serial port be opened, as shown in Figure 2.8. Note: Baud rate must be 115200 to keep consistence with the program.
Figure 2.8 Virtual HMI Setting
Click Debug debugging to enter the debugging interface, then click Operation in Full Speed, as shown in Figure 2.9. At this point, click the virtual HMI to enter the text interface, it can be seen that the text data is constantly changing. The communication record edit box can monitor all the data sent and received by the mainframe, which is very convenient for program analysis and debugging in later period, as shown in Figure 2.10.
Figure 2.9 Enter Debugging Interface
Figure 2.10 View Program Executive Result
The following links may help you