Anda di halaman 1dari 55

Exercise 1: Create the User Interface for the Filter Test

Objective: Start building your test application by adding front panel controls and indicators of a new
LabVIEW VI. This exercise is the first step towards building an application that will test a filter. The
completed application (Exercise 3) will use an arbitrary waveform generator and digitizer (oscilloscope)
to perform a frequency sweep test. The following figure shows the results of this exercise.

Figure 1 Completed Exercise 1

1. Launch LabVIEW by selecting Start All Programs National Instruments LabVIEW 2011.
2. Select File New VI from the menu on the welcome screen.
3. To begin designing the front panel, you will create five numeric controls. These controls will contain
the parameters of the frequency sweep, including the number of steps in the sweep, the start and stop
frequencies, and the start and stop limits.
a. Right-click on the front panel and select Numeric Numeric Control and place the numeric
control on the front panel.

Tip: The Controls Palette provides access to many useful front panel controls such as input
boxes, command buttons, and gauges.
b. Name the numeric control Number of Steps.
c. Enter a value of 15.

National Instruments Corporation

1-1

Hands-On Seminar

d. Repeat the previous steps (a c) for four more numeric controls. Use the names and values in
the following chart.
Tip: Alternatively, you can make copies of the control (or any other object) if you click on the
control, press and hold the <Ctrl> key, and then drag the control to a new location.
Control

Value

Start Frequency

1000

Stop Frequency

100,000

Start Limit

1.05

Stop Limit

1.05

e. Arrange the controls to looks similar to the figure below.

Figure 2 Numeric Controls

f.

Save the values of the controls by selecting Edit Make Current Values Default.

Hands-On Seminar

1-2

ni.com

4. Next you will create a Boolean indicator that displays the Pass/Fail result of the test.
a. Right-click on the front panel and select Boolean Square LED to create a Boolean.

b. Name this indicator Pass.


c. Right-click on the LED and select Properties.
d. From the resulting dialog, select the Appearance tab.
e. Under the Label section, uncheck the Visible checkbox.
f.

Enable the Show Boolean Text section.

Type in PASS as the On text.

Type in FAIL as the Off text.

Change the Off color to a shade of red.

Figure 3 Pass Button Properties

g. Click OK to exit.

National Instruments Corporation

1-3

Hands-On Seminar

5. Place a graph display on the front panel to display the frequency sweep.
a. Right-click on the front panel and select Graph Waveform Graph.

Important: Make sure to select the Waveform Graph and not the Waveform Chart. They are
sometimes confused because the icons look similar, but the waveform Graph has a green grid
on the display.
b. Change the label of the graph to read Filter Response.
c. Right-click on the Waveform Graph and select Properties.
d. From the resulting dialog, select the Scales tab.
e. Choose Time (X-Axis) from the first drop down menu in the Scales tab. Uncheck Autoscale
and set the Minimum and Maximum input fields to be 0 and 0.001, respectively. The
resulting Properties dialog should look like the screenshot below.

Figure 4 Filter Response Graph Properties for X-axis

f.

Now, choose Amplitude (Y-Axis) in the first drop down menu on this tab.

g. Uncheck Autoscale.
h. Set the Minimum and Maximum input fields to be -1.1 and 1.1, respectively.
i.

Finally, select the Format and Precision tab.

j.

Choose Time (X-Axis) in the first drop down menu and make sure that SI Notation is
selected.

k. Click OK to save your changes.

Hands-On Seminar

1-4

ni.com

6. Arrange the controls and indicators so that the front panel looks similar to the image below.

Figure 5 Front Panel

National Instruments Corporation

1-5

Hands-On Seminar

7. Although you will not use the block diagram yet, switch to the block diagram to see the terminals of
the controls and indicators that you have added to the VI.
a. To switch to the block diagram, select Window Show Block Diagram.
b. Re-arrange the terminals so that they are similar to the figure below. The terminals on the left
side are your controls, while the terminals on the right side are your indicators.
Tip: Controls are front panel objects for entering data to a VI interactively or to a subVI
programmatically, such as a knob, push button, or dial. Indicators are front panel objects that
display outputs, such as a graph or LED.
c. If any terminal is missing a label, such as the Boolean indicator, right-click on it and select
Visible Items Label.

Figure 6 Block Diagram

8. Select File Save and save your VI as Ex-1 FilterTest.vi in the Exercises folder.
End of Exercise 1

Hands-On Seminar

1-6

ni.com

Exercise 1a (Optional): Simulate and display a waveform


In this optional exercise, you will create a simple LabVIEW VI that simulates an analog signal and plots it
on a waveform graph. The VI will test the input values against a user-specified limit and light an LED if the
input value exceeds that limit.

9. If you have not closed your VI from the previous exercise, click File New from either the Front
Panel or Block Diagram to launch a wizard to create new VIs, projects and more. If you have closed
your earlier VI, you should have been returned to the LabVIEW splash screen. Click New to launch
the same wizard.

National Instruments Corporation

1-7

Hands-On Seminar

10. Select VI From Template Tutorial (Getting Started) Generate and Display and click OK.

Hands-On Seminar

1-8

ni.com

11. Examine the Front Panel and Block Diagram of this template VI. The Front Panel contains a
Waveform Chart and a STOP button as shown in the following figure.

The Block Diagram contains a Simulate Signal VI, which is currently configured to simulate a sine
wave and plot it to the chart.

National Instruments Corporation

1-9

Hands-On Seminar

