delft university of technology labview introduction course cour… · pc measurement and control....

13
Delft University of Technology LabVIEW introduction course preparation document Document details Author: Bart Boshuizen Title: LabVIEW introduction course Subtitle: Preparation document Subject: Making a data-acquisition program with LabVIEW Keywords: LabVIEW, course Version: 20100210 Author details Name: Bart Boshuizen Dept: SSC-ICT 3xO Email: [email protected]

Upload: others

Post on 19-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Delft University of Technology LabVIEW introduction course cour… · PC measurement and control. LabVIEW was invented with the engineers in mind. They should be enabled to make measurement

Delft University of Technology

LabVIEW introduction course preparation document Document details Author: Bart Boshuizen Title: LabVIEW introduction course Subtitle: Preparation document Subject: Making a data-acquisition program with LabVIEW Keywords: LabVIEW, course Version: 20100210 Author details Name: Bart Boshuizen Dept: SSC-ICT 3xO Email: [email protected]

Page 2: Delft University of Technology LabVIEW introduction course cour… · PC measurement and control. LabVIEW was invented with the engineers in mind. They should be enabled to make measurement

Delft University of Technology LabVIEW introduction course

2

Page 3: Delft University of Technology LabVIEW introduction course cour… · PC measurement and control. LabVIEW was invented with the engineers in mind. They should be enabled to make measurement

Delft University of Technology LabVIEW introduction course

3

Introduction LabVIEW is being used throughout the University for doing experiments that require PC measurement and control. LabVIEW was invented with the engineers in mind. They should be enabled to make measurement and control applications without having to know all the ins and outs of text based programming language. Hence evolved the graphical programming environment that LabVIEW offers. Still LabVIEW is a real programming environment. And as with any programming environment most people need some help to getting started. Hence evolved this LabVIEW introduction course. Course setup Clearly the purpose of this course is to introduce you to LabVIEW. But also to teach you something on data-acquisition more specifically on data-acquisition with National Instruments devices. By the end of the course you will understand the basic principles of LabVIEW and you will be able to create a working application. This particular document introduces LabVIEW and its programming environment. Try to read and understand it before taking the course. A separate document is required for the hands-on part of this course. It describes a number of steps, in which you will make an actual LabVIEW program including data-acquisition, where each steps is as follows:

• Introduction to the next phase of the program • Instructions on programming the next phase • .. Actual programming .. • Evaluation

Page 4: Delft University of Technology LabVIEW introduction course cour… · PC measurement and control. LabVIEW was invented with the engineers in mind. They should be enabled to make measurement

Delft University of Technology LabVIEW introduction course

4

Scope of use Maybe you know LabVIEW for the kind of application that you will learn to make today: acquire data, display it in a graph and store it to disk. However, with LabVIEW you can create more complex applications. Applications that combine measurement and control with a variety of hardware and include communications with external programs.

Samples of such applications are the Robot Control program and the Atomic Layer Deposition program at the Chemical Engineering department of Delft University of Technology. The Robot Control program combines command level control of a laboratory robot (Zymark) with controlling mass flow controllers (Bronkhorst) and temperature controllers (RKC), with communication to two types of data-acquisition hardware (National Instruments and Advantech) and with communication with an OPC server (IPCOS). The Atomic Layer Deposition program combines controlling temperature controllers (RKC) with data-acquisition hardware (Advantech) and with communication with a DDE server (Bronkhorst). There are dozens of other applications within the Chemical Engineering department that show this capability of LabVIEW. Process control applications like these can even be expanded with Vision, Motion, Vibration, Sound (all requiring add-on software) and High-Speed data-acquisition. Furthermore an application can be made to run on special hardware such as real-time targets, handhelds and FPGAs. Today you will use just one piece of data-acquisition hardware and no special add-on software. In order to demonstrate the capability of LabVIEW to work with several types of hardware simultaneously you will create two independent tasks: analog output (to generate a fluctuating voltage) and analog input (to measure the voltage). This obviously expands the simple concept of acquire, display and store. You might think that LabVIEW is only suitable to do measurements or to control laboratory setups. It is true that LabVIEW is perfectly suited to do the job. But LabVIEW can be used to perform other tasks as well. One example is an application that analyzes data files in ASCII format and reports in native Excel spreadsheets. Another example is an application that generates screenshots of websites. Those applications have nothing to measure or to control, yet LabVIEW offers the right environment to develop those applications as well.

Page 5: Delft University of Technology LabVIEW introduction course cour… · PC measurement and control. LabVIEW was invented with the engineers in mind. They should be enabled to make measurement

Delft University of Technology LabVIEW introduction course

5

Programming environment It is not unusual that at start-up you will have to wait a while before you can actually start to work with LabVIEW. One of the reasons is that whereas many things are possible with LabVIEW, these things have to be initialized. On many occasions you will have to wait even longer because of the add-on software (like plug-in modules and toolkits) that has to be initialized as well. Once LabVIEW is ready for use, it presents a ‘Getting Started’ screen. From here you can either start creating a new program or continue working on an existing program (or program element). For larger applications it is useful to start with a LabVIEW project to which you add all program elements. For some applications using a LabVIEW project is even mandatory. Figure 1 - The Getting Started screen

