LabVIEW
Programs
Introduction to LabVIEW
LabVIEW is an application that lets you interface a
computer with an experiment. It is extremely powerful, allowing you to generate
and measure analog and digital voltages as well as control the timing of such
operations. In order to be such a powerful application,there is a huge amount
of exibility in what you can program. This makes it a little more difficult to
get started, but once you become familiar with the procedures you will enjoy an
amazing capability. After a description of the general features of the
application, you will be prompted to write four basic programs, each of which
performs one operation. Following that, you will write two programs that are
more complicated. Finally, you will have the chance to browse the library of
example programs and then write a program of your ownchoosing. The computer is
equipped with a National Instrument PCI-6221 Multifunctional I/O board. This
board is capable of (1) generating an analog voltage (D/A conversion), (2) measuring
an analog voltage (A/D conversion), (3) generating and measuring digital
voltages (digital I/O), and (4) timing the various operations. The D/A and A/D
conversions have a resolution of 16 bits, meaning that the voltage range (-10
to +10 V) is divided into 216 = 65536 levels. The spacing between levels is
therefore 0:3 mV if the voltage range is -9.99756 to 10.00000 V. You can choose
ranges/resolution among some standard settings
(_10V , _ 5V , _ 1V , _ 0:2V ). Every generated or
measured analog voltage will be one of these 216 values. There are 2 analog
output channels for generating voltages and 8 analog input channels for
measuring voltages. The 8 analog input channels can be set up to use the same
ground connection as the reference (this is called RSE or Referenced Single
Ended, there is also differential input, but we aren't going to use this). The
2 analog output channels have a common reference ground. There are 3 digital
channels, each of which has 8 lines that can be low/false (0 V) or high/true (5
V). Each digital channel can be used either to generate a digital voltage
(digital out) or measure a digital voltage (digital in), but clearly not both
at the same time!
Introduction to Virtual Instruments
LabVIEW programs are called virtual instruments, or
VIs, because their appearance and operation imitate physical instruments, such
as oscilloscopes and multimeters. LabVIEW contains a comprehensive set of tools
for acquiring, analyzing, displaying, and storing data, as wellastoolstohelpyoutroubleshootcodeyouwrite.
In LabVIEW, you build a user interface, or front panel, with controls and indicators. Controls are knobs, push buttons, dials, and other input mechanisms. Indicators are graphs, LEDs, and other output displays. After you build the user interface, you add code using VIs and structures to control the front panel objects. The block diagram contains this code.
You can use LabVIEW to communicate with hardware such as data acquisition, vision, and motion control devices, as well as GPIB, PXI, VXI, RS232, and RS485 instruments.
In LabVIEW, you build a user interface, or front panel, with controls and indicators. Controls are knobs, push buttons, dials, and other input mechanisms. Indicators are graphs, LEDs, and other output displays. After you build the user interface, you add code using VIs and structures to control the front panel objects. The block diagram contains this code.
You can use LabVIEW to communicate with hardware such as data acquisition, vision, and motion control devices, as well as GPIB, PXI, VXI, RS232, and RS485 instruments.
Building the Front Panel
The front panel is the user
interface of a VI. Generally, you design the front panel first and then design
the block diagram to perform tasks on the inputs and outputs you create on the
front panel.
You build the front panel using
controls and indicators, which are the interactive input and output terminals
of the VI, respectively. Controls are knobs, push buttons, dials, and other input mechanisms. Indicators are graphs, LEDs, and other output displays. Controls
simulate instrument input mechanisms and supply data to the block diagram of
the VI. Indicators simulate instrument output mechanisms and display data the
block diagram acquires or generates.
Select View»Controls Palette to display the Controls palette and then select controls and indicators from the
Controls palette and place them on the front panel.
Refer to the
labview\examples\general directory for
examples of building front panels
Block Diagram Data Flow
LabVIEW
follows a dataflow model for running VIs. A block diagram node executes when it
receives all required inputs. When a node executes, it produces output data and
passes the data to the next node in the dataflow path. The movement of data
through the nodes determines the execution order of the VIs and functions on
the block diagram.
Visual
Basic, C++, JAVA, and most other text-based programming languages follow a
control flow model of program execution. In control flow, the sequential order
of program elements determines the execution order of a program.
In
LabVIEW, the flow of data rather than the sequential order of commands
determines the execution order of block diagram elements. Therefore, you can
create block diagrams that have simultaneous operations. For example, you can
run two For Loops simultaneously and display the results on the front panel, as
shown in the following block diagram.
LabVIEW is a multitasking and
multithreaded
system, running multiple execution threads and multiple VIs simultaneously.
LabVIEW Tools
The Tools menu
allows you to change the function of the cursor. For example, in one mode the cursor can be
used to change values, and in another it can be used to move and size
items. If you let the mouse cursor hover
over a button on the Tools menu, a description of what that button does will
appear.
Next is the
Function menu. This is available only
when working on the Block Diagram.
This window
contains many menus and sometimes submenus for creating your program. There are a great many functions available
and this tutorial will only touch on a few of them. For more information on what each function
button does, refer to the Simple Help popup that can be enabled from the Help
menu or the more complete online help also available in the Help menu. The complete documentation is also available
online at
For now we will
just create a very simple program. If
you look at the Block Diagram window you will notice that there are two blocks
already present, Numeric and Numeric2.
These are representations of what is on the Front Panel. Remember that Numeric is a Digital Control while
Numeric2 is a Digital Indicator. This
means that Numeric will probably be an input value and Numeric2 will be an
output value. The first thing we will
try to do is add a constant to Numeric and display the result in Numeric2. Go to the Numeric menu on the Function
window, and select the Add block. Place
this block between Numeric and Numeric2 on the Block Diagram window. You might want to use the
Position/Size/Select cursor (the arrow in the Tools menu) to move Numeric and
Numeric2 farther apart
Tools Palette
The Tools palette is
available on the front panel and the block diagram. A tool is a special
operating mode of the mouse cursor. The cursor corresponds to the icon of the tool you select on the palette. Use the
tools to operate and modify front panel and block diagram objects.
If automatic tool selection is
enabled and you move the cursor over objects on the front panel or block
diagram, LabVIEW automatically selects the corresponding tool from the Tools
palette.
Select View»Tools Palette to
display the Tools palette. LabVIEW retains the Tools palette
position so when you restart LabVIEW, the palette appears in the same position.
Tip
Press the <Shift> key and right-click to display a temporary version of
the Tools palette at the location of the cursor.
|
You can disable automatic tool
selection by clicking the Automatic Tool Selection button on the Tools
palette, shown as follows.
When automatic tool selection is
disabled, you can use the <Tab> key to move through the most commonly
used tools in the sequence they appear on the palette.
To use another tool without clicking
to disable automatic tool selection, click the tool you want to use. When you
are finished, press the <Shift-Tab> keys or click the Automatic Tool
Selection button to enable automatic tool selection again.
Function Palette
The Function
Palette contains buttons for functions that are already configured through
expanded DeskTopBinder Lite functions. Using these buttons, you can print
Windows files, preview printouts, convert images, and register scanners for
documents without having to open DeskTopBinder Lite. You can also use these
functions simply by dragging a target file to the button corresponding to the
required function and dropping it there.
1.
On the [Start]
menu, point to [All Programs], [DeskTopBinder],
and then click [Function Palette].
An icon for the Function palette is added to the task
tray displayed at the bottom right of the screen.
2.
Right-click the
new icon that has been added to the task tray, and then click [Properties...].
The [Properties] dialog box
appears.
3.
Click the [Contents] tab, select the [PDF
Direct Print] check box at the center, and then click [OK].
The [Properties] screen
closes and the [PDF Direct Print] icon is
added to the palette.
Front Panel Controls and Indicators
Use the front panel controls and indicators located on the Controls palette to build the front panel. Types of controls and
indicators include numeric controls such as slides and knobs, numeric
indicators such as meters and gauges, graphs, charts, Boolean controls and
indicators such as buttons and switches, strings, paths, arrays, clusters,
listboxes, tree controls, tables, ring controls, enumerated type controls,
containers, and so on.
Styles
of Controls and Indicators
Front panel controls and indicators can appear in modern,
classic, or system style.
Select File»VI Properties and select Editor Options from the Category
pull-down menu to change the style of the control or indicator LabVIEW creates
when you right-click a terminal and select Create»Control or Create»Indicator from
the shortcut menu. Select Tools»Options and select Front Panel from the Category
list to change the style of the control or indicator LabVIEW creates in new,
blank VIs when you right-click a terminal and select Create»Control or Create»Indicator from
the shortcut menu. Note You
cannot customize the appearance of the dialog spin control, slide controls,
progress bars, or scroll bars because the controls and indicators use
platform-specific drawing functions that do not support customization. You also
cannot use Property Nodes and Invoke Nodes to customize the appearance of these
controls and indicators.
Modern
and Classic Controls and Indicators
Many front panel objects have a high-color appearance. Set
the monitor to display at least 16-bit color for optimal appearance of the
objects.
The controls and indicators located on the Modern palette also have corresponding low-color objects. Use the
controls and indicators located on the Classic
palette to create VIs for 256-color and 16-color monitor settings.
System
Controls and Indicators
Use the system controls and indicators located on the System palette in dialog boxes you
create. The system controls and
indicators are designed specifically for use in dialog boxes and include ring
and spin controls, numeric slides, progress bars, scroll bars, listboxes,
tables, string and path controls, tab controls, tree controls, buttons,
checkboxes, radio buttons, and an opaque label that automatically matches the
background color of its parent. These controls differ from those that appear on
the front panel only in terms of appearance. These controls appear in the
colors you have set up for the system.
The system controls change appearance depending on which
platform you run the VI. When you run the VI on a different platform, the
system controls adapt their color and appearance to match the standard dialog
box controls for that platform.
You can find similar controls and indicators on other
palettes in LabVIEW. For example, the Cancel
button located on the System
palette is similar to the Cancel
button located on the Boolean
palette.
Numeric
Displays, Slides, Scroll Bars, Knobs, Dials, and Time Stamps
Use the numeric objects located on the Numeric and Classic Numeric
palettes to create slides, scroll bars, knobs, dials, and numeric displays. The
palette also includes color boxes and a color ramp for setting color values and
time stamps for setting time and date values. Use the numeric objects to enter
and display numeric data.
You can set the representation, data range, and format and precision for numeric objects. Numeric objects accept only certain numeric characters. Tip Expect
users to supply invalid values for numeric controls. Right-click the control
and select Data Entry to
set the control item to coerce invalid values into a desired range. Refer to
the LabVIEW Style
Checklist for more tips on how to maintain
consistent style and quality throughout a VI.
Numeric
Controls and Indicators
Numeric controls and indicators are the simplest way to enter
and display numeric data. You can resize these front panel objects horizontally to accommodate more
digits. Change the value of a numeric control using any of the following ways:
Use the
Operating tool or the Labeling tool to click inside the digital display window
and enter numbers from the keyboard.
Use
the Operating tool to click the increment or decrement arrow buttons of a
numeric control.
Use the
Operating tool or the Labeling tool to place the cursor to the right of the
digit you want to change and press the up or down arrow keys.
When you type a new value into a numeric control or
indicator, the Enter
button appears on the toolbar to remind you that the new value replaces the old
value only when you press the <Enter> key, click outside the digital
display window, or click the Enter
button. While the VI is running, LabVIEW waits until you perform one of these
actions to interpret the new values. For example, while changing a value in the
digital display to 135, you
do not want the VI to receive the values 1 and 13
before 135.
|
Note If the
numeric control or indicator has a format
of engineering or SI notation and does not have a complex representation,
LabVIEW adds any necessary prefixes to the unit string to retain the
floating-point representation.
|
By default, LabVIEW displays and stores numbers like a
calculator. A numeric control or indicator displays up to six digits before
automatically switching to exponential notation. You can configure the number
of digits LabVIEW displays before switching to exponential notation by
right-clicking the numeric object and selecting Display Format from the shortcut menu to display the Display Format page of the Numeric Properties dialog box.
The precision you select affects only the display of the
value. The internal accuracy still depends on the representation.
Slide
Controls and Indicators
Slide controls and indicators are numeric objects with a
scale. The slide controls and indicators include vertical and horizontal
slides, a tank, and a thermometer. Change the value of a slide control using
either of the following ways:
As you change the value, LabVIEW displays the value of the
control in a tip strip. If you drag the slider to a new position and the VI is
running during the change, the control passes intermediate values to the VI,
depending on how often the VI reads the control.
Slide controls or indicators can display more than one value.
Right-click the object and select Add Slider from the shortcut menu to add more sliders. The data type of a control with multiple sliders is a cluster that contains each of the numeric values.
Scroll
Bar Controls and Indicators
Scroll bar controls, similar to slide controls, are numeric objects you can use to scroll data. The scroll
bar controls include vertical and horizontal scroll bars. Change the value of a
scroll bar by using the Operating tool to click or drag the square scroll box
to a new position, by clicking the increment and decrement arrows, or by
clicking the spaces between the scroll box and the arrows.
Rotary
Controls and Indicators
The rotary controls and indicators include knobs, dials,
gauges, and meters. The rotary objects operate similarly to the slide controls
and indicators because they are numeric objects with a scale. Change the value
of a rotary control using either of the following ways:
As you change the value, LabVIEW displays the value of the
control in a tip strip.
Rotary controls or indicators can display more than one
value. Right-click the object and select Add Needle to add new needles. The data type of a control with multiple needles is a cluster that contains each of the numeric values.
Time
Stamp Control and Indicator
Use the time stamp control and indicator to send and retrieve
a time and date value to or from the block diagram. You can change the value of
the time stamp control using any of the following ways:
Right-click the
control and select Display Format from the shortcut menu.
Right-click
the control and select Data Operations»Set Time and Date from
the shortcut menu to display the Set Time and Date
dialog box.
Right-click the
control and select Data Operations»Set Time to Now from the
shortcut menu.
Color Boxes
A color box displays a color that corresponds to a specified
value. For example, you can use color boxes to indicate different conditions,
such as out-of-range values. The color value is expressed as a hexadecimal
number with the form RRGGBB. The first two digits control the red color value.
The second two digits control the green color value. The last two digits
control the blue color value.
Set the color of the color box by clicking it with the
Operating or Coloring tool to display the color picker.
Color Ramps
A color ramp uses color to display its numeric value. You
configure a color ramp that consists of at least two arbitrary markers, each
with a numeric value and a corresponding display color. As the input value
changes, the color displayed changes to the color that corresponds to that
value. Color ramps are useful for visually indicating data ranges, such as a
warning range for when a gauge reaches dangerous values. For example, you can
use a color ramp to set the color scale for intensity graphs and
charts.
Right-click the color ramp and use the shortcut menu items to
customize the appearance, size, colors, and number of colors.
You also can add a color ramp to any knob, dial, or gauge on
the front panel. Meters have a visible color ramp by default.
Graphs and Charts
Use the graph controls and indicators on the Graph and Classic Graph
palettes to plot numeric data in graph or chart form. Use the picture indicator to create, modify, and view graphics in LabVIEW. Use the 3D picture control to display graphical representations of 3D objects.
Buttons,
Switches, Lights, and Checkboxes
Use the Boolean controls and indicators located on the Boolean and Classic Boolean
palettes to create buttons, switches, and lights. Use Boolean controls and
indicators to enter and display Boolean (TRUE/FALSE) values. For example, if you are
monitoring the temperature of an experiment, you can place a Boolean warning
light on the front panel to indicate when the temperature exceeds a certain
level.
Boolean controls have six types of mechanical action that
allow you to customize Boolean objects to create front panels that more closely
resemble the behavior of physical instruments. Use the shortcut menu to
customize the appearance of Boolean objects and how they behave when you click
them.
Radio Buttons Controls
Use the radio buttons control to give users a list of items
from which they can select only one item at a time. If you want to give users
the option to select none or one item, right-click the control and select Allow No Selection from the shortcut menu to place a checkmark next to the menu
item.
Because the data type of a radio buttons control is an enumerated type, you can use the radio buttons control to select the cases
of a Case structure.
You cannot right-click Boolean controls in the radio buttons
control and perform data operations, such as setting the default value.
Refer to the following VIs for examples of using a radio
buttons control:
Radio Buttons
Control VI: labview\examples\general\controls\booleans.llb
Radio Buttons
With Event Structure VI: labview\examples\general\controls\booleans.llb
Mixed Checkboxes
Use a mixed checkbox to display a TRUE, FALSE, or MIXED
value. For example, use a mixed checkbox if you want to display a set of
Boolean values in a single indicator, where that set of Boolean values are
either all TRUE, all FALSE, or a combination of TRUE and FALSE, called MIXED.
Use the mixed checkbox as a control to simultaneously change a set of Boolean
values to either a TRUE or FALSE value.
Although the mixed checkbox is an enumerated type control,
you can configure the
control similarly to a Boolean control.
To disable the ability to set the MIXED value of a mixed checkbox
interactively, right-click the control and select Allow Mixed from the shortcut menu to remove the checkmark next to the
menu item. When you disable Allow Mixed, LabVIEW can assign the value of the mixed checkbox as
MIXED, but you cannot operate to MIXED by clicking on it.
Running vis
This document contains the LabVIEW 8.5 Run-Time Engine. This
Run-Time Engine must be installed on any Windows system where you plan to run
executables that you build with the LabVIEW Application Builder. Version 8.5 of
the Run-Time Engine may be used only to run executables that were built with
LabVIEW 8.5
Additionally, the Run-Time Engine allows your browser to
display VIs that are embedded in Web pages.
If you were attempting to view a VI through a browser and
you were directed to this site by your Web browser, the VI will display
correctly after you install either Run-Time Engine.
There are two downloads that are available. You only need to
install one of them.
·
LabVIEW
8.5 Run-Time Engine (Standard) gives full support for executables. This version will
support all executables built with LabVIEW as well as allow viewing of Remote
Front Panels in web browsers. It includes support for DataSocket, Variable
Engine and NI-USI. This version can be deployed using an installer created with
Application Builder. Download LabVIEW85RuntimeEngineFull.exe to install this
version.
·
LabVIEW
8.5 Run-Time Engine (Web Browser Only) is a smaller download intended for viewing Remote Front
Panels in web pages. It does not contain the full run-time engine, but will
allow some executables to run. This version can not be deployed. Download
LVRunTimeEng.exe to install this version.
No comments:
Post a Comment