12. Switch back to the Front Panel by pressing <Ctrl-E>. Since the Run button (the white arrow in the top
left corner) is solid, you can run this VI as it is. Click the Run button and examine the operation of the
VI. When you are finished, click the STOP button on the Front Panel to stop running the VI.
Note: As you will see later in the exercise, when the Run button in the upper left corner of both the
Front Panel and the Block Diagram changes from a solid white arrow, to a broken gray arrow, this
new icon indicates that the VI is currently not executable.
13. Now we can add some functionality to this basic VI. We will modify the VI to flash an alarm whenever
the signal value is above a certain level. Open the Controls palette (if it is not open already) by rightclicking the Front Panel window. A small pushpin icon in the upper left corner of this palette appears.
Click this pushpin to force the palette to remain on your screen.

14. Click the Numeric Controls palette, and select a Vertical Pointer Slide to be placed on the Front
Panel. To do this, click the Vertical Pointer Slide and drag it to the Front Panel. Click once to
place it.

Hands-On Seminar

1-10

ni.com

15. Click the Express menu item on the Controls palette to return to the Express Controls Palette. Click
the LEDs subpalette, and place a Round LED on the Front Panel.

16. Right-click the Vertical Pointer Slide and select Properties. A property page will appear. Examine
the different properties that you can modify. Make the following changes on the Appearance tab and
click OK to apply the changes.
Label: Limit
Slider 1: Check Show digital display(s)

National Instruments Corporation

1-11

Hands-On Seminar

17. Right-click the Round LED labeled Boolean, and select Properties. Examine the different properties
that can be modified. On the Appearance tab, change the label from Boolean to Alarm. Click OK to
apply your change. Move the objects on the Front Panel so it resembles the following.

18. Switch to the Block Diagram by pressing <Ctrl-E>. Double-click the Simulate Signal Express VI to
bring up its properties window. Examine the different properties you can modify. Change the
Amplitude of the signal to 10. Click OK to apply this change and to close the properties window.

Hands-On Seminar

1-12

ni.com

19. Bring up the functions palette by right-clicking the Block Diagram. Select Arithmetic & Comparison
Comparison and place the Comparison Express VI on the diagram.

Note

Finding functions can be challenging in any language. The Search function helps you quickly find and
place LabVIEW front panel and block diagram objects using predictive text. With the Functions Palette
open, click Search to open the search window.

National Instruments Corporation

1-13

Hands-On Seminar

Type comparison into the Search window. Note that the list of functions shown in the window is instantly
filtered based on the text that you type. Highlight the correct function and left-click on the block diagram to
place it.
When you place the Comparison Express VI on the Block Diagram, a dialog box appears that lets you
configure what type of comparison you will be doing. Make the following selections, then click OK to
apply these changes and to close the dialog box.
Compare Condition: Greater
Comparison Inputs: Compare to second input

Hands-On Seminar

1-14

ni.com

20. You can connect Controls, Functions, and Indicators on the Block Diagram by pointing to an object
and clicking it when the cursor changes to a spool of wire. You can then move the cursor to the object
you want to connect it to and click again. Connect the Limit control to the Alarm indicator.

Note: The Run button in the upper left corner of both the Front Panel and the Block Diagram has
changed from a solid white arrow, to a broken gray arrow. This new icon indicates that the VI is
currently not executable. If you click the Run button when it is solid and white, it runs the VI. Clicking
it when it is broken and gray brings up a dialog box that will help you debug the VI.

21. Click the Run button now. The resulting dialog box shows that, in this case, the error results from
connecting terminals of two different types. Since the Limit control is a Numeric type and the Alarm
indicator is a Boolean type, we cannot wire these two terminals together. Highlight the error by
clicking it, and then click Show Error. LabVIEW will highlight the location of the error.

22. Notice that the wire between Limit and Alarm is dashed and a red is displayed on it.

To delete this broken wire, press <Ctrl-B>. This keyboard shortcut removes all broken wires from the
Block Diagram.

23. Make your Block Diagram resemble the following image by completing the following steps.

Wire the Limit control to the Operand 2 input of the Comparison function.
Connect the wire between the Simulate Signals block and the Waveform Graph to the
Operand 1 input of the Comparison block.
Wire the Result output of the Comparison block to the Alarm indicator.

National Instruments Corporation

1-15

Hands-On Seminar

Your Block Diagram should now resemble the following:

24. Switch to the Front Panel by pressing <Ctrl-E>.


25. Save the VI in the Exercises folder by using the File menu and name it Ex-1
SimulateWaveform.vi.
26. Run the VI. While running the VI, you can change the Limit value. Also notice that when a data point
received from the Simulate Signal VI is greater than the Limit value, the Alarm indicator lights up.
27. While the VI is still running, switch to the Block Diagram by pressing <Ctrl-E>. Enable highlight
execution by clicking the light bulb on the tool bar.

This will allow you to see the flow of data through your program.
28. When you are finished, stop the VI by clicking the Stop button on the Front Panel.

End of Exercise 1

Hands-On Seminar

1-16

ni.com

Exercise 2: Add Instrument I/O and Sweep to the Filter Test


Objective: Building upon the previous exercise, you will add Express VIs that will create a waveform,
generate the waveform using an arbitrary waveform generator, and then acquire the waveform using a
digitizer (oscilloscope). Next, you will add a For Loop to perform a frequency sweep test. LabVIEW
Express VIs are easy-to-use, interactive VIs for frequently built test and measurement applications. With
Express VIs, you get up and running quickly by configuring your application with just a few mouse
clicks. The following figure shows the results of this exercise.

