Build an HMI

Building an HMI

Introduction

    Need to build an HMI quickly? Don't have much time to spend on development and testing? Don't have much programming experience?

    If you have answered "Yes" to any of the above questions that you are in the right place.

    This tutorial is going to give you a basis on you can start to build your HMI using the Instrumentation ActiveX controls. In fact, this paper can also be extended to the .NET controls also as they are essentially the same as the ActiveX -it's just the underlying technology that differs.

    This tutorial is not an in-depth article on writing an HMI. This article is intended to introduce the concept of writing a basic HMI application without writing any lines of code.

The HMI we will create

    We are going to create a simple HMI that has just a single screen.

    Our HMI is going to interact with an OPC Server which will enable our HMI to show real-time data-values from a shop-floor PLC/Device, while at the same time giving us the flexibility to write values to those PLC's/Devices too.

      There are MANY ways in which you can get your HMI application to interact with PLC's/Devices:

      • If you have existing ActiveX components such as the InGear ActiveX controls then you could accomplish the same result, but with some additional coding.
      • If you have any legacy DDE servers, then you could utilize those interfaces and use some basic scripting to bring live data into your HMI.

      OPC is by far the easiest and quickest way to add real-time interactivity to your PLCs/Devices.

Requirements for this exercise

    You will need:

    • an OPC Server (this tutorial assumes the use of our TOPServer which you can download)
      http://www.toolboxopc.com/
       
    • Visual Basic 6.0 is assumed, but any other development language is ok
       
    • To NOT write ANY lines of code

Choosing HOW to communicate with your OPC Server

    There are many ways in which you can incorporate OPC connectivity to these Instruments within your HMI:

Getting Started

    Our HMI screen will have some boxes that will give us some read-outs of the various Tags within an OPC Server.

Step 1 - Including the Instrumentation controls within your project

    Please refer to steps #1 and #2 in the the Basic Tutorial for instructions on how to do this.

Step 2 - Adding some controls onto the Form

    Please refer to step #3 in the the Basic Tutorial for instructions on how to do this.

    In our example, we are going to add some output boxes to display the values of some tags.

    So, double-click on the iSevenSegmentIntegerX control on the Visual Basic toolbar, and it should appear on the Windows form. Simply resize the control to your specifications.

    Add another 3 or 4 of these controls to the form.

Step 3 - Binding the controls to a Tag in an OPC Server

    As previously stated, you have a choice on how to accomplish this particular step, both equate to the same end-result though.
    You can choose to use either:

    • native built-in interface of the instrumentation controls
    • the OPC Data Control ActiveX

    Let's take a look at both ways.

    Native OPC Interface

      Right-click on an instrument control, and then open its properties:

      In this screen, we need to define:

      • the instrument property which we will bind our Tag to
      • the tag in the OPC Server

      The first thing to do is to select our property, so click on the "Add" button and you will see a list as follows:
      Select the "Value" property. This is the property that is used to display a value within the control.

      FYI: The Value property is the property you will use in MOST of the Instrumentation controls.

      Once you have picked the property, simply click the OK button and you will be returned to the main OPC dialog again.

      Now we need to pick the Tag and OPC Server to bind to this property.

      Clicking on the "..." buttons within this dialog will open the browser dialogs specific to the button's field. So be sure to select:

      • The PC where the OPC Server resides
      • The OPC Server you wish to use
      • The Tag to use

      The following dialog shows the Tag browser:
      Simply highlight the Tag and then click the OK button.

      You have now bound a Tag to this control. This means that the OPC Server will automatically update this instrument.

      Now do the same for the other controls on the form.

    OPC Data Control ActiveX

      The OPC Data Control ActiveX is largely similar to configure as the native OPC interface.

      The following tutorial on the OPC Data Control ActiveX's website shows how to bind a Tag to a controls property.

      http://www.opcdatacontrol.com/Support/Samples_SimpleRead/sampl es_simpleread.html

      Simply follow this tutorial, except bind the Tag(s) to the "Value" property/properties for an instrument / instruments.

Testing your HMI

    Now that you've built a basic HMI screen, simply put the HMI into a runtime mode - in VB6 you just "Run" the program or press F5.

    The ActiveX's will automatically update the value(s) for the controls with the up to date value as served by the OPC Server.

    Any connectivity errors will be handled by the ActiveX's.

Adding write-back support

    Depending on the control you are using, no work is required!

    By following the steps previously outlined to bind a Tag to a control is all that is required.

    Some controls are intended to be out "output only" controls, meaning that they simply show the value of a Tag only, but other controls are intended for input and output.

Summary

    In this basic tutorial, you have seen how to quickly and easily create a basic HMI screen that interacts with an OPC Server in real-time. This HMI was created without writing any lines of code.

Expanding your HMI's abilities, some ideas

    You HMI can be expanded in many ways. Here is a list of ideas that you can consider for use within your HMI:

    • Create more/multiple screens for your HMI
    • Add special "write" buttons to your HMI screens to add rules and limit the values being written to the OPC Server, and thus the PLC/Device.
    • Use the iStripChartX or iPlotX component(s) to add charting abilities to your HMI
    • Use the iStripChartX or iPlotX component(s) to log the data

    Some more advanced features might be:

    • De-activate (but not disconnect) the Tags for the controls that are not viewed on screen, i.e. they reside on a Window that is behind the currently viewed window. This can put less overhead on the OPC Server.
    • Consolidate all of your OPC item connections using the "iOPCManage" control to establish a single connection to the OPC Server.
      The OPC Data Control ActiveX already achieves this.

    If you use the OPC Data Control ActiveX then you may wish to consider some minor scripting to:

    • Automatically bind Tags to objects on the form (instruments) by using an external configuration file (*.INI)
    • Automatically activating/deactivating the Tags being used on a Form when that form is viewed/hidden from screen.
    • Utilizing the ReadMultiVariables and WriteMultiVariables methods to read/write to many Tags in one transaction.

Copyright Software Toolbox, Inc., 1996-2004, All Rights Reserved Worldwide.
148A East Charles Street, Matthews, North Carolina, USA 28105
Phone: 704-849-2773 or 1-888-665-3678 (US), Fax: 704-849-6388
Email:
tools@softwaretoolbox.com