0% found this document useful (0 votes)
34 views

P6 Tutorial LABVIEW

The document provides an introduction to creating virtual instruments in LabVIEW. It discusses how LabVIEW programs are called virtual instruments and how they imitate physical instruments. It then guides the user through creating a simple VI that generates and displays a signal on a graph, including adding controls and changing the signal type.

Uploaded by

Ivan Osta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

P6 Tutorial LABVIEW

The document provides an introduction to creating virtual instruments in LabVIEW. It discusses how LabVIEW programs are called virtual instruments and how they imitate physical instruments. It then guides the user through creating a simple VI that generates and displays a signal on a graph, including adding controls and changing the signal type.

Uploaded by

Ivan Osta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Getting Started with LabVIEW

1
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 well as tools
to help you troubleshoot your code.

In LabVIEW, you build a user interface, or front panel, with controls and
indicators. Controls are knobs, push buttons, dials, and other input devices.
Indicators are graphs, LEDs, and other 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.

Use LabVIEW to communicate with hardware such as data acquisition,


vision, and motion control devices and GPIB, PXI, VXI, RS-232, and
RS-485 instruments.

Building a Virtual Instrument


In the following exercises, you will build a VI that generates a signal and
displays that signal in a graph. When you complete the exercises, the front
panel of the VI will look similar to the front panel in Figure 1-1.

You can complete the exercises in approximately 40 minutes.

© National Instruments Corporation 1-1 Getting Started with LabVIEW


Chapter 1 Getting Started with LabVIEW Virtual Instruments

Figure 1-1. Front Panel for the Acquiring a Signal VI

Opening a New VI from a Template


LabVIEW provides templates containing information from which you can
build your VI. These templates help you get started with LabVIEW.
Complete the following steps to create a VI that generates a signal and
displays it on the front panel.
1. Launch LabVIEW.
2. In the LabVIEW dialog box, shown in Figure 1-2, click the New
button to display the New dialog box.

Figure 1-2. LabVIEW Dialog Box

Getting Started with LabVIEW 1-2 ni.com


Chapter 1 Getting Started with LabVIEW Virtual Instruments

3. Select VI from Template»Tutorial (Getting Started)»Generate


and Display in the Create new list. This template VI generates and
displays a signal.
Notice that previews of the template VI appear in the Front panel
preview and the Block diagram preview sections. Figure 1-3 shows
the New dialog box and the Generate and Display template VI.

Figure 1-3. New Dialog Box

4. Click the OK button to open the template. You also can double-click
the name of the template VI in the Create new list to open the
template.

© National Instruments Corporation 1-3 Getting Started with LabVIEW


Chapter 1 Getting Started with LabVIEW Virtual Instruments

5. Examine the front panel of the VI.


The user interface, or front panel, appears with a gray background and
includes controls and indicators. The title bar of the front panel
indicates that this window is the front panel for the Generate and
Display VI.

Note [V.I: Front Panel (user interface) - Block Diagram (programming)]


If the front panel is not visible, you can display the front panel by selecting
Window»Show Front Panel.

6. Examine the block diagram of the VI.


The block diagram appears with a white background and includes VIs
and structures that control the front panel objects. The title bar of the
block diagram indicates that this window is the block diagram for the
Generate and Display VI.

NoteIf the block diagram is not visible, you can display the block diagram by selecting
Window»Show Block Diagram.

7. In the front panel toolbar, click the Run button, shown at left.
Notice that a sine wave appears on the graph.
8. Stop the VI by clicking the STOP button, shown at left, on the front
panel.

Adding a Control to the Front Panel


Controls on the front panel simulate the input devices on a physical
instrument and supply data to the block diagram of the VI. Many physical
instruments have knobs you can turn to change an input value. Complete
the following steps to add a knob control to the front panel.

Tip Throughout these exercises, you can undo recent edits by selecting Edit»Undo or
pressing the <Ctrl-Z> keys.

1. If the Controls palette, shown in Figure 1-4, is not visible on the front
panel, select Window»Show Controls Palette to display it.

Getting Started with LabVIEW 1-4 ni.com


Chapter 1 Getting Started with LabVIEW Virtual Instruments

Figure 1-4. Controls Palette

2. Move the cursor over the icons on the Controls palette to locate the
Numeric Controls palette.
Notice that when you move the cursor over icons on the Controls
palette, the name of that subpalette appears in the gray space above all
the icons on the palette. When you idle the cursor over any icon on any
palette, the full name of the subpalette, control, or indicator appears.
3. Click the Numeric Controls icon to access the Numeric Controls
palette.
4. Select the knob control on the Numeric Controls palette and place it
on the front panel to the left of the waveform graph.
You will use this knob in a later exercise to control the amplitude of a
signal.
5. Select File»Save As and save this VI as Acquiring a Signal.vi
to an easily accessible location [en C:\TEMP\].