Figure 7 Completed Exercise 2

Hardware: For this exercise,


1/ Connect Oscilloscope CH 0 (positive probe) to AO 0 (Arbitrary waveform generator), as pictured
below

National Instruments Corporation

1-17

Hands-On Seminar

Figure 2 Signal Connections for Exercise 2

Exercise 2A: Generating a waveform with the Arbitrary Waveform Generator


1. Use the following steps to make a working copy of the VI that you created in the previous exercise.
a. If you closed your VI earlier, open Ex-1 FilterTest.vi from the Exercises folder.
b. Select File Save As, select Substitute copy for original, and click Continue.
c. Name the VI as Ex-2 FilterTest.vi and click OK.
2. Now you will begin to add the Express VIs to create, generate, and acquire the sine wave used for the
frequency sweep. First, you need to create the sine wave.
a. To begin designing the block diagram, navigate to Window Show Block Diagram.
b. Right-click on the block diagram, and select Express Input Simulate Signal.
Note: Be sure to click the icon above the name Simulate Sig, as pictured below.

c. Place the Simulate Signal Express VI on the block diagram.


d. On the resulting Configure Simulate Signal configuration dialog, configure the values as
shown in the figure below. All of the other values are left on their default setting.

Hands-On Seminar

Configuration Option

Value

Samples per second (Hz)

2,800,000

1-18

ni.com

Figure 3 Configure Simulate Signal

e. Click OK to save your changes.


3. On the block diagram, resize the Simulate Signal VI so that the terminal name Sine is no longer
visible (select bottom border and drag up).

Notice that the blue output terminal for the Sine signal moves to the top right of the VI.

4. Next, you will need to add a VI to generate a waveform using an arbitrary waveform generator.
a. Right-click on the block diagram, and select Measurement I/O NI ELVISmx NI
ELVISmx Arbitrary Waveform Generator Express VI.

National Instruments Corporation

1-19

Hands-On Seminar

b. Place the NI ELVISmx Arbitrary Waveform Generator Express VI to the right of the
Simulate Signal Express VI.
c. On the resulting configuration dialog, select corresponding ELVIS device and keep all other
values on their default setting.

Figure 4 Configure NI ELVISmx Arbitrary Waveform Generator Express VI

d. Click OK.

Hands-On Seminar

1-20

ni.com

5. Next, you will need to initialize the arbitrary waveform generator with the output of the Simulate
Signal Express VI, and pass along any errors.
a. Wire the Sine output terminal of the Simulate Signal Express VI to the Channel 0 Signal In
input terminal of the NI ELVISmx Arbitrary Waveform Generator Express VI.
b. Wire the error out output terminal of the Simulate Signal Express VI to the error in input
terminal of the NI ELVISmx Arbitrary Waveform Generator Express VI.
Tip: The Simulate Signal and NI ELVISmx Arbitrary Waveform Generator Express VIs on the
block diagram are called nodes. A node is a program execution element, analogous to statements,
operators, functions, and subroutines in text-based programming languages.
Tip: The NI ELVISmx Arbitrary Waveform Generator Express VI will execute after the Simulate
Signal Express VI because of data dependency. This means a node cannot execute until it
receives data from another node. Therefore, the arbitrary waveform generator will not start
generation until the simulated waveform has been created.

Figure 5 Completed Exercise 2a

Exercise 2B: Acquiring a waveform with the Digitizer (Oscilloscope)


1. Now you will acquire the output of the arbitrary waveform generator with the digitizer.
a. Right-click on the block diagram, and select Measurement I/O NI ELVISmx NI
ELVISmx Oscilloscope Express VI.

National Instruments Corporation

1-21

Hands-On Seminar

b. Place the NI ELVISmx Oscilloscope Express VI to the right of NI ELVISmx Arbitrary


Waveform Generator Express VI.

Figure 6 Add NI ELVISmx Oscilloscope Express VI

c. On the resulting configuration dialog, select the corresponding ELVIS device and configure the
values as shown in the figure below. All of the other values are left on their default setting.

Hands-On Seminar

Configuration Option

Value

Channel 0 Enable

On

Channel 1 Enable

Off

Sample Rate (S/s)

1.25M

Record length

1.25k

Range (V)

1-22

ni.com

Figure 7 Configure NI ELVISmx Oscilloscope Express VI

National Instruments Corporation

1-23

Hands-On Seminar

d. Select the Trigger tab.


e. On the resulting configuration dialog, configure the values as shown in the figure below. All
of the other values are left on their default setting.
Configuration Option

Value

Type

Edge

Source

Channel 0 Source

Slope

Positive

Level (v)

Figure 8 Configure NI ELVISmx Oscilloscope Express VI

Important: The trigger source must be set to Channel 0, or the trigger condition will never be
met and no signal will be acquired.
f.

Click OK to save your changes.

2. Now you will need to connect the error output from the NI ELVISmx Arbitrary Waveform Generator
Express VI to NI ELVISmx Oscilloscope Express VI. Wire the error out output terminal of the NI
ELVISmx Arbitrary Waveform Generator Express VI to the error in input terminal of the NI
ELVISmx Oscilloscope Express VI.

Hands-On Seminar

1-24

ni.com

