Share this

Communication between embedded intelligent human-machine interface and PLC

2026-04-06 06:59:26 · · #1

1. Introduction

In recent years, the term "embedded" has been mentioned more and more, and embedded products have been applied to various industries. Technologies related to embedded systems, such as embedded products and embedded systems research, have also been listed as key development directions during the "15th Five-Year Plan" period.

An embedded system is defined as an application-centric, computer technology-based, customizable software and hardware system designed to meet stringent requirements for functionality, reliability, cost, size, and power consumption.

With the development of industrial automation, automation systems based on PLCs, microcontrollers, and other devices are becoming increasingly widespread, covering almost all automation fields. Correspondingly, human-machine interface (HMI) systems have emerged and developed in tandem. Embedded industrial HMIs are a shining star in the HMI system market. Their high reliability, long lifespan, small size, high performance, multi-threading, multi-tasking, and strong real-time capabilities make embedded industrial HMIs increasingly favored by automation system integrators and automation equipment manufacturers. They can ideally and vividly display data from PLCs, microcontrollers, and other industrial equipment, offering powerful functions and ease of use. As an upper-level device for PLCs and other control equipment, they bridge the gap between users and machines. This product is currently widely used in industrial automation systems, medical, financial, and other industries' automation equipment.

As more and more engineering projects adopt embedded human-machine interfaces, the demand for application software such as Supervisory Control and Data Acquisition (SCADA) systems used with embedded hardware is also increasing. This is precisely the issue this article will discuss. The embedded monitoring system discussed here uses an embedded intelligent human-machine interface as hardware and an embedded operating system, plus a custom-developed application program, as its software. The following sections of this article mainly introduce this monitoring application program, focusing on the implementation principles of the communication part within the application.

Today, various embedded operating systems have been developed, such as Linux, VxWorks, and WinCE.net, on which user-friendly, graphically-rich applications can be developed to meet the diverse requirements of monitoring systems. However, because embedded technology is a relatively new and advanced technology, there are still relatively few people involved, so such applications are currently limited. The embedded monitoring system introduced in this article serves as an example.

2. System Composition

The embedded monitoring system we developed uses an embedded intelligent industrial control human-machine interface (HMI) developed by Shenyang Ludao Information Technology Co., Ltd. as its host computer. Its embedded industrial controller is based on a GeodeX86 core processor and includes a hardware platform for network communication, data communication, a large-size touchscreen, and an LCD display, running the WinCE operating system. It provides 20 general-purpose I/O points for user use, supports fieldbuses such as ProfiBus at the physical layer, supports 16-bit true-color TFTLCD display, has 64MB of MSDRAM memory, 64MB of FLASH memory, and features a USB interface, a 10/100M Ethernet network communication interface, as well as general-purpose interfaces such as serial ports, parallel ports, and VGA ports.

The lower-level PLC can be a popular type of PLC, such as OMRON PLC, SIMEN SPLC, Schneider NEZ APLC, or Mitsubishi PLC. Of course, temperature controllers, microcontrollers, intelligent modules, and other industrial field control equipment can also be used.

The operation of the controlled object (such as a boiler) is controlled by the aforementioned control equipment (various PLCs, etc.); while the status of the controlled object is monitored by a human-machine interface and the application developed on it.

The human-machine interface uses Microsoft's WinCE.net operating system. WinCE.net is a compact, efficient, and scalable operating system (OS) designed for various embedded systems and products. Its multi-threaded, multi-tasking, and fully preemptive features are specifically designed for resource-constrained environments. OEM developers can select and tailor WinCE.net according to the characteristics of their hardware, thereby configuring a stable, efficient, and proprietary WinCE.net operating system and corresponding SDK development package. In terms of application, WinCE.net supports over 1000 public Microsoft Win32 APIs and several additional programming interfaces, which users can use to develop applications. In addition, Microsoft provides the Microsoft eMbedded Visual C++ language, similar to Visual C++ and supporting MFC, for those developing WinCE.net applications. Below, we will introduce the details of the development process.

3. Software Process

Application development was conducted on a personal computer. The personal computer's operating system was Windows 2000. The application development platform was the Microsoft Embedded Visual C++ integrated development environment.

During application development, the Microsoft Emulator can also be used. It allows for program debugging even without a human-computer interface.

The final executable file can be downloaded to the human-machine interface via serial port or local area network using the download function provided by the Microsoft eMbedded Visual C++ development environment.