Changing the Signal Type


The block diagram has a blue icon labeled Simulate Signal. This icon
represents the Simulate Signal Express VI. The Simulate Signal Express VI
simulates a sine wave by default. Complete the following steps to change
this signal to a sawtooth wave.
1. Display the block diagram by selecting Window»Show Block
Diagram or by clicking the block diagram.
Notice the Simulate Signal Express VI, shown at left. An Express VI
is a component of the block diagram that you can configure to perform
common measurement tasks. The Simulate Signal Express VI
simulates a signal based on the configuration that you specify.
2. Right-click the Simulate Signal Express VI and select Properties from
the shortcut menu to display the Configure Simulate Signal
dialog box.

© National Instruments Corporation 1-5 Getting Started with LabVIEW


Chapter 1 Getting Started with LabVIEW Virtual Instruments

3. Select Sawtooth [Diente de Sierra] from the Signal type pull-down menu.
Notice that the waveform on the graph in the Result Preview section
changes to a sawtooth wave. The Configure Simulate Signal dialog
box should appear similar to Figure 1-5.

Figure 1-5. Configure Simulate Signal Dialog Box

4. Click the OK button to apply the current configuration and close the
Configure Simulate Signal dialog box.
5. Move the cursor over the down arrows at the bottom of the Simulate
Signal Express VI.
6. When a double-headed arrow appears, shown at left, click and drag the
border of the Express VI until the Amplitude input appears.
Notice how you expanded the Simulate Signal Express VI to display a
new input. Because the Amplitude input appears on the block
diagram, you can configure the amplitude of the sawtooth wave on the
block diagram.
In Figure 1-5, notice how Amplitude is an option in the Configure
Simulate Signal dialog box. When inputs, such as Amplitude, appear
on the block diagram and in the configuration dialog box, you can
configure the inputs in either location.

Getting Started with LabVIEW 1-6 ni.com


Chapter 1 Getting Started with LabVIEW Virtual Instruments

Wiring Objects on the Block Diagram


To use the knob control to change the amplitude of the signal, you must
connect the two objects on the block diagram. Complete the following steps
to wire the knob to the Amplitude input on the Simulate Signal Express VI.
1. Move the cursor over the Knob terminal, shown at left, until the
Positioning tool appears.
Notice how the cursor becomes an arrow, or the Positioning tool,
shown at left. Use the Positioning tool to select, position, and resize
objects.
2. Click the Knob terminal to select it, then drag the terminal to the left
of the Simulate Signal Express VI. Make sure the Knob terminal is
inside the loop, shown at left.
The terminals are representations of front panel controls and
indicators. Terminals are entry and exit ports that exchange
information between the front panel and block diagram.
3. Deselect the Knob terminal by clicking a blank space on the block
diagram.
4. Move the cursor over the arrow of the Knob terminal, shown at left.
Notice how the cursor becomes a wire spool, or the Wiring tool, shown
at left. Use the Wiring tool to wire objects together on the block
diagram.

Note The cursor does not switch to another tool while an object is selected.

5. When the Wiring tool appears, click the arrow and then click the
Amplitude input of the Simulate Signal Express VI, shown at left, to
wire the two objects together.
Notice that a wire appears and connects the two objects. Data flows
along this wire from the terminal to the Express VI.
6. Select File»Save to save this VI.

© National Instruments Corporation 1-7 Getting Started with LabVIEW


Chapter 1 Getting Started with LabVIEW Virtual Instruments

Running the VI
Running a VI executes your solution. Complete the following steps to run
the Acquiring a Signal VI.
1. Display the front panel by selecting Window»Show Front Panel or
by clicking the front panel.

Tip Press the <Ctrl-E> keys to switch from the front panel to the block diagram or from
the block diagram to the front panel.

2. Click the Run button.


3. Move the cursor over the knob control.
Notice how the cursor becomes a hand, or the Operating tool, shown at
left. Use the Operating tool to change the value of a control or select
the text within a control.
4. Using the Operating tool, turn the knob to adjust the amplitude of the
sawtooth wave.
Notice how the amplitude of the sawtooth wave changes as you turn
the knob. Also notice that the y-axis on the graph autoscales to account
for the change in amplitude.
To indicate that the VI is running, the Run button changes to a
darkened arrow, shown at left. You cannot edit the front panel or block
diagram while the VI runs.
5. Click the STOP button, shown at left, to stop the VI.

Note Although the Abort Execution button looks like a stop button, the Abort
Execution button does not always properly close the VI. National Instruments
recommends stopping your VIs using the STOP button on the front panel. Use the Abort
Execution button only when errors prevent you from terminating the application using the
STOP button.

Getting Started with LabVIEW 1-8 ni.com

You might also like