3. Next, you will pass the acquired waveform to the front panel display. Wire the Channel 0 out output
terminal of the NI ELVISmx Oscilloscope Express VI to the Waveform Graph control called Filter
Response.
4. Finally, wire the output of Start Frequency control to the Frequency input of the Simulate Signal
Express VI so that you can interactively change the output frequency while the program executes.
5. The block diagram should resemble the image below. Check to make sure that your VI is free from
errors by checking that the Run arrow is not broken.

Figure 9 Completed Exercise 2b

If the Run arrow is broken


, indicating an error, click on it to see the list of errors. If you double-click
on the error in the resulting Error List window, a moving dashed outline called a marquee will highlight
the error on the block diagram so that you can find and fix it.
6. Save your VI.

National Instruments Corporation

1-25

Hands-On Seminar

7. Click the Run button to verify that the VI is working properly. A sine wave should be displayed.
Tip: You may have noticed that the start of the waveform is a falling edge rather than a rising edge. This
is because the reference position for the NI-Scope Express VI trigger is set to 50% (Figure 8). In this case,
the rising edge trigger occurs at 500uS.

Figure 10 Run VI

8. Return to the block diagram and click on the Highlight Execution


button. This turns on a
debugging technique that animates VI execution to illustrate the data flow.
9. Click on the Run button and see how the data flows from terminal to terminal.
10. Click on Highlight Execution button again to turn it off.

Hands-On Seminar

1-26

ni.com

11. Return to the front panel. Click the Run Continuously


button and adjust the Start Frequency
value using the up/down arrows on the control to vary the frequency that is generated. If the
frequency is too low or high, an error will result. The other numeric controls and the Pass LED are
not wired yet and therefore do not have any affect on the VI yet.
Tip: You can adjust the frequency in steps of a thousand by using the text tool to highlight the number in
the thousandths place (on the Start Frequency control) and then using the up/down arrows to change the
value as pictured below.
Tip: The higher frequency signals may look aliased, but this is due to the small size of the graph display.
If you right-click on the graph and select Visible Terminal Graph Palette, you can use the zoom tools
to zoom in on the waveform to see the detail.

Figure 11 Continuous Run

12. Click the Abort

button when finished.

Exercise 2C: Create Frequency Sweep


You will now add code so that the VI will run a frequency sweep. In this part of the exercise, you will add
the functions and structures necessary to accomplish this task.
1. To create a frequency sweep, you will first need to create a For Loop.

National Instruments Corporation

1-27

Hands-On Seminar

a. Right-click on the block diagram and select to Structures For Loop.

b. Click and drag to place the For Loop around the Express VIs and the two indicators as
pictured below.

Figure 12 Adding the For Loop

Tip: The objects inside the loop will execute every time the loop repeats. The count terminal
is used to determine how many times the For Loop iterates.
Tip: LabVIEW creates a tunnel where the wire crosses the loop boundary. A tunnel allows data
to flow in and out of loops and structures.

Figure 13 Loop Tunnel

Hands-On Seminar

1-28

ni.com

2. The Number of Steps control will determine the number of iterations of the For Loop.
a. Wire the Number of Steps control to the count terminal at the top left of the For Loop.
b. Right-click on the Number of Steps control and select Representation
I32. This will change the data type of the control to an integer.
Tip: By default, a Numeric Control is a double-precision floating-point
number (64 bits in size and can represent up to a 15 digit decimal number).
This format works well in most cases, but in this case an integer type can be
used since the loop count must be a whole number.
Tip: Notice that the color of the Number of Steps control changed from
orange to blue. LabVIEW uses colors and wires thickness to differentiate between different data
types. If you select Help Show Context Help, and move your cursor over a wire, you will see
the description of the data that the wire contains. You can view help for nodes on your block
diagram as well.

Figure 14 Loop Count Control

Now that the loop is in place and will execute the number of times determined by the Number of Steps
control, you need to add code so to that each time the loop iterates, a higher frequency will be generated.
For the first iteration of the loop, the output frequency will be equal to the Start Frequency. However,
subsequent loop iterations will increase the frequency by a set amount, which well call the Frequency
Step. To determine the value of the Frequency Step, use the following equation:
Stop Frequency Start Frequency
Frequency Step =
Number of Steps 1

National Instruments Corporation

1-29

Hands-On Seminar

3. You will use the Start Frequency, Stop Frequency, Number of Steps, and add some Numeric
functions to calculate the value of the Frequency Step.
a. In this step, you will calculate the numerator of the equation, Stop Frequency Start
Frequency.
i. Right-click on the block diagram and select Numeric Subtract. Place the Subtract
function to the right of the Stop Frequency control (outside of the For Loop).
ii. Wire the Stop Frequency control to the first (top) input terminal of the Subtract
function.
iii. Wire the Start Frequency control to the second (bottom) input terminal of the
Subtract function.

Figure 15 Stop Frequency minus Start Frequency

b. Next, you will calculate the denominator, Number of Steps 1.


i. Right-click on the block diagram and select Numeric Decrement. Place the
Decrement function above the Subtract function (outside of the For Loop).
ii. Wire the Number of Steps control to the input terminal of the Decrement VI.

Figure 16 Number of Steps minus 1

c. Finally, you will calculate the result of the numerator divided by the denominator.
i. Right-click on the block diagram and select Numeric Divide. Place the Divide
function to the right of the Subtract function (outside of the For Loop).
ii. Wire the output of the Subtract function to the first (top) input terminal of the
Divide function.
iii. Wire the output of the Decrement function to the second (bottom) input terminal of
the Divide function

Hands-On Seminar

1-30

ni.com

Figure 17 Completed Equation

Stop Frequency Start Frequency