During operation, industrial control equipment such as PLCs run their control programs, while the HMI runs the downloaded executable file. The two communicate via a serial port, but the HMI initiates the communication. Based on monitoring requirements, the HMI sends communication commands to the PLC, and the PLC responds accordingly.

After receiving response data from the PLC, the human-machine interface displays it on the touchscreen in the form of charts, animations, and text for the user to observe. This data can also be stored, printed, and even transmitted to management information systems such as ERP.

If intervention is required on the PLC or the controlled object, commands or data can be sent to the PLC via touch keys or a touch mouse on the human-machine interface touch screen to achieve the corresponding control.

The execution flow diagram of this application is as follows:

Figure 1 Execution Flowchart

4. Composition of the image

Typical engineering monitoring screens include: text displays, production process flow displays (including animations, bar charts, etc.), alarms, personnel operations, trend curves, etc. Our system architecture is based on a main dialog box program, which then presents these different screens using sub-dialog boxes.

The main dialog box is responsible for initializing the serial port, opening the serial port, and starting the serial port read thread. The sub-dialog boxes periodically or as needed send various commands to the serial port, read the command responses back through the main dialog box's thread, and then provide them to the user in a specific format within the sub-dialog boxes for monitoring on-site operations. The key technology involved is serial communication. We will focus on the implementation of this communication mechanism below.

5. Communication Implementation

The serial port provided by the human-machine interface conforms to a common standard. Serial communication under WinCE.net works on the same principle as serial communication under Windows. Both are application programs.

Instead of directly controlling the hardware, it uses device drivers provided by the operating system to transfer data.

WinCE.net is a Win32 programming language. In Win32, serial ports are treated as files, not directly manipulated. Win32 provides corresponding file I/O functions and communication functions for serial communication.

However, it's important to note that WinCE.net only supports a subset of the Windows API functions. Functions available in Windows may not be usable in WinCE.net. Also, WinCE.net's character set is similar to Windows NT but different from Windows 9x; it's based on Unicode. This is one of the most common problems encountered by programmers transitioning from Windows to WinCE.net. Furthermore, some commonly used communication controls in Windows, such as MSComm, cannot be used correctly in WinCE.net.

This monitoring system uses API functions to implement serial communication. The following sections will introduce the serial communication and the implementation of the entire system in several parts.

5.1 Open the serial port

The first step is to open the serial port, which is the first step in serial communication. The code is as follows:

BOOLCMainDlg::OnInitDialog()