In this course you will create only a few program elements so you don’t need to create a LabVIEW project. The most important part of an application is its main VI or Virtual Instrument. A ‘VI’ is just the same as a ‘LabVIEW program’. During this course you will create several VIs of which one is the main VI and the others are the sub VIs. A blank VI, as today, is often the starting point.

Page 6: Delft University of Technology LabVIEW introduction course cour… · PC measurement and control. LabVIEW was invented with the engineers in mind. They should be enabled to make measurement

Delft University of Technology LabVIEW introduction course

6

Figure 2 - A Blank VI

A blank VI presents itself as two windows, one being the Front Panel the other being the Block Diagram. Both windows contain the same icon (the Current VI Icon) that represents the VI and which is also where you can find the connector pane. A right-click on the Front Panel, Block Diagram or on the Current VI Icon gives access to the options for that specific program element. A right-click on the Front Panel shows the Controls Palette, on the Block Diagram it shows the Functions Palette and on the Current VI Icon it shows a pop-up menu.

Page 7: Delft University of Technology LabVIEW introduction course cour… · PC measurement and control. LabVIEW was invented with the engineers in mind. They should be enabled to make measurement

Delft University of Technology LabVIEW introduction course

7

Figure 3 - The Controls Palette and the Functions Palette respectively

More general tools that are required during programming can be found on the Tools Palette. The tools on the Tools Palette apply both to the Front Panel and the Block Diagram. If the Tools Palette isn’t visible go to ‘View’ menu and select ‘Tools Palette’. Figure 4 - The Tools Palette with the Positioning Tool selected

Obviously even more tools and options can be found in the menu. There are some options besides the obvious ones (like ‘File’/’Save’) that are worth mentioning: ‘Edit’/’Customize Control’ This is only available on the Front Panel and only if one control or indicator has been selected. It allows you to customize a control such that it looks different. But it also allows you to turn the selected control or indicator into a Type Def(inition). ‘Edit’/’Create SubVI’ This is only available on the Block Diagram and only if a piece of the code has been selected. It allows you to convert the selected code into a new VI. ‘View’/’VI Hierarchy’ This shows you all the sub VIs you use in a program as well as other programming elements (Global Variables and Custom Controls) and of course how they relate.

Page 8: Delft University of Technology LabVIEW introduction course cour… · PC measurement and control. LabVIEW was invented with the engineers in mind. They should be enabled to make measurement

Delft University of Technology LabVIEW introduction course

8

The Front Panel and the Controls Palette The Front Panel is the user interface of your program, the part that users get to see when running a LabVIEW program. Often you’ll get most of the credits for the user interface, let’s say 90% for 10% of the work. As a programmer you decide what’s on the user interface: controls, indicators, graphs, tables etc. But there is more, you can also add tabbed pages, dropdown menus and mere decorations. To make the user interface complete you could even add pop-up screens and one or more help files. In this course you’ll create a single screen with a few controls including buttons and indicators including a graph. You’ll learn how to update, refresh and modify your controls and indicators programmatically. The program isn’t complete with your own ‘About’ window. On the Controls Palette you’ll find items such as ‘Numeric’ for numerical controls and indicators, ‘Boolean’ for Boolean type (TRUE or FALSE) controls and indicators, ‘String & Path’ for text based controls. These are all single value or scalar controls and indicators. You will also find ‘Array & Cluster’. An array is a collection of values of the same type in a row (1D array) or in rows and columns (2D array). A cluster is a combination of values of different types. All in all there are a dozen types of controls and indicators to select from. The controls are the inputs and the indicators are the outputs of your LabVIEW program. So you will see a reflection, or terminal, for each of the controls and indicators in the actual program or Block Diagram.

Page 9: Delft University of Technology LabVIEW introduction course cour… · PC measurement and control. LabVIEW was invented with the engineers in mind. They should be enabled to make measurement

Delft University of Technology LabVIEW introduction course

9

The Block Diagram and the Functions Palette The Block Diagram is the actual part of the program where all the work is done and it is the part that requires most of the work, let’s say 90%. Programming in LabVIEW means you select the required functions and programming structures and make connections between the nodes (terminals and instances of functions) through which the data can flow. Typically the data flows from a control terminal to an indicator terminal. Data flow may also start from constants, some specific functions and Global or Local Variables. Likewise data flow may end in some specific functions and Global or Local Variables. On the Functions Palette you’ll find items like ‘Structures’ for structures that will alternate the normal data flow, ‘Numeric’, ‘Boolean’ and ‘String’ for operations on scalar data and ‘Array’ and ‘Cluster’ for operations on array and cluster respectively. Almost every program that you create can be used by another LabVIEW program provided you have added the right connections on the Connector Pane.