Frequency Step =
Number of Steps 1
Tip: You may have noticed that a small dot appeared on the Divide function when you wired to the
Number of Steps control. It is called a coercion dot, and it alerts you that you wired two different numeric
data types together. The dot means that LabVIEW converted the value passed into the node to a different
representation. For example, the Divide function expects two double-precision, floating-point inputs.
Since one of those inputs is an integer, a coercion dot appears on the Divide function.
The Frequency Step is ready to be used in the For Loop. For each loop, the frequency used in the
following loop will be calculated by adding the current frequency to the Frequency Step. This calculation
will make the frequency sweep as the loop iterates.
Next Loop Frequency = Current Loop Frequency + Frequency Step
4. You will use the Start Frequency, Frequency Step, Add function, and For Loop to calculate the value
of the next loops output frequency.
a. Right-click on the block diagram and select Numeric Add. Place the Add function below
the NI-SCOPE Express VI (inside of the For Loop).
b. Wire the output of the Divide function (which is outside the For Loop) to the top input
terminal of the Add function (inside the For Loop).

Figure 18 Add function

National Instruments Corporation

1-31

Hands-On Seminar

c. Right-click on the Loop tunnel created by the wire from the Start Frequency control and
select Replace with Shift Register.

Figure 19 Create Shift Register for Frequency value

Tip: A shift register is used to transfer values from one loop iteration to the next. In this case, the
first time the loop runs, it will use the frequency value of the Start Frequency control. But the
next loop will use the value transferred from the previous loop.
d. Wire the Start Frequency shift register to the bottom input of the Add function. This is
easier to do if you start the wire at the Add function.
e. Wire the output of the Add function to the shift register on the right side of the For Loop.

Figure 20 Completed Frequency Sweep

Using the default values that you entered in Exercise 1, the VI will generate 15 (Number of Steps)
different frequencies, starting at the Start Frequency (1000Hz), ending at the Stop Frequency
(100,000Hz).

Hands-On Seminar

1-32

ni.com

5. Switch to the front panel. Check to make sure that your VI is free from errors by checking that the
Run arrow is not broken. If the Run arrow is broken
of errors.

, indicating an error, click on it to see the list

6. Run the VI.

Figure 21 Run the Frequency Sweep

7. Return to the block diagram and click on the Highlight Execution

button.

8. Click on the Run button and see how the data flows from terminal to terminal and between loop
iterations.
9. Click on Highlight Execution button again to turn it off.
10. Return to the front panel and run the VI a couple times with different values for the Start and Stop
Frequencies. Remember, if the frequencies are too low or high, an error will result.
11. Select Edit Reinitialize Values to Default when you are done experimenting.
12. Save the VI.
End of Exercise 2

National Instruments Corporation

1-33

Hands-On Seminar

Exercise 3: Add Limit Testing to Filter Test


Objective: This exercise will finish the VI from the previous two exercises. You will add limit testing to
verify that response of the filter is within range during the frequency sweep test. The following figure
shows the results of this exercise.
Note: This exercise includes thorough descriptions of each step to assist you in understanding why each
step is used. Because of this level of detail, you may not have enough time to complete it in the time
allowed. If you are unable to complete the exercise, there is a completed version in the Solutions folder
available for you to use for the next exercise.

Figure 8 Completed Exercise 3

Hardware: For the beginning of this exercise, start with the connections used in the previous exercise,
Oscilloscope CH 0 (positive probe) to AO 0 (Arbitrary waveform generator), as pictured below:

Figure 9 Signal Connections

Exercise 3A: Limit Testing


Hands-On Seminar

1-34

ni.com

1. Use the following steps to make a working copy of the VI that you created in the previous exercise.
a. If you closed your VI earlier, open Ex-2 FilterTest.vi in your Exercises folder.
b. Select File Save As, select Substitute copy for original, and click Continue.
c. Name the VI as Ex-3 FilterTest.vi and click OK.
2. You will first need to remove one wire used in the previous exercise.
a. Delete the wire between the NI-SCOPE Express VI and the Filter Response waveform
graph by selecting the wire and clicking the <Delete> key.
b. Make sure that there is space for another Express VI between the NI-Scope Express VI and
the Filter Response Waveform Graph. If you need to widen the For Loop, resize it.

Figure 10 Delete NI-SCOPE Express signal wire and make room for another Express VI

National Instruments Corporation

1-35

Hands-On Seminar

3. You will add an Express VI that will compare a waveform with upper and lower limits that you set
and return the results.
a. Right-click on the block diagram and select Express Signal Analysis Mask & Limit.
b. Place the Mask and Limit Testing Express VI to the right of the NI-SCOPE Express VI.
c. On the resulting configuration dialog, check the Upper Limit and Upper Constant
checkbox.
d. Uncheck the Upper Inclusive checkbox.
e. Next, check the Lower Limit and Lower Constant checkbox.
f.

Uncheck the Lower Inclusive checkbox.

Figure 11 Mask and Limit Testing Express VI

g. Click OK to save your changes.


4. On the block diagram, resize the Mask and Limit Testing VI so that the input terminals are no longer
visible (select bottom border and drag up). Now you will wire the four inputs of the Mask and Limit
Testing VI.
a. Wire the Channel 0 out output terminal of the NI ELVISmx Oscilloscope Express VI to the
Signals input terminal of the Mask and Limit Testing VI.
b. Wire the error out output terminal of the NI ELVISmx Oscilloscope Express VI to the error
in input terminal of the Mask and Limit Testing VI.