{

......

m_hComm = CreateFile(_T(“COM1:”), GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0); // Operation to open the serial port, note the following.

There are subtle differences in how WinCE.net and Windows systems express themselves; WinCE.net requires a colon to be added after the serial port number.

SetupComm(m_hComm, 1024, 1024); // Initialize the serial port's input and output buffer parameters;

SetCommState(m_hComm, &m_dcb); // Configure serial port parameters; m_dcb is the set parameter structure;

......

SetCommTimeouts(m_hComm, &timeout); // Set the communication timeout parameter;

PurgeComm(m_hComm,PURGE_TXCLEAR|PURGE_RXCLEAR);

// Clear the characters in the input and output buffers to prepare for receiving data and entering the monitoring state;

5.2 Serial Port Read Thread

The second step is to start a serial port reading thread, which allows the serial port reading program to run continuously in the background without affecting the work of the foreground program. The relevant code is as follows:

BOOLCMainDlg::OnInitDialog()

{

......

ReadFile(m_hComm, inBuffer+iBufLen, INBUFFERLEN-iBufLen, &dwBytes, NULL); // Read data from the serial port;

iBufLen += dwBytes;

for(int i=”0“;i{

if(inBuffer[i]==”\r”)//Taking the connected device as an example, its communication protocol stipulates that the response should end with “\r”;

inBuffer[i] = 0; // String termination marker;

switch(m_iDlgType) // m_iDlgType is a flag variable representing different dialog boxes;

{

Case dialog box 1 identifier:

Dialog box 1.ProcData(inBuffer, i); // Handling of command responses in different dialog boxes, ProcData is the name of the processing function;

break;

......

}

......

}

5.3 Send write commands to each sub-dialog box

Each sub-dialog box sends commands to the PLC periodically using a timer, as needed. Taking OMRON PLC as an example, when sending commands, a checksum needs to be added to the command string according to the OMRON PLC communication protocol. The program code is as follows:

void child dialog box class 1: OnTimer(UINTnIDEvent)

{

......

strcpy(m_szC

md, "@00RR00000001"; // Command string for OMRON PLC;

GenXor(m_szCmd, result); // Perform checksum calculation by calling the GenXor function;

sprintf(szTailer,"%02X*\r", result); //OMRONPLC communication protocol ends with "*\r";

strcat(m_szCmd, szTailer); // Forms a complete communication protocol command string;

WriteFile(m_hComm, m_szCmd, strlen(m_szCmd), &dwWriten, NULL);

// Write the command string to the serial port;

......

}

The following is the code used above to calculate the checksum:

void GenXor(LPCSTRstrSource, char&result) // This is a function to calculate the checksum, performing an XOR operation:

{

result = 0; // Assign an initial value to the checksum;

intlen = "strlen"(strSource); // Length of the command protocol string;

for(int i="0"; iresult^=strSource[i]; // Perform bitwise XOR;

}

5.4 Display Interface Processing

Finally, the data read by the read thread is processed by the corresponding sub-dialog box. This data is then analyzed and presented using animations, bar charts, trend curves, etc. Taking an OMRON PLC as an example, the code is as follows:

void child dialog class 1::ProcData(char*buffer, intlen)

{

...sscanf(buffer+7, "%04X", &wData); // Retrieves the required data from the response into the variable wData according to the OMRON PLC command specification;

......//The obtained variable values ​​are processed as needed, such as displaying them in a sub-dialog box in the form of text or animation;

}

There are some techniques for UI design. For example, when displaying animations, a timer can be used to control the rotation of images. (In this system, animations are displayed using the CbitmapButton control.)

switch(m_iImage) // m_iImage is a defined animation display flag;

{

case1: // Display the first image and set the animation display flag to 2;

CBitmapButton control variable.LoadBitmaps(image_flag1);

m_iImage=2;

break;

case2: // Display the second image and set the animation display flag to 1;

CBitmapButton control variable.LoadBitmaps(image_marker2);

m_iImage=1;

break;

}

When displaying real-time curves, a circular array is used. A certain amount of space is allocated in memory so that the read data forms a circular array, which is then dynamically displayed on the interface.

In this system, each array contains 20 analog values, meaning the real-time trend curve continuously displays information from 20 points. However, because a circular array technique is used, it appears very dynamic.

void sub-dialog class:: loop array function (int iValue) // iValue is the valid data parsed from the command response;

{

intindex=(m_iBegin+m_iCount)%20; //Calculate the index of the loop array, starting from 0;

m_aryValue = iValue; // Assign a value to the circular array;

m_iCount++; //Increment the count of the loop array by 1;

if(m_iCount>20) // Check if the count exceeds 20. If so, start the next array index from 1, and so on.

{

m_iCount=20;

m_iBegin=(m_iBegin+1)%20;

}

......

}

Communication is crucial to this system. Our experience has shown that the above four steps are the fundamental elements for implementing the entire monitoring system.

6. Conclusion

In summary, the basic architecture of this monitoring system software can be intuitively represented by the following diagram:

Figure 2 Basic architecture of the monitoring system software

With the rise of embedded operating systems, various configuration software developers have also developed embedded versions of their configuration software. However...

In practical applications, we have found that many enterprises have relatively fixed production control processes and require a large number of HMIs. For them, the method described here, which develops a system tailored to their specific production process characteristics, provides a final operating system without requiring secondary configuration development by the user. Such a system is suitable for these users in terms of time, price, and performance. This system has been tested and run on the LEODO embedded industrial control HMI developed by Luda Company, proving its fast and stable operation. It performs very well and is well-suited for industrial applications. Of course, the LEODO HMI also includes a simple, practical, and resource-rich ET configuration software, allowing users to choose between developing their own system using a high-level language or the configuration software, depending on their specific needs.

In summary, it's clear that developing human-computer interfaces using Microsoft embedded C++ shares many similarities with developing programs using Microsoft Visual C++ under Windows. With the help of this software and hardware platform, most users can develop applications tailored to their specific needs.

Read next

CATDOLL 66cm Baby Boy Silicone Doll – Lifelike Newborn Style

Height: 66cm Male Silicone Weight: 8.8kg Shoulder Width: 21cm Bust/Waist/Hip: 44/44/47cm Oral Depth: N/A Vaginal Depth:...

Articles 2026-02-22