Overview
Table of Contents
Background
As described in the An HMI Architecture for LabVIEW Touch Panel Module document, a Human Machine Interface (HMI) provides a graphical user interface (GUI) through which an operator can monitor and control the operation of a machine and its multiple processes or sub-processes. The HMI application is commonly organized into a set of different pages as a way for operators to switch between different views of configuring and monitoring the machinery. A single page represent a specific process or sub-process in the machine or user operation. Each page is implemented as a separate program that contains the user interface (UI) elements needed to control or monitor that specific process.This document is intended for programmers who want to learn more about building UI pages using the LabVIEW Touch Panel Module.
Implementation
The building of a HMI page can be broken up into the four high level sections of building the user interface, block diagram architecture, updating the user interface, and application level integration. For most of these sections, reference libraries and reference designs have been created as tools for decreasing development time and for implementing best practices.Building the User Interface
When implementing a HMI Page, we need to create a new page, customize page appearance, and add all the needed user interface elements.Creating a New Page
The first thing to do when building an HMI page is to simply create a new LabVIEW VI. When using the LabVIEW Touch Panel module, the best way to do this is:- Create a LabVIEW Project and add your touch panel type as a new target
- Right click on the HMI device and select New Touch Panel VI.
Another option for creating a page is to make copies of the HMI_Page VI that is installed with HMI Navigation Engine (HNE) reference library. This VI is meant to be a 12" landscape touch panel page template and has the block diagram architecture and application level integration already added (both discussed below). The developer than just needs to customize the page VI to meet their specific needs. This HMI_Page VI is on the User Libraries»HNE»Templates palette.
Whatever method you chose, make sure all the pages created have a consistent look and feel. Things like window size, front panel color, etc. should be the consistent.
Customizing Page Appearance
Each page must be setup to display its
front panel to the operator when executed and close its front panel
after it finishes execution. VIs have two properties that provide this
functionality named Show front panel when called and Close afterwards if originally closed
respectively. Make sure these properties are selected for each page.
For more information on setting these properties, please refer to the How Can I Control Whether or Not The Front Panel of a SubVI Pops Up When Called in LabVIEW? document.
Window Appearance and Window Run-Time
Position are two VI Properties that should also be considered when
displaying your VI's front panel. In general, the Window Run-Time
Position should be Centered. The settings for Window Appearance
depend on your program's requirements. As stated above, make sure each
page adheres to the same standard. For more information on the Window
Appearance and Window Run-Time Position VI Properties, please refer to
the LabVIEW Help.
Adding User Interface Elements
Next, select the user interface elements that will be used by the operator to interact with the functions controlled by the page. The most common elements include:- Navigation Buttons
- Control Buttons
- Alarm Displays
- Images
- Constant Free Text Labels
- Text Indicators
- Data Entry Objects (i.e. keypads)
Figure 1 shows a example page containing a typical set of UI elements.
Figure 1. HMI Page- LabVIEW VI’s Front Panel
Note that just like with page creation, a
good UI design follows a stand convention to which all pages adhere. In
this example, red boolean buttons represent commands that when pressed,
cause a control parameter or state change in the machine controller.
The blue buttons are navigation buttons that cause the HMI to navigate
to a different page.
Block Diagram Architecture
Each HMI page needs to react quickly to any user actions or inputs. The responsiveness of the HMI depends on the operation of the block diagram so using the correct architecture is important. The Asynchronous Message Communication (AMC) reference library provides a template for handling UI events that is ideal for the block diagram architecture of a HMI page. The AMC template is an event-based producer consumer design pattern. When an event occurs in the producer loop due to user interaction, an message is queued to the consumer loop, which is programmed to handle that message. Figure 2 shows an example block diagram using the AMC architecture.If the HMI_Page VI was copied to create a new page, this AMC architecture will already be in place. If not, navigate to the User Libraries»AMC»Templates palette and select the AMC QMH Windows CE Template VI. Place this code on the page's block diagram and remove any old structures that this will be replacing. Once this is done, the building of the page's functionality can start. The programmer first links UI objects to the event structure so that when an operator makes changes on the front panel, the event structure captures those changes. Next, the programmer uses a queue to send a message from the event structure to the consumer loop. The programmer then creates or modifies cases in the consumer loop to handle the queued message.
Figure 2 can be used as a simple example. The code has been programmed such that when the operator selects Process 1, a random number is generated and queued to the consumer loop as message name Process Data 1. The consumer loop has a case defined for the message Process Data 1 that simply reads, converts and displays the data sent.
Please refer to Asynchronous Message Communication (AMC) Reference Library for more information on the AMC. Please refer to Application Design Patterns: Producer/Consumer for more information on producer consumer loops. Please refer to Event Structures (Basics) and its Additional Notes for more information on events.
Updating the User Interface
Previously, the Touch Panel HMI Page Development (TPD) reference library was used to update the user interface. This library has been deprecated and replaced with the better practices discussed below.Updating Controls and Indicators
In machine control systems, the HMI application is meant to configure and monitor the machinery. To do this, the HMI must have the latest data from the machine controller. The Current Value Table (CVT) reference library is used to create a central data location locally on the HMI. This same reference library is used to create another central data location locally on the machine controller that is both separate and different from the HMI's data location. The CVT Client Communication (CCC) reference library is used to share the latest data values between these two data locations via an ethernet connection such that the HMI has the latest data from the machine controller and visa versa. Because the latest machine data is now in the HMI's central data location, the API installed by the CVT reference library can be used to access this data anywhere on the HMI. As each data value is associated with a tag name, accessing the data is as simple as wiring the desired tag name to the correct CVT API VI. To update the front panel with this information, just wire the output of the CVT API VI to an indicator. Also remember that data flow still applies. If you would like this indicator to frequently update with the latest data values, place this code snippet into a while loop. The consumer loop of the AMC architecture (discussed above) has an Idle state which executes if no events have occurred within a specified time. Figure 3 shows an example of how to use this state to update your indicators within recommended AMC architecture.The same is true in reverse. If a CVT tag on the HMI is setup to transfer its data through the CCC to the machine controller, all we need to do is write the front panel control to that CVT tag. Figure 4 below shows an example of how to do this within the recommended AMC architecture.
Figure 4. Example Page Updating CVT Tags with Controls
Please refer to the document Current Value Table (CVT) Reference Library for more information on the CVT. Please refer to the document CVT Client Communication (CCC) Reference Library for more information on the CCC.
Displaying Alarms
HMI applications commonly require a mechanism for monitoring, logging and displaying active and historical alarms and the Touch Panel Alarm Engine (TAE) reference library was created for this purpose. While the monitoring and logging pieces of the TAE should reside in a different section of your program, the displaying of alarms should occur in the HMI pages. The TAE installs a palette to User Libraries»TAE named Display Alarms. This palette has an API for accessing, formatting and displaying the 40 latest active and historical alarms. Each of these VIs accepts a reference to a string control and updates that string control with the latest active and historical alarms whenever it is called. Typically, this code resides in the Idle case of the consumer loop in the AMC architecture. Please refer to the document Touch Panel Alarm Engine (TAE) Reference Library for more information on the TAE.Page Localization
Localization of the HMI application is often required for machine control systems that are to be distributed on a global scale or to a multilingual environment. One option to meet this requirement is to have a different HMI with a localized OS for each language (i.e. Windows XP Embedded German Edition) but this can be very cumbersome to maintain. A better option is to build localization into your HMI application. The Localization Configuration Editor (LCE) and reference library were created for this purpose. The Localization Configuration Editor is used to create a configuration file that contains all the language values for the different User Interface elements to be localized. The LCE reference library is then used to load this file into the HMI application and to update the User Interface elements with the appropriate localized language values. The block diagram below shows an example of how to integrate localization into a HMI page with the AMC architecture.
Figure 5. Example Page Using the Localization API
Please refer to the document Reference Example for Localization Configuration Editor for LabVIEW for more information on the LCE.
Application Level Integration
While pages help simplify the organization and creation of individual process-specific programs, it does create an additional concern which is how to integrate these pages into our application such that they are well organized and easy to navigate. The HMI Navigation Engine (HNE) reference library provides a design pattern and API to handle this problem.
The HNE navigation loop is implemented as a
case structure enclosed in a while loop. Each case of the case
structure contains a page VI. The case selector is wired to the HNE
Page Manager (Next) VI, which is used to provide the name of the next
page to display. When this loop executes, it loads a page, waits until
that page finishes execution, iterates, loads the next page and again
waits for that new page to finish executing. The HNE component installs
a VI named HMI_NavigationEngine to the User Libraries»HNE»Templates
palette that contains this basic structure. This VI can be copied and
renamed for use in your application. To modify this VI, create new
cases with each case being named for a specific page. Then, add each
HMI page to its relating case.
The next step is use the HNE API in the
pages to inform the navigation loop which page it is to loaded next. To
do this, first add buttons to the page's UI that will be used by the
operator to navigate to other pages. When any of these buttons are
pressed, the page should be programmed to execute the HNE Page Manager
(Set). The name of the page relating to the button pressed should be
wired to the Next Page input. This will inform the navigation
loop which page to open next. Last, the page should be programmed to
exit. Figure 6 shows an example of how to do this using the
AMC architecture.
Figure 6. Example Page Using the HNE API
The HNE also includes a VI named HNE Page
Manager (Back) VI that can be used to navigate back through the page
history. This VI is added to each page in the same way as described
above.
By using the navigation loop and HNE API,
we have both integrated pages into our application in a simple and
organized way and architected a way to easily navigate between pages.
Please refer to the document HMI Navigation Engine (HNE) Reference Library for more information on the HNE.
References
KnowledgeBase 3E08SANQ: How Can I Control Whether or Not The Front Panel of a SubVI Pops Up When Called in LabVIEW?
Developer Zone Tutorial: Application Design Patterns: Producer/Consumer
Developer Zone Community: Event Structures (Basics)
Developer Zone Tutorial: Application Design Patterns: Producer/Consumer
Developer Zone Community: Event Structures (Basics)
Where to Go From Here
The following is a map of other documents that describe
the machine control reference architecture. You can click on the image
to navigate directly to each document.
[Your
user agent does not support frames or is currently configured not to
display frames. However, you may visit <a
href="ftp://ftp.ni.com/pub/devzone/tut/mca_navigation1.html">the
related document.</a>]
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/ ).
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/ ).