Figure 12 Wire NI-SCOPE Express VI to Mask and Limit Testing Express VI

Hands-On Seminar

1-36

ni.com

c. Wire the Start Limit control to the Upper Limit of the Mask and Limit Testing VI. This is
the value that determines the upper limit.

Figure 13 Wire Start Limit to Upper Constant terminal of Mask and LImit Testing Express VI

For this test, the lower constant is the negative value of the upper constant. This will create a
peak-to-peak limit for the response waveform. To negate the value of the Start Amplitude value,
you will use a Negate function.
d. Right-click on the block diagram, and select Numeric Negate.
e. Place the Negate function towards the middle of the For Loop.
f.

Wire the Start Limit loop tunnel to the input of the Negate function. This is easier to do if
you start the wire at the Negate function.

g. Wire the output of the Negate function to the Lower limit of the Mask and Limit Testing VI.

Figure 14 Use Negate function to create Lower Limit

National Instruments Corporation

1-37

Hands-On Seminar

5. Now you will wire the outputs for the Mask and Limit Testing VI.
a. Wire the Tested Signals output terminal of the Mask and Limit Testing Express VI to the
Filter Response waveform graph. Now the waveform that is read in by the digitizer will be
displayed on the front panel.
b. Wire the Passed output terminal of the Mask and Limit Testing Express VI to the Pass
Boolean indicator.

Figure 15 Wire outputs of Mask and Limit Testing Express VI

6. Switch to the front panel and run the VI. Notice the blue and green limits that are now on the Filter
Response waveform graph.

Figure 16 Limits

Hands-On Seminar

1-38

ni.com

Now you will add code so that each time the loop iterates, new Upper and Lower Limits will be used.
For the first iteration of the loop, the Upper Limit will be equal to the Start Limit. However, subsequent
loop iterations will decrease the Upper Limit by a set amount, which well call the Limit Step. To
determine the value of the Limit Step, use the following equation:
Stop Limit Start Limit
Limit Step =
Number of Steps 1
As it turns out, this equation is identical to the one used to calculate the Frequency Step in the previous
exercise. This provides the perfect opportunity to re-use code that you previously created.
7. You will select a portion of your block diagram and create a SubVI that you can re-use.
a. Switch to the block diagram of your VI.
b. Press and hold the <Shift> key and click on the Decrement, Subtract, and Divide functions
outside the loop of the block diagram. A moving dashed outline called a marquee will
highlight each function.

13.
Figure 17 Select Numeric functions

Tip: Alternatively, you can click and drag a selection box around the Subtract, Decrement, and
Divide functions.
c. With the Decrement, Subtract, and Divide functions highlighted, select Edit Create
SubVI. LabVIEW will replace the three functions that you selected with a new SubVI.

Figure 18 New SubVI

d. Double-click on the new VI that you just created. Looking at the front panel, notice that you
have three numeric controls on the left, and one numeric indicator.

National Instruments Corporation

1-39

Hands-On Seminar

e. Rename the controls and indicators of the new VI so that they arent specific to frequency.
i. Rename the Stop Frequency to Stop Value.
ii. Rename the Start Frequency to Start Value.
iii. Rename the Numeric to Step Value.

Figure 19 SubVI Front Panel

f.

Select Window Show Block Diagram to view the block diagram. Here you can see the
three functions and the controls and indicators wired just the way you had them. Creating
SubVIs is a powerful way to modularize your LabVIEW code.

Figure 20 SubVI Block Diagram

g. Select File Save as and name the SubVI as Step Value Calculator.vi.
h. Click OK and close the VI and return to the block diagram of the FilterTest VI.

Hands-On Seminar

1-40

ni.com

8. Now you will use the Start Limit, Stop Limit, Number of Steps, and the new Step Value VI to
calculate the value of the Limit Step.
a. Right-click on the block diagram and select Select a VI.
b. Select Step Value Calculator.vi in your Exercises folder and click OK.
c. Place the VI to the right of the Stop Limit control.
Tip: Alternatively, you can click on the Step Value SubVI, copy it, and paste the copy on the
block diagram.
d. Wire the Number of Steps control to the Number of Steps input terminal (top left) of the
Step Value Calculator VI.
e. Wire the Stop Limit control to the Stop Value input terminal (middle left) of the Step Value
Calculator VI.
f.

Wire the Start Limit control to the Start Value input terminal (bottom left) of the Step Value
Calculator VI.

Figure 21 Use Step Value Calculator VI to calculate Limit Step

The Limit Step value has been calculated and is ready to be used in the For Loop. For each loop, the limit
used in the following loop will be calculated by adding the current limit to the Limit Step. This
calculation will vary the limits as the frequency increases.
Next Loop Upper Limit = Current Loop Upper Limit + Limit Step
9. You will use the Start Limit, Limit Step, Add function, and For Loop to calculate the value of the
next loops limits.
a. Right-click on the block diagram and select Numeric Add. Place the Add function towards
the bottom right of the For Loop.
b. Wire the output of the second Step Value VI (which is outside the For Loop) to the top input
terminal of the new Add function (inside the For Loop).

National Instruments Corporation

1-41

Hands-On Seminar

Figure 22 Wire the Step Value Calculator VI output to the Add function

c. Right-click on the Loop tunnel created by the wire from the Start Limit control and select
Replace with Shift Register.

Figure 23 Create Shift Register for Limit value