Page 10: Delft University of Technology LabVIEW introduction course cour… · PC measurement and control. LabVIEW was invented with the engineers in mind. They should be enabled to make measurement

Delft University of Technology LabVIEW introduction course

10

Connector Pane The Connector Pane is hidden behind the icon of your VI. It is a square pictorial representation of all inputs that can be used as parameters of your program and of all outputs that may originate from you program. Since the inputs of your program, that can be altered at run-time, and the output of your program, that will be altered at run-time, can only be found on the Front Panel this means:

• the Connector Pane can only be a selection of the controls (inputs) and indicators (outputs) on the Front Panel

• the Connector Pane can only be accessed from the Front Panel The Connector Pane is subdivided in patches (terminals) according to one of the predefined patterns. The most commonly used pattern is 4-2-2-4. Any terminal can be assigned to any of the controls or indicators by first clicking on the terminal and then on the control or indicator using the Wiring Tool. Figure 5 - Tools Palette with Wiring Tool selected

Figure 6- The connector pane made visible

Page 11: Delft University of Technology LabVIEW introduction course cour… · PC measurement and control. LabVIEW was invented with the engineers in mind. They should be enabled to make measurement

Delft University of Technology LabVIEW introduction course

11

Good to know in advance creating a new program For a new program you start with a blank VI. You’ll get both a Front Panel and a Block Diagram. You can switch to the desired window by clicking on it on by pressing <CTRL><E>. When working on the Front Panel you use the Controls Palette. If it isn’t visible you can right-click on the Front Panel. The most common controls can be found at the section ‘Modern’. You can use left-click to select the desired item after which you drop it in on the Front Panel. When working on the Block Diagram you use the Functions Palette. If it isn’t visible you can right-click on the Block Diagram. The most common programming functions can be found at the section ‘Programming’. You can use left-click to select the desired item after which you drop it in on the Block Diagram. Structures can’t be dropped like that but need to be resized first. identifying tools

- Automatic Tool Selection off

- Automatic Tool Selection on With Automatic Tool Selection on, LabVIEW will automatically select the best tool for the object -such as a wire, function or terminal- you are pointing at. But for more flexibility you can turn automatic tool selection off. With Automatic Tool Selection off, you have to switch manually. The preferred method is to use <SPACE> for the most common tools, to use <TAB> for other common tools or to select the desired tool from the Tools Palette.

- Operate Value

- Position/Size/Select

- Edit Text

- Connect Wire

- Object Shortcut Menu

- Scroll Window

- Set/Clear breakpoint

- Probe Data

- Get Color

- Set Color

Page 12: Delft University of Technology LabVIEW introduction course cour… · PC measurement and control. LabVIEW was invented with the engineers in mind. They should be enabled to make measurement

Delft University of Technology LabVIEW introduction course

12

identifying buttons Both the Front Panel and the Block Diagram have a button bar. The common buttons are named in the overview below. The most important buttons during the course have been highlighted.

- Run Running

- Run Continuously Running Continuously

- Abort Execution (program not running) Abort execution of …..

- Pause Continue

- Highlight Execution (BD only) Do Not Highlight Execution

- Align Objects

- Distribute Objects

- Resize Objects (FP only)

- Reorder

- Show Context Help Window Hide Context Help Window running a program To run the program you can press the ‘run’ button or press <CTRL><R>. If you want to run a program, that doesn’t contain some form of repetition, continuously, you can press the ‘run continuous’ button (next to the run button).

If the run button is as on the left picture you can press it to test the program. If it is as on the right picture you can still press the run button only this time LabVIEW will show what is wrong. highlighting execution To see what the LabVIEW really executes go to Block Diagram and select Highlight Execution.

Run your program with the block diagram visible and see how the data flows!

Page 13: Delft University of Technology LabVIEW introduction course cour… · PC measurement and control. LabVIEW was invented with the engineers in mind. They should be enabled to make measurement

Delft University of Technology LabVIEW introduction course

13

making a program public In order to make a small program public, so it can be used as a sub-VI within another program, you need to setup the program interface. First you need to set the connectors right. This can be done from the Front Panel only. With the Front Panel active you right-click on the Current VI Icon and select the option ‘Show Connector’. Make sure it has the 4-2-2-4 pattern of terminals as on the picture below. If not, then right-click the connector and select it from the option ‘Patterns’. empty connector pane with 4-2--2-4 pattern

For each control or indicator that should be on the connector click on the control (with the Wiring Tool) and on the desired terminal. Typically the inputs are on the left, the outputs are on the right and if present the Error In control cluster is on the bottom left and the Error Out indicator cluster is on the bottom right. sample connector pane

While setting up the connections you can follow the developments ‘live’ when you have turned Context Help on -you can turn Context Help on by pressing the question mark- and hover over the connector. sample connector pane in Context Help

Actually, for the sample program the connector input is required. To set this you right-click on the terminal (on the connector pane) and select ‘This Connection Is’/’Required’.