You are on page 1of 18

Overview

As scientists, engineers, technologists, or just the curious, we de-
sign experiments to better understand the world around us. Sensors
are used to probe and measure physical parameters that describe the
world. Transducers stimulate the world in a known way so our sen-
sors can read the response. To automate measurements and re-
sponses, a microcomputer drives and controls the sensors and trans-
ducers. LabVIEW is the most powerful measurement and control
language available to execute the control algorithms and to present
the results is a user-friendly format. This chapter introduces the
LabVIEW workspace and demonstrates how analog and digital sig-
nals are measured and manipulated, all in a friendly and transpar-
ent graphical language.

GOALS
■ Enter the LabVIEW environment
■ See the graphical language at work
■ Build a digital-to-analog converter
■ Take the LabVIEW challenge: Vector Calculator

KEY TERMS
■ LabVIEW workspace ■ Analog Amplifier
■ LabVIEW Tools, Controls, and ■ Digital Amplifier
Functions ■ Digital-to-Analog Converter
■ LabVIEW Palettes everywhere

LabVIEW Environment 1 LabVIEW Virtual Instrument for a Popular Digital Voltmeter FLUKE 45 1 .

The virtual instrument cannot only simulate the instrument. rotate the knobs. You can quickly get a feel for the capability and the operation of an instrument. all the functionality of the real device is simu- lated on the screen. Transducers and LabVIEW Welcome to the world of LabVIEW and virtual instrumentation. IEEE488. and learn the operation of the instrument. The difference between simulation and virtual instrumenta- tion is that behind the scenes. . A virtual instrument consists of a computer simulation of a tra- ditional hardware instrument. groups of instruments are combined to demonstrate measurement tech- niques.” The top window is the front panel of the virtual instrument. or process. or real process from the same front panel. and the simulation becomes a valuable educational tool. Indeed. to gain familiarity. the instrument can be simulated and used in a way that it cannot be harmed or harm any other device. or TCP/IP). information on the computer screen is connected to a real instrument by software.2 Sensors. Once the skills in operation are learned. the simulation can be connected to a real instru- ment to provide real-time computer control over that instru- ment. In some cases. the simula- tion can be used as a training exercise. but also control the real instrument. through various communication lines (RS232. When you click the buttons. As a teaching tool. training on a LabVIEW simulation may be of lower cost than using a hardware simulator. When you click on a simulated button on the video monitor. In other cases. real technique. technique. or just turn on the power switch. A window on the computer screen called the front panel replaces and in many cases looks just like the front panel of the real instrument. the real switch operates. Herein lies the power of LabVIEW. The Front Panel Launching LabVIEW yields two panels or windows labeled with the default titles “Untitled 1” and “Untitled 1 Diagram.

Two particu- larly useful palettes are the Tools palette and the Controls palette. stop. or pause the program. Scroll bars at the side and across the bottom will be available to center the instru- ment once components are added to the front panel. set the text font. You can show these by clicking on the Windows menu and selecting Show Tools Palette and Show Controls Palette. Above the Workspace is a toolbar. When the mouse button is released. size. with different tools to run. and align components in the workspace. The palette can be “picked up” by clicking on it and moved to a new location by dragging the palette with the mouse button down. ■ The Front Panel Palettes A palette is defined as a group of objects that are placed to- gether in a separate window. the palette stays at the new location. .1 | LabVIEW Environment 3 Default Title Run Continuously Abort Default Font & Size Run Workspace Icon Pane Alignment Ring Distribution Ring The central gray area is the “Workspace” where the virtual instrument’s front panel will be assembled. Additional tools and a library of components are nec- essary to help us build the front panel. and style. and a LabVIEW default icon pane that ultimately will be the graphical representation of the program.

the cursor is depicted as an arrow and executes the usual mouse-type operations. The Positioning tool is used primarily for editing the front and diagram panels and allows you to se- lect. The Text tool allows you to make and edit free la- bels that can be used for instructions or titles. changes the cursor to a new function when used in the Workspace. style. move. . The font. size. Which function it executes is determined by the selection of the tool icon. when selected. Transducers and LabVIEW Workspace Each palette has a variety of objects or icons that add addi- tional capabilities. changing controls and in- dicators even when the program is running. Outside the workspace. high- lighting an object. Each icon. selecting and deselecting an item. Let’s look at the Tools palette first.4 Sensors. Here is a short list: The Operating tool lets your finger do the walking through the front panel. and color of all text boxes can be changed by first selecting the text with the text tool and then selecting the new style. and dragging an object across the window. and resize objects. opening up a menu. the cursor has multiple functions. Inside the workspace.

The Scroll tool allows the panels to be moved around and viewed differently. The Color Copy tool allows the user to select a color from an existing object. The Color tool allows you to select the fore- ground or background colors of an object from a multitude of shades and hues.1 | LabVIEW Environment 5 The Wiring tool on the diagram panel connects ter- minal boxes and functions together by assigning a data path between objects. the wiring tool is used to assign controls and indicators to sub-VI inputs and outputs for converting a pro- gram into a module. The Pop-up tool opens up an object’s menu to re- veal properties than can be changed. The Breakpoint tool sets points on the VI where the program will pause. Boolean (Sub-menu) Numerics String & table List & Ring Graph Path & Refnum User Controls Array & Cluster Decorations Select a Control.. It is used for debugging com- plex programs. . Useful for matching colors between objects so that the same shade is se- lected. The Probe tool creates probes on wires so you can view the data as it passes through the wire.. On the front panel.

observe what happens when the graph button is clicked. To place a control or indicator on the front panel. it is first necessary to find in a subpalette the appropriate object. and user controls). just click and drop the object. then to select it by clicking on that object. paths & refnums. The remaining button. The cursor then changes to the Scroll tool so you can now drag the object into the work- space. In the example below. resized. is used to provide simple shapes that can be moved. By clicking on that control button and holding down the mouse button. These are conveniently divided into data types (numerics. a gauge indicator is found on the numeric menu. Transducers and LabVIEW The Controls palette contains a wealth of LabVIEW controls and indicators. the associated subpalette appears. Five graph types appear on the subpalette. called Decorations. By clicking on that object. Each palette that contains a black arrow in the top right corner indicates that there are more menus in a subpalette. graphs. Booleans. arrays & clusters. For example. strings & tables.6 Sensors. which “magically” appears. When it is in the correct location. a box appears around it and the Positioning cursor becomes the Scroll cursor. . and colored to add shape and sparkle to your panels.

It . The black box indicates that a label is requested.1 | LabVIEW Environment 7 Now just drag the object into the workspace. the gauge appears. Workspace and presto. When the cursor is clicked in the workspace. You can now type a name for this object. the label is set.

Numeric Array Structures String Boolean Cluster Comparison File I/O Time & Dialog Instrument I/O Data Acquisition Communications Advanced Analysis Select a VI Instrument Drivers Tutorial User Libraries . Transducers and LabVIEW will be carried onto the diagram panel to provide a name for this numeric output. clusters. When the diagram panel is selected. it contains a wealth of LabVIEW functions con- veniently divided into areas of common operations such a nu- merics. arrays. it can be se- lected from the Windows>Show Functions palette. strings. a new Functions palette appears. and so on.8 Sensors. The controls palette is only active and visible when the front panel is the active window. Like the control palette. If it is not visible. Booleans.

In the following case. and Constants. Trigono- metric. data is input and output on a matrix of boxes on the front panel. When the spreadsheet was run.1 | LabVIEW Environment 9 LabVIEW has an extensive list of mathematical functions and operations. Logarithmic. the tangent operation is found on the Numeric subpalette. How do you build a spreadsheet for instrumentation? The front panel of LabVIEW contains all the input and output devices: the switches. ■ Panels. and in some cases several subpalettes must be navi- gated to get to the desired function. This palette contains further subpalettes for Conversions. In a spreadsheet. the dis- . Panels Everywhere! The original concept for LabVIEW was in the form of an elec- tronic spreadsheet for instrument control applications. Behind every box on the front panel is an arith- metic equation. In the trigono- metric subpalette the tangent operation is found. Selection and placement of a function is similar to that of controls and indi- cators. Complex. the inputs were converted to outputs by the hidden formulas and the results showed up on the front panel. the relays. the digital voltmeters.

10 Sensors. do not forget the ON/OFF switch to power up the am- plifier. Behind the front panel input/output devices is the diagram panel or window. and so on. Each of the input/output functions has a graphical rep- resentation. The link between the two panels is comprised of the terminal blocks. A m plif ie r Diagram Panel . Suitable labels aid in the program layout and documentation. Each input or output device will have a terminal box that can be wired up to other components (functions). a potentiometer to set the gain. where the actual circuit is to be built. Transducers and LabVIEW plays. A thumbwheel switch is used to set the input level. Oh yes. and a meter to display the result. The lettering inside the terminal box and its color tells what type of data is gener- ated or expected. Look at a simple instrument where an input level is to be amplified with a gain from 0–10 and displayed on a meter.

To do this. heavy outlined with the letters “TF” inside the box. graphi- cal symbols or icons are used to represent mathematical and other functions. the relationship is Output = Input × Gain.vi Diagram The window behind the front panel is often called the block di- agram. Here is where we have built the circuit to simulate the amplifier. since the program design resembles an electronic schematic diagram. One wires up the inputs to the input side of the function and the output to the display. Its input terminal is green in color. and meter values are all numeric values and are indicated by an orange box with the letters “DBL” inside the terminal box. gain. In this instrument. Amplifier. while outputs have a single line around the terminal. a Boolean. Inputs have heavy outlines around the terminal. It only has two possible states ON or TRUE and OFF or FALSE.1 | LabVIEW Environment 11 The input. Note that the inputs are usually on the . DBL stands for double precision floating point variable. In LabVIEW. The ON/OFF switch is a different data type. we will use the Positioning tool to move the input and output terminals into a more natural programming arrangement. Analog Amplifier To convert these inputs and outputs into an instrument. the in- puts and outputs must be connected to the mathematical func- tions that simulate the required operation. Note the different shaped boxes for input and output.

The output of the switch (0) or (1) is multiplied by a con- stant weighting factor and the resultant value displayed in the output box labeled “Value. the process stops. . De- sign a LabVIEW program to execute the calibration equation Output = (Input − Offset) * Gain Use Amplifier. in a data path is made. These two states are converted into a numeric (1) or (0) respectively by a Boolean-to-numeric transformation function. If the Boolean input is false. The [while . It has a control terminal [ ] and even an index [i]. then reads the control terminal [ ]. true (ON) or false (OFF). ■ LabVIEW Challenge: Offset and Gain The most common form of calibration for a linear sensor is sub- traction of a constant offset from the sensor output followed by multiplication of the difference signal by a scaling constant.vi as a starting point and modify the program to execute the calibration equation.12 Sensors. If the Boolean input is true. In this example. Save your program as Am- plifier2. . the while . shown above as the heavy gray box. A bit indicator (LED display) displays the state of the switch when the program is run. . and click. Digital Amplifier In our second example. The bit switch is depicted on the front panel as a vertical throw switch. It outputs a Boolean data type.” . drag to the appropriate location. What about that power switch? In LabVIEW. Presto. The wiring tool is used to con- nect input/output terminals to the functions. programs are often placed into a while loop. the loop repeats and executes all functions inside the box. Just click on the input/output. whose input is only amplified when a switch is thrown. . Transducers and LabVIEW left and the outputs on the right. loop] structure executes everything inside the box. loop simulates the ON/OFF power switch on the front panel.vi. we will look at a digital amplifier.

In this example. Note the special icon [?0:1] that converts the Boolean output of the switch into a numeric value. This is essential. if the weight is 64. the outputs of the two switches are added together to form a sum. then the output can only have two values: 0 if switch is off and 64 if the switch is on. These four input/output links show up on the block diagram as four terminal boxes. since the multiply function can only operate on numerics. When a second binary switch is added in parallel with the first one. there are two inputs (Bit Switch and Weight) and two outputs (Bit Indicator and Value).1 | LabVIEW Environment 13 For example. .

better known as the DAC.vi. or 3). This program. the program is just a little more complicated. A two-input ADD function has been added to create the out- put sum. 2. DACs are the core of many circuits and in- struments including digital voltmeters. is a major interface circuit that forms the bridge between the analog and digital worlds.14 Sensors. 1. is in essence a 2-bit digital- to-analog converter. There are four possible out- put values (0. On the block diagram. the functionality of the front panel can be preserved in the program design depicted on the block dia- gram. plotters. A DAC is an electronic component that converts digital logic levels (bits) into an analog voltage. called DAC2. oscilloscope displays. Transducers and LabVIEW The first switch labeled [Bit 1] has a weight of 2 and the sec- ond switch [Bit 0] has a weight of 1. By careful arrangement and alignment of the icons with the alignment tools. The output of a DAC is the arithmetic sum of all the input bits weighted in a particular manner: DAC = ∑w b i=0 i i . Digital to Analog Converters The digital-to-analog converter. and many computer-controlled devices.

32. 2. and 1. 64. 4. An 8-bit DAC can be simulated by summing the outputs of eight digital amplifiers.vi) is shown above. weighted with 128. wi = 2i. The block diagram for such a simulation (DAC8. Note how each bit circuitry is similar to all other bits differing only by a different weighting factor. 8. the complete expression for an 8-bit DAC is given by the expression DAC = 128 b7 + 64 b6 + 32 b5 + 16 b4 + 8 b3 + 4 b2 + 2 b1 + 1 b0 Any number between 0 and 255 can be represented by an 8-bit binary number.1 | LabVIEW Environment 15 where wi is a weighting factor. bi is the bit value (1 or 0) and i is the index of the bit number. In the case of a binary weighting scheme. 6. In a program with this .

vi is shown below. and easy to debug. What are their DAC sums? 00000000 ____________ 10101010 ____________ 11001100 ____________ 11110000 ____________ 10000000 ____________ 01010101 ____________ 00110011 ____________ 00001111 ____________ . Here are some useful binary patterns. Eight LED indicators are also used to display the binary value of the input bits when the simulation is run. Load from the chapter 1 library DAC. On the front panel.16 Sensors. wise use of cut-and-paste operations and the LabVIEW alignment tools make the circuit easy to build. observe the relationship between the binary codes and their numeric equivalent value. The analog output is displayed in a numeric display. eight Boolean switches are used to set the input bits b0 through b7. The front panel for DAC8. Check out the weighting factors for each bit by toggling each switch on and off. By running this pro- gram continuously. modules and arrays will be introduced as a means of writing programs that are even more readable. and manageable.vi. Transducers and LabVIEW much redundancy. In the future chapters. easy to to read. concise.

a sub-VI.) can be repre- sented as vectors. . In the next chapter. where the vector is de- scribed by its length or magnitude 冟A冟 and the angle ␪ it makes with the horizontal axis.1 | LabVIEW Environment 17 These binary patterns generate useful and interesting wave- forms when the bits are output sequentially. Build a vector calculator that adds two vectors A and B. DAC. Vector manipulation and arithmetic provides a concise method to represent and solve many types of prob- lems. assume the vectors are represented by polar coordinates.vi is also a sub-VI and its simulation will be used many times in future chapters to convert a binary pattern into a numeric number. current. etc. The resultant vector R is R = A+B = (Ax + Bx) i + (Ay + By) j To make the challenge more interesting. ■ LabVIEW Challenge: Vector Calculator Many scientific variables (voltage. Recall each vector can be represented by its rectangular compo- nents A = Axi + Ayj and B = Bxi + Byj. you will see how a program can be con- verted into a sub-program or in LabVIEW.