d. Wire the Start Limit shift register that you just created to the second input of the new Add
function. This is easier to do if you start the wire at the Add function.
e. Wire the output of the Add function to the shift register on the right side of the For Loop.

Hands-On Seminar

1-42

ni.com

Figure 24 Finish Wiring the Add function

10. Double check that your block diagram is similar to the previous image. Save your VI.
11. Switch to the front panel.
12. Change the Stop Limit from 1.05 to 0.55, and select Edit Make Current Values Default.
13. Run the VI. The limit lines should gradually converge as the sweep progresses. The Pass LED should
also change to the Fail when the amplitude of the waveform is outside of the limits. If the VI isnt
running properly, double-check the block diagram or consult with the instructor.

Figure 25 Running Filter Test

14. Save the VI.

National Instruments Corporation

1-43

Hands-On Seminar

Exercise 3B: Connect to DUT


1. Now that you have successfully created and run the Filter Test VI, its time to connect the instruments
to the DUT and test the filter on DUT0.
2. First, make the following new Arb and Digitizer signal connections:
a. AO 0 (Arbitrary waveform generator) to lowpass filter input BP1_MID
b. Oscilloscope CH 0 (positive probe) to lowpass filter output BP1_OUT
c. Oscilloscope CH 0 (negative probe) to lowpass filter ground GND

b
a

Figure 26 Signal Connections

3. Run your VI again. Now that the filter has been introduced, the waveform should increase in
frequency and decrease in amplitude. The waveform should stay within the green and blue limit lines
on the graph.

Hands-On Seminar

1-44

ni.com

14. The DUT has a jumper that can be moved to force the filter test to fail. If you move the jumper to
C4 or R2 the filter will be bypassed and the test will fail. Try running the test with the jumper
moved to simulate a bad filter.

15. Replace the jumper when you are finished.


End of Exercise 3

National Instruments Corporation

1-45

Hands-On Seminar

Exercise 4: Add Tests Using NI TestStand Sequence Editor


Objective: To create a TestStand sequence and add steps to the MainSequence that tests components on
the device under test (DUT).
The TestStand Sequence Editor is a graphical user interface (GUI) for creating and modifying sequence
files. You use the sequence editor to add steps to a sequence file to create a test sequence for a DUT.
When a test fails, you need a way to notify the operator of the failure. Including failure information in the
report might be insufficient, and some other notification method may be more appropriate. In this
exercise, you will add steps to the sequence file that will test the LED and filter on the DUT.
Hardware: For the remaining exercises, add the following new DMM signal connections.
a. DMM positive probe to LED_SRC
b. DMM negative probe to LED_MEAS

Exercise 4A: Edit Filter Test VI properties


1. Follow these steps to make a working copy of the VI that you created in the previous exercise:
a. Open Ex-3 FilterTest.vi in your Exercises folder.
b. Select File Save As, select Substitute copy for original, and click Continue.
a. Name the VI as FilterTest.vi and click OK.
2. You completed the VI for the filter test and tested it in the previous exercise, but now you will need to
edit the VI so that it will output the result of the Pass terminal to TestStand.
a. With the front panel open, right-click on the VIs icon
window, and select Show Connector.

at the top right corner of the

b. Click on the top right box of the connector.

c. Then left click on the Pass boolean indicator on your front panel. This associates the Pass
boolean control with the selected terminal of your VI.
d. Right-click on the connector icon again and select Show Icon.

Hands-On Seminar

1-46

ni.com

3. Now, resize the VI front panel to only show the Waveform Graph and Pass Boolean indicator. When
the VI is called as a popup panel by TestStand, only the waveform graph will be visible.
4. The final change that you need to make to the VI is to change the window appearance.
a. Navigate to File VI Properties.
b. On the resulting dialog window, select Window Appearance in for the Category.
c. Select the Dialog radio button.
d. Select OK to save changes.
e. Run the VI to see how the window appears. This is how the VI will appear when called.

Figure 27 FilterTest VI Dialog Box

f.

Close the VI and click Save.

g. Leave LabVIEW open and continue.

Exercise 4B: Create a TestStand sequence and add the Filter Test step
1. Select Start All Programs National Instruments TestStand 2010 SP1.
2. After the TestStand Sequence Editor opens, a login dialog will appear. There is no password, click
OK. Each time you open the Sequence Editor, you will be prompted to login.
Tip: You can control access to specific TestStand capabilities based on the user login level. Using an
interactive user manager environment, you add, remove, and edit users, their passwords, access
levels, and profiles. In this case, when you log in as an administrator, you have access to all TestStand
sequence editor capabilities.

Figure 28 Login Dialog Box

National Instruments Corporation

1-47

Hands-On Seminar

3. First you will select the LabVIEW adapter which allows you to call and run LabVIEW VI code
modules from TestStand. Select the LabVIEW adapter from the Adapter ring control.

Figure 29 Adapter Ring Control

4. Now you will confirm that the execution process model is correct for this exercise. In this case, you
will use the Sequential execution process model.
a. Select Configure Station Options and select the Model tab.
b. Use the Station Model drop-down to select SequentialModel.seq or click the browse
button, to go to C:\Program Files\National Instruments\TestStand
3.5\Components\NI\Models\TestStand Models and select
SequentialModel.seq.
5. Now you will insert your first step to the test sequence, which will test the filter on the DUT. The test
will return a Boolean value for the pass/fail result, so the type of test you want is a pass/fail test.
Right-click on the sequence view window, then select Insert Step Tests Pass/Fail Test.

Figure 30 Addition of Filter Test step

