This action might not be possible to undo. Are you sure you want to continue?
John Weber The Software Toolbox
October 21, 1998 Houston, TX
Copyright 1998 Qualitrol International & Software Toolbox.All rights reserved worldwide.The Software Toolbox is a registered trademark of Qualitrol International.
Why are we here today ?
• Take the mystery out of objects and VB
– Objects & terminology – ActiveX & Containers – VB - The “Glue”
• Sample Applications
– Process Graphics – PLC Connections – Trending/Logging – Alarming/Logging – Recipes – Networking
Defining the Technologies
Software Objects What are they ?
• You can’t touch them - except on the disks or CD you load them onto your PC from • You can see them in many cases through their user interface • Are pieces of software for a specific task or family of similar tasks • Are similar to subroutines or functions • May contain numerous subroutines and functions of their own • Used to model software after real-world machine or process components or sections • Are easily transported from one PC to another provided standard interfaces are followed • Much of the software you use on your PC is built of objects
Objects .an object representation of a PLC Input Modules Output Class Modules Class Interfaces Power Supply PLC Rack .The Building Blocks Example .
number of channels.occur when things happen Hypothetical PLC Analog Input Module “class” Properties .Object Terminology • • • • Classes . updated value sent to CPU. scaling updated. configuration change received from CPU .voltage changed on field input side.send analog input to CPU.groupings of similar object types Properties . channel type Methods .make things happen Events . scaling set points. scale value Events .define how the object behaves Methods . voltage level.
Object Terminology A simple software object .a text box on a VB form Properties Alignment BackColor BorderStyle Font Height Name Text Visible Width and 43 others Methods Drag Move OLEDrag Refresh SetFocus ShowWhatsThis and 5 others Events Change Click DblClick DragDrop DragOver GotFocus LostFocus KeyPress Mousedown Mouseup and 13 others .
etc.visual basic.a type of COM object • Container .Distributed Component Object Model = COM + Networks • ActiveX .a place you assemble your objects to form an application – Office productivity applications – Development tools . – Web browser • OLE .Object Linking and Embedding .More Object Terminology • COM .Component Object Model • DCOM .
the worksheet is a collection of cell objects. a workbook is a collection of worksheet objects Cell Properties Cell Object .Software Objects Examples Command Button Object Command Button Properties Everything on your Excel spreadsheet is an object! .
Software Objects Examples Invoking the Print Method The Print Event .
Software Objects Examples Visual Basic (VB) comes with a lot of free objects that give you the Windows look and feel with minimal work .
Software Objects Examples ActiveX control objects “plug-in” to VB to let you add functionality • PLC Communications • Trends • Gauges • Tanks .
and the control is added to the toolbar .Adding an ActiveX Component to the VB Toolbar & To A Form Right Mouse Click with pointer over the toolbar and select “components” The Default VB Toolbar Double click the new component on the toolbar and it is added to your form! Check the component you want to add “ABCTL OLE Control module” in this case. click the OK button. click the Apply button.
text box or ActiveX control) on a form Instanciate (verb) .An Automation Software Object Actual PLC Communciations ActiveX Object “instances” Placed into a Visual Basic form container Instance (noun) .a single copy of a type of software object (I.the act of placing a single copy of an object onto a form .e.
Browsing the Object’s Interfaces Actual PLC ActiveX object in a VB container application where its properties. and events are browseable using VB’s Object Browser Function Events Properties Methods . methods.
Visual Basic .property.000 people worldwide .a full fledged development environment • VBA . object_event syntaxes • VB known by 3.method. object.Visual Basic for Applications – It is macro language in the Office applications – Is licensed by over 100 companies for use as their scripting language for customization • Both Use simple object.000.VB .The Glue to connect objects in your container • VB .
Private Sub Objectname_EventName( ) user Logic End Sub Example Statements Text1.FileAddr) to read using a plug-in ActiveX control object Invokes the .FileAddr = “N7:0” ABCTL1.ObjectName.Autopoll(500) displays text in a text box by setting the .Text = “Hello World” ABCTL1.Autopoll Method to read data every 500ms using a plug-in ActiveX control object .Property = variable or value Methods .Text property on the Text1 text box object Sets a PLC memory address property (.Assembling the Objects in a Container Simple Visual Basic Syntax for referring to objects Properties .Objectname.Methodname (parameters) Events .
Human Machine Interface Apps • • • • • • • HMI = Human Machine Interface Process Graphics PLC Connectivity for Data Trending and Logging Alarming and Logging Recipe Loading Networking .
Static Step 1Select the VB image control from the VB toolbar and add to the form Step 2 .Paste an image from a Symbol Library to the image control.Process Graphics . set the stretch property on the image control to true and size to fit your needs .
Process Graphics . Here we’ve used a preconfigured look and feel from the object’s library to get setup quick . select “properties” on the pull down menu that appears and use this properties page to set your look and feel.Dynamic Add an instance of a dynamic gauge ActiveX plug in to your VB toolbar and then to your form Right click on the object with your mouse.
PLC Connectivity and Data adding the ActiveX Control Add an off-the-shelf ActiveX control for PLC connectivity to your VB toolbar and then add instances of the control to your VB form • Use multiple instances of the PLC ActiveX control to keep code to a minimum • Give the each instance an intuitive name such as PLCMachine1 and PLCMachine2 in your applications • Use separate instances for reading and writing to keep your code to a minimum. even though most PLC Communications ActiveX controls don’t require you to use separate instances for reading and writing .
the PLC node address (.PLC Connectivity and Data setting properties This particular PLC communications ActiveX control represents each physical hardware adapter as a “logical adapter”. and the number of points to read/write. the PLC memory address (. When you right click on each instance of the PLC control.Fileaddr). you bring up this properties page to set the properties on the control for whether you are reading or writing (. By doing this.node).function). the developer of this control gives you the ability to change the hardware interfaces to your PLC without recompiling your program. . You run a simple config program shown here to set the hardware settings and communications parameters.
longval. (Form_Load() Event) the Autopoll method on the instance of the PLC ActiveX control called ABCTL1 is invoked. are available for other data types .PLC Connectivity and Data Making the read happen • Reading occurs when the . it fires the “OnReadDone()” event • Displays are updated using the 3 lines of code shown above in the ABCTL1_OnReadDone() Event • Data is accessed in the PLC ActiveX control using the WordVal and BitVal methods to properly format the data • Other methods such as floatval.Autopoll methods are invoked • In this example when the Form Loads. stringval. etc.Trigger or . • The PLC control does its job and when it is done.
Trending and Logging Builds upon what you’ve already learned by adding 2 new controls • Trending ActiveX control • VB’s standard Data control for database connectivity Setup a single instance of the PLC ActiveX control and its properties like before but this time use the standard VB command button’s On_Click() event to start the polling of the PLC based on user input Properties Page for the Trending ActiveX Control .
Autopoll method to start/stop polling when user clicks on command buttons These lines setup the timebase and variables on the trend chart ActiveX control when the form is loaded Update text boxes on screen with data from the PLC ActiveX Control Plot data on the trending ActiveX control Log the data to the database using the VB data controls methods This OnReadDone Event fires every time a poll completes .the autopoll rate sets your trend update rate for you .Trending and Logging .VB Code Invoke the PLC ActiveX Controls’ .
Trending and Logging The Finished Product in Run Mode .
Alarming and Logging .Building the Form • Uses same controls and adds one new • Uses new methods and events on PLC ActiveX control to provide alarm generation capability VB List Box Control for simple alarm display .new to this project VB Data Control for Database Connectivity PLC ActiveX Communications Control .
on discrete change) – Autopoll method used to tell control how often to check the points • Could all be done with VB If-then structures • Using the ActiveX controls’ methods instead saves code and troubleshooting time . on normal. on low.Alarming and Logging Generating the Alarms • Watchpoint Methods – Method included in PLC ActiveX control – User specifies high. on change. low limits and type of alarms desired (on high.
Alarming and Logging • You setup the watchpoints and go on doing other things in your applications • Handle the events when they happen • OnAnalogHigh • OnAnalogLow • OnAnalogChange • OnAnalogNormal • OnDiscreteChange .
also clear the alarms display when polling starts Build the high alarm message text string.Alarming and Logging. then log the data to the database using the data controls methods .VB Code Setting up the watchpoint by invoking the .Autopoll method to start polling the PLC when the command buttons are clicked . display it in the list box.WatchPointAdd method in the PLC Comms ActiveX Control Use the .
then log the data to the database using the data controls methods .Alarming and Logging.VB Code Build the low alarm message text string. display it in the list box.
VB Code Build the normal alarm message text string. display it in the list box. then log the data to the database using the data controls methods Update a text box on the screen each time a new value is read from the PLC Do some simple data validation when the user enters a PLC memory address .Alarming and Logging.
Alarming and Logging Finished Product .
Alarming and Logging Advanced Displays For more advanced alarm displays. ActiveX plugins are available to provide the needed functionality .
Setting up the Data Control Use VB’s standard Data Control to connect to a database • Don’t let all the properties confuse or worry you • Key properties to set on data control: • DatabaseName = pathname and filename of the database • RecordSource = table name or query name to get records from in the database .Recipe Loading .data control gives you a pull-down list .
whose data will be bound to the text box Each text box field on the form is “bound” using the DataSource and DataField properties to a column in the database . pulled from an auto-generated pulldown list.Recipe Loading .the name of the data control that you setup to connect to the database • DataField .Data Binding Text box properties page has 2 key properties that allow the user to connect or “bind” the value shown in the field to a column in a database table or query • DataSource .the actual column.
In Action When the user clicks on the next or previous recipe buttons. the code shown below advances the database pointer forward or backward one record while checking to make sure the beginning or end of the database table is not passed .Recipe Loading .
the user is notified with a message box .In Action When user clicks on “Download to PLC”. When the OnWriteDone event fires.Recipe Loading . the code below loads the displays values into the PLC ActiveX control and invokes its trigger method to write the data to the PLC.
Networking .Leveraging Newer Ethernet Aware PLCs Client PCs running your VB HMI Application and using a PLC ActiveX control that supports direct Ethernet connections to the PLC TCP/IP Ethernet Network PLCs with built-in Ethernet Interfaces .
Retrofitting to Proprietary PLC Networks Client PCs running your VB HMI Application and utilizing a PLC ActiveX control that provides with it an EXE application for your server to bridge from Ethernet to the PLC networks or an ActiveX control that is an OPC client and can talk to an OPC server Gateway Server running a software bridge between the PLCnetworks and TCP/IP Ethernet TCP/IP Ethernet Network Proprietary PLC Network Remote user via Windows Dial-Up Networking • Provides a solution when the investment to replace PLCs with Ethernet Based CPUs is too high or the PLC network interface cards for each client are cost-prohibitive • The gateway software bridge can be either an EXE program that is included with some PLC communications ActiveX controls or an OPC server .Networking .
Transfer Line Application .
Transfer Line Application .
Microbrewery Application .
you control the application • Cost – you can distribute your VB code royalty free – ActiveX components have low or no royalty fees for .Benefits of Using Visual Basic for HMI Applications • Use the right tool for the right job – Simple to moderately complex apps – Don’t reinvent a pre-configured HMI in VB if that’s really what you need • Support for wide range of ActiveX plug-ins • Widely known scripting language • Flexibility .
com/vba • Download copy of this presentation and other presentations and technical papers at www.Resources for further learning • Understanding ActiveX & OLE . Microsoft Press • Office97 Visual Programmers Guide Microsoft Press • Microsoft Websites msdn.David Chappel.softwaretoolbox.microsoft.com/isaexpo98 .
com . www.Where do I find ActiveX controls and tools for Industrial HMI Applications ? Although this presentation is a non-commercial. Visit our website today for more product information. including Visual Basic based HMI applications. sharing of knowledge presentation.softwaretoolbox. we added this slide after show because so many of you at the show were asking this question! The Software Toolbox is a company that provides you with a single place to look to find all the software tools you need for automation applications.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue listening from where you left off, or restart the preview.