6. Name the step Filter Test.

Hands-On Seminar

1-48

ni.com

7. Now that youve select the type of step, you will need to specify which LabVIEW VI this step calls.
You will use the LabVIEW VI that you saved at the end of Exercise 3 as the code for this test.
a. In the Step Settings window below, click the Browse for VI button. This will bring up
the Edit LabVIEW VI Call dialog box. Here you will select the path of the LabVIEW VI
that this step calls.

Figure 31 Select a Pathname for the Step's Code Module dialog box

b. Select the FilterTest.vi file from your Exercises directory and click OK to return to
the Edit LabVIEW VI Call dialog box.
8. Now that you have selected the VI, you will need to define where to store the test result in TestStand.
a. Notice that the window on the right now shows the VI icon with an output terminal called
Pass. This output is available to TestStand because of the edit you made to the
connector pane of the VI earlier in Part A of this exercise.
b. Click the Value field for Pass and click the Expression Browse button, f(x) button
the right.

, to

Figure 32 Edit LabVIEW VI Call

c. This is the Expression Browser dialog box, which you can use to interactively build an
expression by selecting from lists of variables, properties, operators, and functions.
d. In this case, navigate the properties of the step and select Step.Result.PassFail.
Click Insert to select that property.

National Instruments Corporation

1-49

Hands-On Seminar

Figure 33 Edit LabVIEW VI Call Dialog Box

e. Step.Result.PassFail is the TestStand property that will now contain the Pass
value.
f.

Click OK to return to the Edit LabVIEW VI Call dialog box.

g. Click OK again to return to the sequence editor window.


9. You have finished adding the first step to your test sequence.

Hands-On Seminar

1-50

ni.com

Exercise 4C: Add the LED Test step and interactively connect routes
1. Next, you will add a second step which will test the LED on the DUT. The test will return a numeric
value for the voltage that you will want to compare to limits, so the type of test you want is a numeric
limit test.
a. Right-click on the Filter Test step, then select Insert Step Tests Numeric Limit Test
as shown below.
b. Call the inserted step LED Test.
2. Just as you did for the previous test step, you will need to specify which LabVIEW VI this step calls.
Right-click on LED Test and select Specify Module.
a. In the Step Settings window below, click on the Select Express.
Tip: Express VIs can be called directly by TestStand. Remember from Exercise 2 that
Express VIs group low-level LabVIEW VIs into functional components that you can
configure through an interactive dialog box. In this case, you will use the niDMM Express VI
to specify acquisition properties and view the resulting data in the dialog box before inserting
the VI into your sequence.
b. From the menu that launches, click Browse and navigate to C:\Program Files
(x86)\National Instruments\LabVIEW 2011\vi.lib\express\NI ELVISmx\API.llb
c. On the window that prompts, select elvxp_mxDMMExpressBlock.vi from the list and
click OK
d. A configuration dialog box for NI ELVISmx DMM Express VI will open. Select the
corresponding ELVIS device and configure Measurement function to Diode as shown
in the next figure

National Instruments Corporation

Configuration Option

Value

Measurement function

Diode

1-51

Hands-On Seminar

Figure 34 NI ELVISmx DMM Express Dialog Box

3. Select Run Once. If the LED is connected properly and is functional, the displayed value will be
around 1.6 Volts. Also notice that the LED is lit.
4. Click the OK button to return to the Edit LabVIEW VI Call dialog box.
5. Next you will enter an expression that specifies where TestStand stores the numeric data that the VI
outputs.
a. In the Value field of the Measurement terminal, type in Step.Result.Numeric.

Figure 9 Passing step results

b. Step.Result.Numeric is the TestStand property that will now contain the measured
DMM value which will be compared to the limits we will define in the next step.
6. Now that the VI has been configured, you will want to define what values are within range and allow
the test to pass.
a. Click on the Limits tab in the Step Settings window.
b. Set the limits in the Edit Numeric Limit Test dialog box to the values shown in the next
figure. Setting the limits in this way will have this step fail only if the returned
measurement, the voltage value, is outside of 1.5V and 2.0V, which effectively tests for
shorts and opens.

Hands-On Seminar

1-52

ni.com

Figure 10 Edit Numeric Limits Dialog Box

c. Click OK to close the Edit Numeric Limit Test dialog box.


7. You have finished adding the second step to your test sequence. To save the sequence file, select File
Save and save Ex-4 Tests.seq in your Exercises directory.

National Instruments Corporation

1-53

Hands-On Seminar

Exercise 4D: Run the sequence


1. Now that the tests are added, you can execute your test sequence.
a. Select Execute Single Pass. If prompted, select Yes to save the sequence file.

Figure 35 Sequence Editor Running

2. View the test results. Notice the status of the tests and the result of the LED Test measurement is
displayed.
NOTE: The LED will remain on after the test is complete.
3. To run another test, click Execute Restart.
4. Moving the jumper on DUT3 to a different position will make the filter fail. Move the jumper to C4
and run the sequence again using Execute Restart. View the test results to see that the Filter Test
failed.
Tip: Placing the jumper on the C4 or R2 jumper pins will cause the Filter Test to fail.

Hands-On Seminar

1-54

ni.com

5. Place the jumper back on the NONE jumper pin when finished.
6. Close the Single Pass window by pressing the Close button on the window or selecting Window
Close Completed Execution Displays when you are finished.
End of Exercise 4

National Instruments Corporation

1-55

Hands-On Seminar

Anda mungkin juga menyukai