Professional Documents
Culture Documents
Lab 1
Data Acquisition
with cDAQ while
Getting Familiar
with LabVIEW
Section 1 – Data Acquisition with cDAQ while Getting
Familiar with LabVIEW
--------------------------------------------------------------------------- 2
Part 1 – Configuring Hardware
--------------------------------------------------------------------------- 3
Part 2 – Using LabVIEW Express VIs
--------------------------------------------------------------------------- 4
Part 3 – Using Low Level DAQmx VIs
--------------------------------------------------------------------------- 5
Data Acquisition with cDAQ while Getting Familiar with LabVIEW | Laboratory 1
Section 1
Data Acquisition with cDAQ
while Getting Familiar with
LabVIEW
In this lab, you will start your temperature monitoring program. The first step that you will
take is measuring the voltage across the thermistor. Thermistors are a type of resistor which
have different resistances at different temperatures. By building a voltage divider, we can
measure the voltage across the thermistor. Then we will use a pre-built program to calculate
the resistance and convert that to a temperature.
You will then explore the LabVIEW environment through data acquisition by contrasting
Express VIs with Low Level DAQmx VIs.
Parts List:
The following equipment is required for this
experiment:
-- 1 10kΩ resistor
-- 1 10kΩ thermistor, EPCOS B57164K103J
-- 1 100nF capacitor
-- Breadboard
-- Wires
Virtual Instrumentation 2
Data Acquisition with cDAQ while Getting Familiar with LabVIEW | Laboratory 1
Procedure
Part 1 – Configuring Hardware
1) Use the Getting Started: How to Configure Your System document to ensure that your
system is ready to use.
GND
Virtual Instrumentation 3
Data Acquisition with cDAQ while Getting Familiar with LabVIEW | Laboratory 1
3) Navigate to Measurement I/O, and pin down the palette by clicking the pushpin icon at the
top of the Functions Palette.
4) Notice that the Measurement I/O Palette contains sub-palettes for DAQmx.
5) Click on the DAQmx icon on the Measurement I/O palette and locate the DAQ Assistant
Express VI. Drag the DAQ Assistant onto the Block Diagram.
8) Take note of the default settings of the DAQ Assistant and select OK.
9) Right-click the Data output terminal of the DAQ Assistant and select Create>>Graph
Indicator.
Virtual Instrumentation 4
Data Acquisition with cDAQ while Getting Familiar with LabVIEW | Laboratory 1
3) Place the Create Channel, Timing, Read, and Clear Task VIs on the Block Diagram.
5) Right-click on the Physical Channels input to the VI and select Create>>Constant. Select AI1
of your cDAQ Analog Input card.
6) Wire the Error Out and Task Out terminals of the Create Channel VI to the Error In and Task In
terminals of the Timing VI respectively.
7) Create a constant for the rate on the Timing VI and set it to 1000.
10) Wire the Error Out and Task Out terminals of the Timing VI to the Error In and Task In
terminals of the Read VI respectively.
11) Click the down arrow on the Read VI and select Analog>>Single Channel>>Multiple
Samples>>Waveform.
12) Switch to the Front Panel and right click to access the Controls Palette. Locate the Graph
sub-palette under Programming and place a Waveform Graph on the Front Panel.
13) Return to the Block Diagram and wire the Data output terminal of the Read VI to the
Waveform Graph.
14) Wire the Error Out and Task Out terminals of the Read VI to the Error In and Task In terminals
of the Clear Task VI respectively.
Virtual Instrumentation 5
Data Acquisition with cDAQ while Getting Familiar with LabVIEW | Laboratory 1
Virtual Instrumentation 6
Data Acquisition with cDAQ while Getting Familiar with LabVIEW | Laboratory 1
Questions
1) Outline the general idea of how analog input data acquisition works in hardware.
What do the data acquisition VIs do?
2) Outline the similarities and differences between using the Express VI and the low level
DAQmx VIs
3) Explore the DAQmx palette and look for features that you can access with the low level
DAQ VIs. What could be possible benefits of using the low level DAQmx VIs?
4) One application of the simple code made in this lab, instead of measuring the voltage
across a thermistor, would be testing a battery to determine if it is fully charged.
Using this code, the voltage of the battery could be read and compared to what is expected.
What are three other applications you can think of for this code?
Virtual Instrumentation 7
VIRTUAL INSTRUMENTATION
Lab 1
Data Acquisition
with ELVIS while
Getting Familiar
with LabVIEW
Section 1 – Data Acquisition with ELVIS while Getting
Familiar with LabVIEW
--------------------------------------------------------------------------- 2
Part 1 – Configuring Hardware
--------------------------------------------------------------------------- 3
Part 2 – Using LabVIEW Express VIs
--------------------------------------------------------------------------- 4
Part 3 – Using Low Level DAQmx VIs
--------------------------------------------------------------------------- 5
Data Acquisition with ELVIS while Getting Familiar with LabVIEW | Laboratory 1
Section 1
Data Acquisition with ELVIS
while Getting Familiar with
LabVIEW
In this lab, you will start your temperature monitoring program. The first step that you will
take is measuring the voltage across the thermistor. Thermistors are a type of resistor which
have different resistances at different temperatures. By building a voltage divider, we can
measure the voltage across the thermistor. Then we will use a pre-built program to calculate
the resistance and convert that to a temperature.
You will then explore the LabVIEW environment through data acquisition by contrasting
Express VIs with Low Level DAQmx VIs.
Parts List:
The following equipment is required for this
experiment:
-- 1 10kΩ resistor
-- 1 10kΩ thermistor, EPCOS B57164K103J
-- 1 100nF capacitor
-- Breadboard
-- Wires
Virtual Instrumentation 2
Data Acquisition with ELVIS while Getting Familiar with LabVIEW | Laboratory 1
Procedure
Part 1 – Configuring Hardware
1) Use the Getting Started: How to Configure Your System document to ensure that your
system is ready to use.
AI1-
C R
0.1µF 10kΩ
GND
Virtual Instrumentation 3
Data Acquisition with ELVIS while Getting Familiar with LabVIEW | Laboratory 1
3) Navigate to Measurement I/O, and pin down the palette by clicking the pushpin icon at the
top of the Functions Palette.
4) Notice that the Measurement I/O Palette contains sub-palettes for DAQmx.
5) Click on the DAQmx icon on the Measurement I/O palette and locate the DAQ Assistant
Express VI. Drag the DAQ Assistant onto the Block Diagram.
8) Take note of the default settings of the DAQ Assistant and select OK.
9) Right-click the Data output terminal of the DAQ Assistant and select Create>>Graph
Indicator.
Virtual Instrumentation 4
Data Acquisition with ELVIS while Getting Familiar with LabVIEW | Laboratory 1
3) Place the Create Channel, Timing, Read, and Clear Task VIs on the Block Diagram.
5) Right-click on the Physical Channels input to the VI and select Create>>Constant. Select AI1
of your NI ELVIS.
6) Wire the Error Out and Task Out terminals of the Create Channel VI to the Error In and Task In
terminals of the Timing VI respectively.
7) Create a constant for the rate on the Timing VI and set it to 1000.
10) Wire the Error Out and Task Out terminals of the Timing VI to the Error In and Task In
terminals of the Read VI respectively.
11) Click the down arrow on the Read VI and select Analog>>Single Channel>>Multiple
Samples>>Waveform.
12) Switch to the Front Panel and right click to access the Controls Palette. Locate the Graph
sub-palette under Programming and place a Waveform Graph on the Front Panel.
13) Return to the Block Diagram and wire the Data output terminal of the Read VI to the
Waveform Graph.
14) Wire the Error Out and Task Out terminals of the Read VI to the Error In and Task In terminals
of the Clear Task VI respectively.
Virtual Instrumentation 5
Data Acquisition with ELVIS while Getting Familiar with LabVIEW | Laboratory 1
Virtual Instrumentation 6
Data Acquisition with ELVIS while Getting Familiar with LabVIEW | Laboratory 1
Questions
1) Outline the general idea of how analog input data acquisition works in hardware.
What do the data acquisition VIs do?
2) Outline the similarities and differences between using the Express VI and the low level
DAQmx VIs
3) Explore the DAQmx palette and look for features that you can access with the low level
DAQ VIs. What could be possible benefits of using the low level DAQmx VIs?
4) One application of the simple code made in this lab, instead of measuring the voltage
across a thermistor, would be testing a battery to determine if it is fully charged.
Using this code, the voltage of the battery could be read and compared to what is expected.
What are three other applications you can think of for this code?
Virtual Instrumentation 7
VIRTUAL INSTRUMENTATION
Lab 2
Applying Signal
Conditioning to
a Thermistor
Measurement
Section 1 - Applying Signal Conditioning to a
Thermistor Measurement
--------------------------------------------------------------------------- 2
Creating Signal Conditioning
--------------------------------------------------------------------------- 3
Applying Signal Conditioning to a Thermistor Measurement | Laboratory 2
Section 1
Applying Signal Conditioning
to a Thermistor Measurement
In this lab, you will take the voltage measured in lab 1 and convert it to a temperature. In
typical data acquisition programs, the data is measured as raw voltages or currents. Typically,
the sensor that is being measured will have a specification which indicates how that sensor
converts from voltages into engineering units. For example, a range sensor might output a
range from 0 volts to +5 volts, which corresponds to engineering units of 0 centimeters to 100
centimeters.
In your program, you will need to make that conversion between volts and engineering units.
This is one of the stages of a process called signal conditioning.
In this lab, you will use a pre-built program to calculate the resistance of the thermistor and
convert that value to a temperature.
Parts List:
The following equipment is required for this
experiment:
Virtual Instrumentation 2
Applying Signal Conditioning to a Thermistor Measurement | Laboratory 2
Procedure
Creating Signal Conditioning
1) The conversion from a voltage measurement to a temperature measurement is dependent
on the exact resistance of the 10k resistor. For this reason, you’ll need to measure the
resistance and note the result before continuing.
2) Open the Data Acquisition with cDAQ.vi file from the previous lab.
If you didn’t complete this VI, ask your instructor for access to a VI to use as the starting
point for this lab.
5) Click the Search button at the top right of the Functions Palette.
9) Connect the Voltage input of the Convert Thermistor Reading function to the Waveform
wire.
10) Delete the wire to the Waveform Graph, move the Waveform Graph terminal to the right of
the Convert Thermistor Reading function, and wire the Temperature output of the function
to the terminal.
Virtual Instrumentation 3
Applying Signal Conditioning to a Thermistor Measurement | Laboratory 2
Virtual Instrumentation 4
Applying Signal Conditioning to a Thermistor Measurement | Laboratory 2
Questions
1) Why is it important to convert a measured signal from raw measurements to engineering
units?
Virtual Instrumentation 5
VIRTUAL INSTRUMENTATION
Lab 2
Applying Signal
Conditioning to
a Thermistor
Measurement
Section 1 - Applying Signal Conditioning to a
Thermistor Measurement
--------------------------------------------------------------------------- 2
Creating Signal Conditioning
--------------------------------------------------------------------------- 3
Applying Signal Conditioning to a Thermistor Measurement | Laboratory 2
Section 1
Applying Signal Conditioning
to a Thermistor Measurement
In this lab, you will take the voltage measured in lab 1 and convert it to a temperature. In
typical data acquisition programs, the data is measured as raw voltages or currents. Typically,
the sensor that is being measured will have a specification which indicates how that sensor
converts from voltages into engineering units. For example, a range sensor might output a
range from 0 volts to +5 volts, which corresponds to engineering units of 0 centimeters to 100
centimeters.
In your program, you will need to make that conversion between volts and engineering units.
This is one of the stages of a process called signal conditioning.
In this lab, you will use a pre-built program to calculate the resistance of the thermistor and
convert that value to a temperature.
Parts List:
The following equipment is required for this
experiment:
Virtual Instrumentation 2
Applying Signal Conditioning to a Thermistor Measurement | Laboratory 2
Procedure
Creating Signal Conditioning
1) The conversion from a voltage measurement to a temperature measurement is dependent
on the exact resistance of the 10k resistor. For this reason, you’ll need to measure the
resistance and note the result before continuing.
2) Open the Data Acquisition with ELVIS.vi file from the previous lab.
If you didn’t complete this VI, ask your instructor for access to a VI to use as the starting
point for this lab.
5) Click the Search button at the top right of the Functions Palette.
9) Connect the Voltage input of the Convert Thermistor Reading function to the Waveform
wire.
10) Delete the wire to the Waveform Graph, move the Waveform Graph terminal to the right of
the Convert Thermistor Reading function, and wire the Temperature output of the function
to the terminal.
Virtual Instrumentation 3
Applying Signal Conditioning to a Thermistor Measurement | Laboratory 2
Virtual Instrumentation 4
Applying Signal Conditioning to a Thermistor Measurement | Laboratory 2
Questions
1) Why is it important to convert a measured signal from raw measurements to engineering
units?
Virtual Instrumentation 5
VIRTUAL INSTRUMENTATION
Lab 3
Loops, Case
Structures,
and Timing
Section 1
Loops, Case Structures, and
Timing
In this lab, you will expand upon the code you created in Lab 2 in order to continuously measure
temperature with the thermistor. The application that we’re trying to build is implementing a
temperature monitor. Monitoring applications need to continuously read data from the sensor
that they’re monitoring, therefore we will need to continuously monitor the temperature.
To do this, you will explore While Loops, For Loops and Case Structures. By the end of this lab,
you should understand the functionality of each type of loop or structure and how they are
different. You should also understand the effects of implementing timing in a VI.
Pre-Lab Questions:
1) Based on your classroom understanding of While Loops, For Loops, and Case Structures, if
we stated that we wanted to do a continuous acquisition, what loop or structure would we
choose?
Virtual Instrumentation 2
Loops, Case Structures, and Timing | Laboratory 3
Procedure
Configuring Hardware
1) Keep the same wiring configuration as in Lab 1 and 2.
Part A
1) Open the VI that you created in Lab 2, Data Acquisition with cDAQ - Signal Conditioning.vi.
If you didn’t complete this VI, ask your instructor for access to a VI to use as the starting
point for this lab.
2) Copy and paste the code from Lab 2 into a new VI.
5) Change the Rate to 500 and leave the Samples per Channel at 100. This modifies the
settings of the buffer that data is written to.
7) Place a While Loop around the Read VI, the Convert Thermistor Reading VI and the
Waveform Graph indicator.
8) Create a Stop Control for the Loop Condition Terminal of the While Loop by right-clicking on
the input to the Loop Condition Terminal and selecting Create>>Control.
9) Change the Waveform Graph to a Waveform Chart by right-clicking on the graph on the
Front Panel and choosing Replace. Navigate to the Graph palette and choose a Waveform
Chart.
10) On the Front Panel, right-click on the Waveform Chart and select Properties.
11) On the Scales tab, uncheck Auto-Scale for the x-axis and change the minimum to 0 and the
maximum to 0.1.
Virtual Instrumentation 3
Loops, Case Structures, and Timing | Laboratory 3
Part B
1) Wire AI2 + of the Analog Input card to the +5V Supply and wire AI2- to Ground.
2) Put a Case Structure around the Create Channel VI and its corresponding terminals.
3) Navigate to the False Case and add a new Create Channel VI to the Case Structure. Choose
Channel AI2 of your device for this case.
4) Wire the Error Out and Task Out of the new Create Channel VI to the Task and Error terminals
on the right side of the Case Structure.
5) Wire a Boolean Control to the Case Selector of the Case Structure by right-clicking the input
terminal of the Case Selector and selecting Create>>Control.
Virtual Instrumentation 4
Loops, Case Structures, and Timing | Laboratory 3
7) Click the Boolean Control on the Front Panel so that it is in the True state. Run the VI. Notice
that the same waveform is created as in Part A of this Lab.
8) Stop the VI and click the Boolean Control on the Front Panel so that it is in the False state.
10) Explore changing the scale of the waveform chart to zoom in on the signal.
Virtual Instrumentation 5
Loops, Case Structures, and Timing | Laboratory 3
Questions
1) What are three differences between a While Loop and a For Loop?
2) Comparing Lab 1 and Lab 3, why do you suppose we do not typically use for loops for data
acquisition?
4) Comparing Lab 1 and Lab 3, why do you suppose we do not typically use for loops for data
acquisition?
Virtual Instrumentation 6
Loops, Case Structures, and Timing | Laboratory 3
5) What was the effect of putting the Wait in the While Loop, and why is it good to use waits?
6) Why does clicking the True/False control on the Front Panel not have any effect while the VI
is running?
7) What is another type of control that could have been wired to the Case Structure Selector
Terminal that would have given the ability to associate a title with each case that could be
selected on the Front Panel?
Virtual Instrumentation 7
VIRTUAL INSTRUMENTATION
Lab 3
Loops, Case
Structures,
and Timing
Section 1
Loops, Case Structures, and
Timing
In this lab, you will expand upon the code you created in Lab 2 in order to continuously measure
temperature with the thermistor. The application that we’re trying to build is implementing a
temperature monitor. Monitoring applications need to continuously read data from the sensor
that they’re monitoring, therefore we will need to continuously monitor the temperature.
To do this, you will explore While Loops, For Loops and Case Structures. By the end of this lab,
you should understand the functionality of each type of loop or structure and how they are
different. You should also understand the effects of implementing timing in a VI.
Pre-Lab Questions:
1) Based on your classroom understanding of While Loops, For Loops, and Case Structures, if
we stated that we wanted to do a continuous acquisition, what loop or structure would we
choose?
Virtual Instrumentation 2
Loops, Case Structures, and Timing | Laboratory 3
Procedure
Configuring Hardware
1) Keep the same wiring configuration as in Lab 1 and 2.
Part A
1) Open the VI that you created in Lab 2, Data Acquisition with ELVIS - Signal Conditioning.vi.
If you didn’t complete this VI, ask your instructor for access to a VI to use as the starting
point for this lab.
2) Copy and paste the code from Lab 2 into a new VI.
5) Change the Rate to 500 and leave the Samples per Channel at 100. This modifies the
settings of the buffer that data is written to.
7) Place a While Loop around the Read VI, the Convert Thermistor Reading VI and the
Waveform Graph indicator.
8) Create a Stop Control for the Loop Condition Terminal of the While Loop by right-clicking on
the input to the Loop Condition Terminal and selecting Create>>Control.
9) Change the Waveform Graph to a Waveform Chart by right-clicking on the graph on the
Front Panel and choosing Replace. Navigate to the Graph palette and choose a Waveform
Chart.
10) On the Front Panel, right-click on the Waveform Chart and select Properties.
11) On the Scales tab, uncheck Auto-Scale for the x-axis and change the minimum to 0 and the
maximum to 0.1.
Virtual Instrumentation 3
Loops, Case Structures, and Timing | Laboratory 3
Part B
1) Wire AI2 + of the NI ELVIS to the +5V Supply and wire AI2- to Ground.
2) Put a Case Structure around the Create Channel VI and its corresponding terminals.
3) Navigate to the False Case and add a new Create Channel VI to the Case Structure. Choose
Channel AI2 of your device for this case.
4) Wire the Error Out and Task Out of the new Create Channel VI to the Task and Error terminals
on the right side of the Case Structure.
5) Wire a Boolean Control to the Case Selector of the Case Structure by right-clicking the input
terminal of the Case Selector and selecting Create>>Control.
Virtual Instrumentation 4
Loops, Case Structures, and Timing | Laboratory 3
7) Click the Boolean Control on the Front Panel so that it is in the True state. Run the VI. Notice
that the same waveform is created as in Part A of this Lab.
8) Stop the VI and click the Boolean Control on the Front Panel so that it is in the False state.
10) Explore changing the scale of the waveform chart to zoom in on the signal.
Virtual Instrumentation 5
Loops, Case Structures, and Timing | Laboratory 3
Questions
1) What are three differences between a While Loop and a For Loop?
2) Comparing Lab 1 and Lab 3, why do you suppose we do not typically use for loops for data
acquisition?
4) Comparing Lab 1 and Lab 3, why do you suppose we do not typically use for loops for data
acquisition?
Virtual Instrumentation 6
Loops, Case Structures, and Timing | Laboratory 3
5) What was the effect of putting the Wait in the While Loop, and why is it good to use waits?
6) Why does clicking the True/False control on the Front Panel not have any effect while the VI
is running?
7) What is another type of control that could have been wired to the Case Structure Selector
Terminal that would have given the ability to associate a title with each case that could be
selected on the Front Panel?
Virtual Instrumentation 7
VIRTUAL INSTRUMENTATION
Lab 4
Arrays, Clusters,
and Type Definitions
Section 1
Arrays, Clusters, and Type
Definitions
In this lab, you will expand upon the DAQmx code you created in Lab 2 to explore Arrays,
Clusters, and Type Definitions.
The temperature monitoring application will be taking continuous measurement. You’ll explore
how large sets of similar data can be grouped into arrays and sets of dissimilar data can be
grouped into clusters.
By the end of this lab, you should have a good understanding of the functionality and
limitations (if any) of arrays and clusters, as well as when each is appropriate to use.
Pre-Lab Questions:
1) In the code shown, what do you
suppose has an array component
and what do you suppose uses a
cluster?
2) What function(s) could be used in order to break the cluster into its individual components?
Virtual Instrumentation 2
Arrays, Clusters, and Type Definitions | Laboratory 4
Procedure
Configuring Hardware
1) Keep the same wiring configuration as in Lab 3.
Part A – Arrays
1) Open the VI that you created in Lab 3, Structures.vi.
If you didn’t complete this VI, ask your instructor for access to a VI to use as the starting
point for this lab.
4) Outside of the While Loop on the right side, place the Get Waveform Components function.
5) Right-click the Get Waveform Components function and select Add Element.
6) Repeat the previous step so that there are three outputs from the Get Waveform
Components function.
9) Wire a branch from the Waveform wire to the Get Waveform Components Function outside
of the While Loop.
10) Create indicators for each of the outputs of the Get Waveform Components Function so that
the ‘Y’ data, ‘t0’ data, and ‘dt’ data is displayed on the Front Panel.
11) Wire the “Number of Samples per Channel” input of the Read VI to a constant of 125.
Virtual Instrumentation 3
Arrays, Clusters, and Type Definitions | Laboratory 4
13) Run the VI to get a sample of data, and then stop it.
14) Expand the array indicator on the Front Panel so that you can see 10 to 15 values. Notice
the difference in the values when different cases of the Case Structure are chosen.
15) Identify which indicator is an array and how you know. Also, record why it makes sense
that the indicator you chose as the array is the only array and why it makes sense that the
other two indicators are not.
Part B – Clusters
1) Inside of the While Loop, place an Unbundle by Name function.
2) Wire the error wire coming out of the Read VI into the Unbundle by Name function.
3) Wire the output of the Unbundle by Name to a Boolean “Or” from the Boolean Palette.
4) Wire the Stop Button to the other “Or” input and wire the output of the “Or” to the Loop
Condition Terminal.
Virtual Instrumentation 4
Arrays, Clusters, and Type Definitions | Laboratory 4
7) Record the possible benefit of unbundling the error wire and using the “Or” function. What
is a possible use case?
8) Change the Rate input of the Timing VI from 500 to 3 million. Run the VI. Record the
behavior and click Stop on the error message.
9) Expand the Unbundle by Name to show “Status,” “Code,” and “Source” and make
indicators for each as shown.
10) Run the VI and observe what is displayed in the three new indicators that you created after
clicking Stop on the error message.
11) Why are these three components contained in an Error Cluster and what are the data types
of each. Why do these data types make sense?
Virtual Instrumentation 5
Arrays, Clusters, and Type Definitions | Laboratory 4
2) Notice that the default at the top of the new window is “Control.” In this instance you will
create a Custom Control.
3) Change the cosmetic properties of the control. Think about ways to make the stop button
more apparent to potential users. For instance, make it larger and change the color.
5) Allow LabVIEW to replace your existing control with the new, modified Custom Control.
6) The Custom Control can also be accessed by right-clicking on the Front Panel and choosing
Select a Control from the Controls Palette. Here you can choose your control.
3) When the pop-up window appears, choose Add. This adds your VI to a project.
5) Create any control that you want and change its properties, etc to be customized. Save the
control and close the window. Observe that the Custom Control is now added to the project
along with the custom control you made using Method 1.
6) Drag the control from the project onto your Front Panel. Notice that you can make multiple
instances of your custom control on your Front Panel by dragging the custom control from
the project onto the Front Panel.
Virtual Instrumentation 6
Arrays, Clusters, and Type Definitions | Laboratory 4
8) Double-click the Custom Control created in Method 2 in the project menu tree and change the
instance from Control to Type Def.
10) Drag the Type Def from the Project to the Front Panel.
11) Reopen the Type Def Front Panel to edit the Type Def.
12) Right-click on the control in the Type Def window. Select Replace>>Numeric control.
14) Record what happens to the Type Def that was previously placed on the Front Panel.
16) Double click on the Type Def in the Project and change the instance to Strict Type Def.
18) Drag the Strict Type Def from the project to the Front Panel.
19) Reopen the Strict Type Def Front Panel to edit the Strict Type Def.
21) Change the color and size of the control and save. Close the window and record the behavior
you observe on the Front Panel.
22) Delete the Stop Button you previously had wired into the “Or” function on your Block
Diagram and replace it with your new customized Strict Type Def.
23) Now that you have begun to make your Front Panel more user-friendly, finish it by using the
Alignment, Distribute, and Resize buttons at the top of the Front Panel. Also, use decorations
from the Control Palette to arrange controls and indicators so that they are easy for the user
to use and understand.
24) Save the VI as Data Acquisition with cDAQ – Clusters.vi and the Project as Data Acquisition
with cDAQ.lvproj.
Virtual Instrumentation 7
Arrays, Clusters, and Type Definitions | Laboratory 4
Questions
1) Can you make an array of an array? Can you make an array have multiple data types?
3) Describe the progression from Custom Control to Type Def. to Strict Type Def.
What can you customize in a Strict Type Def that cannot be customized in a Type Def?
Virtual Instrumentation 8
VIRTUAL INSTRUMENTATION
Lab 4
Arrays, Clusters,
and Type Definitions
Section 1
Arrays, Clusters, and Type
Definitions
In this lab, you will expand upon the DAQmx code you created in Lab 2 to explore Arrays,
Clusters, and Type Definitions.
The temperature monitoring application will be taking continuous measurement. You’ll explore
how large sets of similar data can be grouped into arrays and sets of dissimilar data can be
grouped into clusters.
By the end of this lab, you should have a good understanding of the functionality and
limitations (if any) of arrays and clusters, as well as when each is appropriate to use.
Pre-Lab Questions:
1) In the code shown, what do you
suppose has an array component
and what do you suppose uses a
cluster?
2) What function(s) could be used in order to break the cluster into its individual components?
Virtual Instrumentation 2
Arrays, Clusters, and Type Definitions | Laboratory 4
Procedure
Configuring Hardware
1) Keep the same wiring configuration as in Lab 3.
Part A – Arrays
1) Open the VI that you created in Lab 3, Structures - ELVIS.vi.
If you didn’t complete this VI, ask your instructor for access to a VI to use as the starting
point for this lab.
4) Outside of the While Loop on the right side, place the Get Waveform Components function.
5) Right-click the Get Waveform Components function and select Add Element.
6) Repeat the previous step so that there are three outputs from the Get Waveform
Components function.
9) Wire a branch from the Waveform wire to the Get Waveform Components Function outside
of the While Loop.
10) Create indicators for each of the outputs of the Get Waveform Components Function so that
the ‘Y’ data, ‘t0’ data, and ‘dt’ data is displayed on the Front Panel.
11) Wire the “Number of Samples per Channel” input of the Read VI to a constant of 125.
Virtual Instrumentation 3
Arrays, Clusters, and Type Definitions | Laboratory 4
13) Run the VI to get a sample of data, and then stop it.
14) Expand the array indicator on the Front Panel so that you can see 10 to 15 values. Notice
the difference in the values when different cases of the Case Structure are chosen.
15) Identify which indicator is an array and how you know. Also, record why it makes sense
that the indicator you chose as the array is the only array and why it makes sense that the
other two indicators are not.
Part B – Clusters
1) Inside of the While Loop, place an Unbundle by Name function.
2) Wire the error wire coming out of the Read VI into the Unbundle by Name function.
3) Wire the output of the Unbundle by Name to a Boolean “Or” from the Boolean Palette.
4) Wire the Stop Button to the other “Or” input and wire the output of the “Or” to the Loop
Condition Terminal.
Virtual Instrumentation 4
Arrays, Clusters, and Type Definitions | Laboratory 4
7) Record the possible benefit of unbundling the error wire and using the “Or” function. What
is a possible use case?
8) Change the Rate input of the Timing VI from 500 to 3 million. Run the VI. Record the
behavior and click Stop on the error message.
9) Expand the Unbundle by Name to show “Status,” “Code,” and “Source” and make
indicators for each as shown.
10) Run the VI and observe what is displayed in the three new indicators that you created after
clicking Stop on the error message.
11) Why are these three components contained in an Error Cluster and what are the data types
of each. Why do these data types make sense?
Virtual Instrumentation 5
Arrays, Clusters, and Type Definitions | Laboratory 4
2) Notice that the default at the top of the new window is “Control.” In this instance you will
create a Custom Control.
3) Change the cosmetic properties of the control. Think about ways to make the stop button
more apparent to potential users. For instance, make it larger and change the color.
5) Allow LabVIEW to replace your existing control with the new, modified Custom Control.
6) The Custom Control can also be accessed by right-clicking on the Front Panel and choosing
Select a Control from the Controls Palette. Here you can choose your control.
3) When the pop-up window appears, choose Add. This adds your VI to a project.
5) Create any control that you want and change its properties, etc to be customized. Save the
control and close the window. Observe that the Custom Control is now added to the project
along with the custom control you made using Method 1.
6) Drag the control from the project onto your Front Panel. Notice that you can make multiple
instances of your custom control on your Front Panel by dragging the custom control from
the project onto the Front Panel.
Virtual Instrumentation 6
Arrays, Clusters, and Type Definitions | Laboratory 4
8) Double-click the Custom Control created in Method 2 in the project menu tree and change the
instance from Control to Type Def.
10) Drag the Type Def from the Project to the Front Panel.
11) Reopen the Type Def Front Panel to edit the Type Def.
12) Right-click on the control in the Type Def window. Select Replace>>Numeric control.
14) Record what happens to the Type Def that was previously placed on the Front Panel.
16) Double click on the Type Def in the Project and change the instance to Strict Type Def.
18) Drag the Strict Type Def from the project to the Front Panel.
19) Reopen the Strict Type Def Front Panel to edit the Strict Type Def.
21) Change the color and size of the control and save. Close the window and record the behavior
you observe on the Front Panel.
22) Delete the Stop Button you previously had wired into the “Or” function on your Block
Diagram and replace it with your new customized Strict Type Def.
23) Now that you have begun to make your Front Panel more user-friendly, finish it by using the
Alignment, Distribute, and Resize buttons at the top of the Front Panel. Also, use decorations
from the Control Palette to arrange controls and indicators so that they are easy for the user
to use and understand.
24) Save the VI as Data Acquisition with ELVIS – Clusters.vi and the Project as Data Acquisition
Virtual Instrumentation 7
Arrays, Clusters, and Type Definitions | Laboratory 4
with ELVIS.lvproj.
Virtual Instrumentation 8
Arrays, Clusters, and Type Definitions | Laboratory 4
Questions
1) Can you make an array of an array? Can you make an array have multiple data types?
3) Describe the progression from Custom Control to Type Def. to Strict Type Def.
What can you customize in a Strict Type Def that cannot be customized in a Type Def?
Virtual Instrumentation 9
VIRTUAL INSTRUMENTATION
Lab 5
File I/O
Section 1
File I/O
In this lab, you will expand upon the DAQmx code you created in Lab 3 in order to explore File
I/O.
Monitoring applications often run for an extended period of time. In order to save the data that
is gathered, you’re going to setup your temperature monitor to log the data to a file.
You will first observe how easy it is to use Express VIs for File I/O and will later explore using
TDMS.
Pre-lab Questions:
1) What kind of information would you want included in a data log?
2) In the VI we made in Lab 4, what would be relevant information to log and why?
Virtual Instrumentation 2
File I/O | Laboratory 5
Procedure
Configuring Hardware
1) Keep the same wiring configuration as in Lab 4.
5) Place the Write to Measurement File Express VI on the Block Diagram outside of the While
Loop.
6) When the window opens, set the Filename to save as “Test” on your desktop.
9) Wire the waveform data out of the While Loop to the input of the Write to Measurement File
Express VI.
Virtual Instrumentation 3
File I/O | Laboratory 5
12) Run the VI. Stop the VI after a few seconds with the Stop button that you created.
13) Navigate to the “Test” file you created on your desktop and open it with Excel. Observe that
your data has been logged.
14) Returning to the Block Diagram, double-click the Write to Measurement File Express VI
and notice some of the settings you can change such as “Action”, “If a File Already Exists,”
“Segment Headers,” and “X Value Columns.” Change each one of these and record what the
result is.
Virtual Instrumentation 4
File I/O | Laboratory 5
Part B – TDMS
1) Delete the Write to Measurement File Express VI.
2) On the Block Diagram, locate the TDMS Streaming Palette within the File I/O Palette.
3) Outside of the while loop place a TDMS Open and TDMS Close. Inside the while loop, place
a TDMS Write.
4) Wire the File Wires and Error Wires so that all three VIs are wired together.
5) Wire the Waveform data to the Data Input of the TDMS Write.
6) Create a control for the File Path input of the TDMS Open.
7) Right-click the File Path Control on the Front Panel and choose Browse Options.
8) Select New or Existing as the Selection Mode and close the window by clicking Ok.
9) Create a constant for the Operation input of the TDMS Open and set the constant to Create
or Replace.
10) Make sure that your code matches the image shown.
11) Enter a file path in the control on the Front Panel that points to a file called “test.tdms” on
your desktop.
Virtual Instrumentation 5
File I/O | Laboratory 5
14) Create a new VI and place the TDMS File Viewer VI on the Block Diagram.
15) Create a File Path Control input to the TDMS File Viewer.
16) In the control on the Front Panel of the new VI, select the “test.tdms” file on your desktop and
run the VI.
17) Notice that the TDMS File Viewer opens. Explore the File Viewer.
18) Returning to the original VI, notice that the TDMS Write has inputs for Channel Name and
Group Name.
19) Wire a String Constant with the text “Data Acquisition” to the Group Name input.
20) Wire a String Constant with the text “5V Channel” to the Channel Name input.
21) Run the 5V case of the case structure with the Function Generator Running. Stop the VI after a
few seconds.
23) Run the VI you created with the TDMS File Viewer VI.
24) When the File Viewer opens, click on “test.tdms” under File Contents to update the File
Viewer. Expand the File Contents tree and record the changes that occurred after including a
Group Name and Channel Name.
26) Save the File Viewer VI and save this VI as Data Acquisition with cDAQ – Data Logging. VI.
Virtual Instrumentation 6
File I/O | Laboratory 5
Questions
1) What are benefits of using the Express VI?
Virtual Instrumentation 7
VIRTUAL INSTRUMENTATION
Lab 5
File I/O
Section 1
File I/O
In this lab, you will expand upon the DAQmx code you created in Lab 3 in order to explore File
I/O.
Monitoring applications often run for an extended period of time. In order to save the data that
is gathered, you’re going to setup your temperature monitor to log the data to a file.
You will first observe how easy it is to use Express VIs for File I/O and will later explore using
TDMS.
Pre-lab Questions:
1) What kind of information would you want included in a data log?
2) In the VI we made in Lab 4, what would be relevant information to log and why?
Virtual Instrumentation 2
File I/O | Laboratory 5
Procedure
Configuring Hardware
1) Keep the same wiring configuration as in Lab 4.
5) Place the Write to Measurement File Express VI on the Block Diagram outside of the While
Loop.
6) When the window opens, set the Filename to save as “Test” on your desktop.
9) Wire the waveform data out of the While Loop to the input of the Write to Measurement File
Express VI.
Virtual Instrumentation 3
File I/O | Laboratory 5
12) Run the VI. Stop the VI after a few seconds with the Stop button that you created.
13) Navigate to the “Test” file you created on your desktop and open it with Excel. Observe that
your data has been logged.
14) Returning to the Block Diagram, double-click the Write to Measurement File Express VI
and notice some of the settings you can change such as “Action”, “If a File Already Exists,”
“Segment Headers,” and “X Value Columns.” Change each one of these and record what the
result is.
Virtual Instrumentation 4
File I/O | Laboratory 5
Part B – TDMS
1) Delete the Write to Measurement File Express VI.
2) On the Block Diagram, locate the TDMS Streaming Palette within the File I/O Palette.
3) Outside of the while loop place a TDMS Open and TDMS Close. Inside the while loop, place
a TDMS Write.
4) Wire the File Wires and Error Wires so that all three VIs are wired together.
5) Wire the Waveform data to the Data Input of the TDMS Write.
6) Create a control for the File Path input of the TDMS Open.
7) Right-click the File Path Control on the Front Panel and choose Browse Options.
8) Select New or Existing as the Selection Mode and close the window by clicking Ok.
9) Create a constant for the Operation input of the TDMS Open and set the constant to Create
or Replace.
10) Make sure that your code matches the image shown.
11) Enter a file path in the control on the Front Panel that points to a file called “test.tdms” on
your desktop.
Virtual Instrumentation 5
File I/O | Laboratory 5
14) Create a new VI and place the TDMS File Viewer VI on the Block Diagram.
15) Create a File Path Control input to the TDMS File Viewer.
16) In the control on the Front Panel of the new VI, select the “test.tdms” file on your desktop and
run the VI.
17) Notice that the TDMS File Viewer opens. Explore the File Viewer.
18) Returning to the original VI, notice that the TDMS Write has inputs for Channel Name and
Group Name.
19) Wire a String Constant with the text “Data Acquisition” to the Group Name input.
20) Wire a String Constant with the text “5V Channel” to the Channel Name input.
21) Run the 5V case of the case structure with the Function Generator Running. Stop the VI after a
few seconds.
23) Run the VI you created with the TDMS File Viewer VI.
24) When the File Viewer opens, click on “test.tdms” under File Contents to update the File
Viewer. Expand the File Contents tree and record the changes that occurred after including a
Group Name and Channel Name.
26) Save the File Viewer VI and save this VI as Data Acquisition with ELVIS – Data Logging. VI.
Virtual Instrumentation 6
File I/O | Laboratory 5
Questions
1) What are benefits of using the Express VI?
Virtual Instrumentation 7
VIRTUAL INSTRUMENTATION
Lab 6
Modularity
Section 1 – Modularity
--------------------------------------------------------------------------- 2
Configuring Hardware
--------------------------------------------------------------------------- 3
Creating SubVIs
--------------------------------------------------------------------------- 3
Method 1: Converting Existing Code into a SubVI
--------------------------------------------------------------------------- 3
Method 2: Creating a New SubVI
--------------------------------------------------------------------------- 4
Modularity | Laboratory 6
Section 1
Modularity
In this lab, you will expand upon the DAQmx code you created in Lab 5 in order to learn modularity
and to ultimately create a SubVI and understand its use.
Within all applications, modularity gives the ability to easily make changes in a single place and
have that change carried out in multiple places in the code.
Pre-Lab Questions:
1) What is modularity?
Virtual Instrumentation 2
Modularity | Laboratory 6
Lab Procedure
Configuring Hardware
1) Keep the same wiring configuration as in Lab 5.
Creating SubVIs
There are two ways to create SubVI’s.
1) Open the TDMS code from Lab 5, Data Acquisition with cDAQ – Data Logging.
If you didn’t complete this VI, ask your instructor for access to a VI to use as the starting
point for this lab.
2) Copy and paste the code from Lab 5 into a new VI.
4) Highlight the Get Waveform Components VI and the three indicators associated with it.
6) Notice that the Get Waveform Components VI is now replaced by a different icon.
7) Double click on this new icon and record what you observe on the Block Diagram of the
new VI that opens. Save the SubVI as Waveform Components.vi.
8) On the Front Panel of the SubVI add an Error In and Error Out cluster from the Array, Matrix,
and Cluster Palette.
9) Right-click on the icon in the upper right corner and select Show Connector.
Virtual Instrumentation 3
Modularity | Laboratory 6
13) To connect a pattern n to a front panel object, first click the pattern terminal and then click
the object that you would like to link it to.
16) Link the 4 terminals along the right side to the Y array, t0 timestamp, dt numeric, and error
out cluster, from top to bottom.
17) Notice that the colors of the terminals change when they are linked.
18) The new color corresponds to the color associated with the data type for the object that it is
linked to. For example, the error in and out clusters are yellow.
20) Use the Icon Editor to create an icon that reminds you of what this subVI does.
22) Close the subVI and notice that the icon you made is now the icon being used on your
original VI.
23) Because you edited the Connector Pane of the subVI to include terminals for Error In and
Error Out, right click the subVI icon in the main VI and choose Relink to SubVI.
3) On the Front Panel add Error In and Error Out Cluster as in Method 1.
Virtual Instrumentation 4
Modularity | Laboratory 6
7) Click the first input on the Connector Pane and then click one of the control inputs on the Front
Panel.
13) Return to your original VI (Data Acquisition with cDAQ - SubVIs.vi) and right-click on the Block
Diagram.
14) Choose Select a VI on the Functions Palette and choose the Multiply.vi you just made.
15) Wire the ‘Y’ output of the Waveform components VI you made to the input of an Index Array
function.
16) Wire the output of the Index Array Function to an input of the Multiply SubVI you just made.
Virtual Instrumentation 5
Modularity | Laboratory 6
Virtual Instrumentation 6
Modularity | Laboratory 6
Questions
1) What are some benefits of using subVIs when your Block Diagram begins to get cluttered?
2) What are some benefits of using subVIs specifically with data acquisition?
4) What is the output of the Index Array function that you used?
Virtual Instrumentation 7
VIRTUAL INSTRUMENTATION
Lab 6
Modularity
Section 1 – Modularity
--------------------------------------------------------------------------- 2
Configuring Hardware
--------------------------------------------------------------------------- 3
Creating SubVIs
--------------------------------------------------------------------------- 3
Method 1: Converting Existing Code into a SubVI
--------------------------------------------------------------------------- 3
Method 2: Creating a New SubVI
--------------------------------------------------------------------------- 4
Modularity | Laboratory 6
Section 1
Modularity
In this lab, you will expand upon the DAQmx code you created in Lab 5 in order to learn modularity
and to ultimately create a SubVI and understand its use.
Within all applications, modularity gives the ability to easily make changes in a single place and
have that change carried out in multiple places in the code.
Pre-Lab Questions:
1) What is modularity?
Virtual Instrumentation 2
Modularity | Laboratory 6
Lab Procedure
Configuring Hardware
1) Keep the same wiring configuration as in Lab 5.
Creating SubVIs
There are two ways to create SubVI’s.
1) Open the TDMS code from Lab 5, Data Acquisition with ELVIS – Data Logging.
If you didn’t complete this VI, ask your instructor for access to a VI to use as the starting
point for this lab.
2) Copy and paste the code from Lab 5 into a new VI.
4) Highlight the Get Waveform Components VI and the three indicators associated with it.
6) Notice that the Get Waveform Components VI is now replaced by a different icon.
7) Double click on this new icon and record what you observe on the Block Diagram of the
new VI that opens. Save the SubVI as Waveform Components.vi.
8) On the Front Panel of the SubVI add an Error In and Error Out cluster from the Array, Matrix,
and Cluster Palette.
9) Right-click on the icon in the upper right corner and select Show Connector.
Virtual Instrumentation 3
Modularity | Laboratory 6
13) To connect a pattern n to a front panel object, first click the pattern terminal and then click
the object that you would like to link it to.
16) Link the 4 terminals along the right side to the Y array, t0 timestamp, dt numeric, and error
out cluster, from top to bottom.
17) Notice that the colors of the terminals change when they are linked.
18) The new color corresponds to the color associated with the data type for the object that it is
linked to. For example, the error in and out clusters are yellow.
20) Use the Icon Editor to create an icon that reminds you of what this subVI does.
22) Close the subVI and notice that the icon you made is now the icon being used on your
original VI.
23) Because you edited the Connector Pane of the subVI to include terminals for Error In and
Error Out, right click the subVI icon in the main VI and choose Relink to SubVI.
3) On the Front Panel add Error In and Error Out Cluster as in Method 1.
Virtual Instrumentation 4
Modularity | Laboratory 6
7) Click the first input on the Connector Pane and then click one of the control inputs on the Front
Panel.
13) Return to your original VI (Data Acquisition with ELVIS - SubVIs.vi) and right-click on the Block
Diagram.
14) Choose Select a VI on the Functions Palette and choose the Multiply.vi you just made.
15) Wire the ‘Y’ output of the Waveform components VI you made to the input of an Index Array
function.
16) Wire the output of the Index Array Function to an input of the Multiply SubVI you just made.
Virtual Instrumentation 5
Modularity | Laboratory 6
Virtual Instrumentation 6
Modularity | Laboratory 6
Questions
1) What are some benefits of using subVIs when your Block Diagram begins to get cluttered?
2) What are some benefits of using subVIs specifically with data acquisition?
4) What is the output of the Index Array function that you used?
Virtual Instrumentation 7
VIRTUAL INSTRUMENTATION
Lab 7
Data Acquisition
Section 1
Data Acquisition
In this lab you will explore more deeply the idea of data acquisition by utilizing more functionality of
the cDAQ and LabVIEW. You will use a case structure to observe different types of data acquisition.
As a monitoring application, it’s common to need to signal when certain conditions are met. In this
temperature monitoring application, you’ll use a digital signal to turn on and off an LED. In later
exercises, you will determine the conditions to turn the digital signal on or off.
Parts List:
The following equipment is required for this experiment:
-- 1 220Ω resistor
-- 1 LED
-- Wires
Pre-Lab Questions:
1) Signals are either analog or digital. What is the difference between the two?
2) Based on the analog code that you have written in Labs 1 through 6, what modifications
need to be made to write a digital logic high?
3) What is one application that would use an analog signal and one that would use a digital
signal?
Virtual Instrumentation 2
Data Acquisition | Laboratory 7
Lab Procedure
Configuring Hardware
1) Keep the same wiring configuration as in Lab 6. You’re going to add a connection to the
Digital Input/Output card.
3) From the cDAQ Digital Input/Output card, connect output channel 0 to the anode of the LED.
The anode is usually the longer lead of the LED.
5) To remove the Case Structure and keep the code that is inside of it, make sure the True case
is visible, and then right-click the Case Structure and select Remove Case Structure.
Virtual Instrumentation 3
Data Acquisition | Laboratory 7
6) Delete the code that isn’t needed and add the code that’s missing so that it matches the
image shown.
8) On the Front Panel, place an Enumerated Control. Right-click on the control and choose
Edit Items.
9) Insert items “Analog” and “Digital” making sure that “Analog” is item 0 and “Digital” is
item 1.
10) Move back to the Block Diagram and wire the Enum to the Case Selector of the Case
Structure.
11) Make sure that the current code is in the default “Analog” case. If it is not, right-click on the
case structure and choose Make this Case “Analog”, Default.
Virtual Instrumentation 4
Data Acquisition | Laboratory 7
3) Configure the Create Channel for Digital Out and the DAQmx Write for Digital>>Single
Channel>>Single Sample>>Boolean (1 line).
5) Create a constant for the “Lines” input of the Create Channel and select cDAQ1Mod2/port0/
line0.
8) Make a Stop Button for the While Loop and label it Digital.
9) Confirm that the hardware is setup as defined in the Configuring Hardware section.
11) On the front panel, select Digital from the Enum control.
Virtual Instrumentation 5
Data Acquisition | Laboratory 7
Virtual Instrumentation 6
Data Acquisition | Laboratory 7
Questions
1) Describe the behavior of each case.
2) Why does changing the Enum while the code is running have no effect on the VI?
3) In the digital case, what happens if the digital line is set high (i.e. the LED is illuminated)
and the VI is stopped? Why is this?
Virtual Instrumentation 7
VIRTUAL INSTRUMENTATION
Lab 7
Data Acquisition
Section 1
Data Acquisition
In this lab you will explore more deeply the idea of data acquisition by utilizing more functionality of
the NI ELVIS and LabVIEW. You will use a case structure to observe different types of data acquisition.
As a monitoring application, it’s common to need to signal when certain conditions are met. In this
temperature monitoring application, you’ll use a digital signal to turn on and off an LED. In later
exercises, you will determine the conditions to turn the digital signal on or off.
Parts List:
The following equipment is required for this experiment:
-- 1 220Ω resistor
-- 1 LED
-- Wires
Pre-Lab Questions:
1) Signals are either analog or digital. What is the difference between the two?
2) Based on the analog code that you have written in Labs 1 through 6, what modifications
need to be made to write a digital logic high?
3) What is one application that would use an analog signal and one that would use a digital
signal?
Virtual Instrumentation 2
Data Acquisition | Laboratory 7
Lab Procedure
Configuring Hardware
1) Keep the same wiring configuration as in Lab 6. You’re going to add a connection to the
Digital Input/Output.
3) From the NI ELVIS, connect output channel 0 to the anode of the LED. The anode is usually
the longer lead of the LED.
5) To remove the Case Structure and keep the code that is inside of it, make sure the True case
is visible, and then right-click the Case Structure and select Remove Case Structure.
Virtual Instrumentation 3
Data Acquisition | Laboratory 7
6) Delete the code that isn’t needed and add the code that’s missing so that it matches the
image shown.
8) On the Front Panel, place an Enumerated Control. Right-click on the control and choose
Edit Items.
9) Insert items “Analog” and “Digital” making sure that “Analog” is item 0 and “Digital” is
item 1.
10) Move back to the Block Diagram and wire the Enum to the Case Selector of the Case
Structure.
11) Make sure that the current code is in the default “Analog” case. If it is not, right-click on the
case structure and choose Make this Case “Analog”, Default.
Virtual Instrumentation 4
Data Acquisition | Laboratory 7
3) Configure the Create Channel for Digital Out and the DAQmx Write for Digital>>Single
Channel>>Single Sample>>Boolean (1 line).
5) Create a constant for the “Lines” input of the Create Channel and select Dev1/port0/line0 .
8) Make a Stop Button for the While Loop and label it Digital.
9) Confirm that the hardware is setup as defined in the Configuring Hardware section.
11) On the front panel, select Digital from the Enum control.
Virtual Instrumentation 5
Data Acquisition | Laboratory 7
Virtual Instrumentation 6
Data Acquisition | Laboratory 7
Questions
1) Describe the behavior of each case.
2) Why does changing the Enum while the code is running have no effect on the VI?
3) In the digital case, what happens if the digital line is set high (i.e. the LED is illuminated)
and the VI is stopped? Why is this?
Virtual Instrumentation 7
VIRTUAL INSTRUMENTATION
Lab 8
Common Design
Architectures
Section 1
Common Design Architectures
Using a collection of LabVIEW skills covered previously, a State Machine will be implemented using
the two states defined in Lab 7 (analog and digital).
In the temperature monitoring application, there are a few different states that the program can be
in. It’s often beneficial to separate a program into different states so that you can organize your code
more cleanly. Additionally, using a State Machine, you can define different conditions for when to
send your program into each state. In this way, your program can run a different sequence of code
depending on the results of a previous sequence.
This is an incredibly powerful capability, and will be necessary for the temperature monitor. Most
of the time, the temperature monitor will simply be in a state of acquiring temperature data. That
temperature data is going to determine if and when the program should go into a different state to
change the value of our status indicator LED.
We’ll learn more about how to use conditions to change the order of execution of our states in the
next lab. In this lab, we’ll focus on the structure of a State Machine.
Pre-Lab Questions:
1) What were some of the limitations of the code in Lab 7?
Virtual Instrumentation 2
Common Design Architectures | Laboratory 8
Lab Procedure
Configuring Hardware
1) Keep the same hardware configuration as was used in Lab 7.
4) Highlight the Enumerated control on the Front Panel and select Edit>>Customize Control.
6) Edit the items of the Enum so that Stop is item 0, Analog is item 1, Digital is item 2, and Idle
is item 3.
8) Close the Type Definition window, and allow the original Enum that was placed on the Front
Panel to be replaced with the Type Definition.
9) On the Block Diagram, place a While Loop around the Case Structure.
10) Right-click on the Enum on the Block Diagram and change it to a constant.
11) Place the constant to the left of the While Loop and wire it through the While Loop to the
case selector of the Case Structure.
12) Right-click on the Case Structure and add a case for every value of the Case Structure.
13) Select the “Idle” case. Right-click the Case Structure and select Make This The Default Case.
Virtual Instrumentation 3
Common Design Architectures | Laboratory 8
14) Right-click on the tunnel going into the While Loop from the Enum constant and select
Replace with Shift Registers.
Virtual Instrumentation 4
Common Design Architectures | Laboratory 8
2) Create the code as shown. Notice that an array of Enum constants is wired to the Index Array.
3) For the analog and digital cases, copy and paste the code from their respective cases in Lab 7.
Make the minor modifications seen in the images shown.
Virtual Instrumentation 5
Common Design Architectures | Laboratory 8
5) Run the code and experiment with clicking the different buttons on the Front Panel.
6) Record the behavior associated with each button and if there is any indication on the cDAQ
that corresponds with a certain case.
Virtual Instrumentation 6
Common Design Architectures | Laboratory 8
Questions
1) What are the basic components of a State Machine? (i.e. what components must be present
in order for this architecture to be implemented?)
Virtual Instrumentation 7
VIRTUAL INSTRUMENTATION
Lab 8
Common Design
Architectures
Section 1
Common Design Architectures
Using a collection of LabVIEW skills covered previously, a State Machine will be implemented using
the two states defined in Lab 7 (analog and digital).
In the temperature monitoring application, there are a few different states that the program can be
in. It’s often beneficial to separate a program into different states so that you can organize your code
more cleanly. Additionally, using a State Machine, you can define different conditions for when to
send your program into each state. In this way, your program can run a different sequence of code
depending on the results of a previous sequence.
This is an incredibly powerful capability, and will be necessary for the temperature monitor. Most
of the time, the temperature monitor will simply be in a state of acquiring temperature data. That
temperature data is going to determine if and when the program should go into a different state to
change the value of our status indicator LED.
We’ll learn more about how to use conditions to change the order of execution of our states in the
next lab. In this lab, we’ll focus on the structure of a State Machine.
Pre-Lab Questions:
1) What were some of the limitations of the code in Lab 7?
Virtual Instrumentation 2
Common Design Architectures | Laboratory 8
Lab Procedure
Configuring Hardware
1) Keep the same hardware configuration as was used in Lab 7.
4) Highlight the Enumerated control on the Front Panel and select Edit>>Customize Control.
6) Edit the items of the Enum so that Stop is item 0, Analog is item 1, Digital is item 2, and Idle
is item 3.
8) Close the Type Definition window, and allow the original Enum that was placed on the Front
Panel to be replaced with the Type Definition.
9) On the Block Diagram, place a While Loop around the Case Structure.
10) Right-click on the Enum on the Block Diagram and change it to a constant.
11) Place the constant to the left of the While Loop and wire it through the While Loop to the
case selector of the Case Structure.
12) Right-click on the Case Structure and add a case for every value of the Case Structure.
13) Select the “Idle” case. Right-click the Case Structure and select Make This The Default Case.
Virtual Instrumentation 3
Common Design Architectures | Laboratory 8
14) Right-click on the tunnel going into the While Loop from the Enum constant and select
Replace with Shift Registers.
Virtual Instrumentation 4
Common Design Architectures | Laboratory 8
2) Create the code as shown. Notice that an array of Enum constants is wired to the Index Array.
3) For the analog and digital cases, copy and paste the code from their respective cases in Lab 7.
Make the minor modifications seen in the images shown.
Virtual Instrumentation 5
Common Design Architectures | Laboratory 8
5) Run the code and experiment with clicking the different buttons on the Front Panel.
6) Record the behavior associated with each button and if there is any indication on the ELVIS
that corresponds with a certain case.
Virtual Instrumentation 6
Common Design Architectures | Laboratory 8
Questions
1) What are the basic components of a State Machine? (i.e. what components must be present
in order for this architecture to be implemented?)
Virtual Instrumentation 7
VIRTUAL INSTRUMENTATION
Lab 9
Programmatic
Decision Making
Section 1
Programmatic Decision Making
Using a collection of LabVIEW skills covered previously, students will implement decision making
within their State Machine.
In the previous lab, the State Machine waited for the user to click a button before choosing which
state to go to.
Pre-Lab Questions:
1) What were some of the limitations of the State Machine implemented in Lab 8?
2) What are some examples of when a program will need to do a different order of actions,
depending on the results of one of the actions?
Virtual Instrumentation 2
Programmatic Decision Making | Laboratory 9
Lab Procedure
Configuring Hardware
1) Keep the same hardware configuration as was used in Lab 8.
Defining a Condition
1) Open the code from Lab 8, Data Acquisition with cDAQ - State Machine.vi.
If you didn’t complete this VI, ask your instructor for access to a VI to use as the starting
point for this lab.
4) In the Analog case, select Select a VI from the functions palette and find the Check For
Temperature Condition VI that is provided.
6) Create controls for Upper Temperature Limit and Lower Temperature Limit.
7) Use an Or function to determine if either of the temperature conditions have been met.
9) Wire the output of the Or function to the right input of the Shift Register.
10) On the left input of the Shift Register, create a False constant. This will initialize the shift
register with a value of False.
11) Place an Equal function, and compare whether the current temperature condition is equal
to the temperature condition on the previous iteration.
12) If the condition is the same, send the State Machine to the Idle Case. If the condition is
different, send the State Machine to the Digital state. In the Digital state, you’ll update the
status of the LED.
Virtual Instrumentation 3
Programmatic Decision Making | Laboratory 9
3) Delete the array of Boolean values and wire the value from the Shift Register into the Write
function.
Virtual Instrumentation 4
Programmatic Decision Making | Laboratory 9
3) Replace the existing code which builds and searches an array with a simple Select function.
4) Wire the value from the left side of the Shift Register through the Idle case to the right side of
the Shift Register.
Virtual Instrumentation 5
Programmatic Decision Making | Laboratory 9
Questions
1) Describe what the new shift register is doing. How is this used to determine when to turn
on or off the LED?
2) Open the Check For Temperature Condition VI that is provided. Describe what this VI is
doing.
3) What would happen if the data in the shift register was not wired through the Idle case, and
was instead overwritten with a True or False constant?
Virtual Instrumentation 6
Programmatic Decision Making | Laboratory 9
Virtual Instrumentation 7
VIRTUAL INSTRUMENTATION
Lab 9
Programmatic
Decision Making
Section 1
Programmatic Decision Making
Using a collection of LabVIEW skills covered previously, students will implement decision making
within their State Machine.
In the previous lab, the State Machine waited for the user to click a button before choosing which
state to go to.
Pre-Lab Questions:
1) What were some of the limitations of the State Machine implemented in Lab 8?
2) What are some examples of when a program will need to do a different order of actions,
depending on the results of one of the actions?
Virtual Instrumentation 2
Programmatic Decision Making | Laboratory 9
Lab Procedure
Configuring Hardware
1) Keep the same hardware configuration as was used in Lab 8.
Defining a Condition
1) Open the code from Lab 8, Data Acquisition with ELVIS - State Machine.vi.
If you didn’t complete this VI, ask your instructor for access to a VI to use as the starting
point for this lab.
4) In the Analog case, select Select a VI from the functions palette and find the Check For
Temperature Condition VI that is provided.
6) Create controls for Upper Temperature Limit and Lower Temperature Limit.
7) Use an Or function to determine if either of the temperature conditions have been met.
9) Wire the output of the Or function to the right input of the Shift Register.
10) On the left input of the Shift Register, create a False constant. This will initialize the shift
register with a value of False.
11) Place an Equal function, and compare whether the current temperature condition is equal
to the temperature condition on the previous iteration.
12) If the condition is the same, send the State Machine to the Idle Case. If the condition is
different, send the State Machine to the Digital state. In the Digital state, you’ll update the
status of the LED.
Virtual Instrumentation 3
Programmatic Decision Making | Laboratory 9
15) Right-click the For Loop and select Remove For Loop.
16) Delete the array of Boolean values and wire the value from the Shift Register into the Write
function.
Virtual Instrumentation 4
Programmatic Decision Making | Laboratory 9
3) Replace the existing code which builds and searches an array with a simple Select function.
4) Wire the value from the left side of the Shift Register through the Idle case to the right side of
the Shift Register.
Virtual Instrumentation 5
Programmatic Decision Making | Laboratory 9
Questions
1) Describe what the new shift register is doing. How is this used to determine when to turn
on or off the LED?
2) Open the Check For Temperature Condition VI that is provided. Describe what this VI is
doing.
3) What would happen if the data in the shift register was not wired through the Idle case, and
was instead overwritten with a True or False constant?
Virtual Instrumentation 6
Programmatic Decision Making | Laboratory 9
Virtual Instrumentation 7
VIRTUAL INSTRUMENTATION
Lab 10
Communicating
Among Multiple
Loops with Queues
Section 1 – Communicating Among Multiple Loops with
Queues
--------------------------------------------------------------------------- 2
Configuring Hardware
--------------------------------------------------------------------------- 4
Implementing the Producer/Consumer Architecture
--------------------------------------------------------------------------- 4
The Top Loop
--------------------------------------------------------------------------- 4
The Bottom Loop
--------------------------------------------------------------------------- 7
Communicating Among Multiple Loops with Queues | Laboratory 10
Section 1
Communicating Among
Multiple Loops with Queues
The objective of this lab is to understand multiple ways of communicating between multiple
loops. Queues will be implemented in this lab, but through discussion questions, queues will be
contrasted to notifiers and variables.
In a temperature monitoring application, it is often important to log the data that is acquired. In this
application, temperature data will be logged to a TDMS file.
Often data logging is done in a loop that runs in parallel to the data acquisition loop. In this way, the
time it takes to save data to a file will not affect the timing of acquiring data.
You will explore these parallel loops and communication between them in this lab.
Pre-Lab Questions:
1) Will the loops below run in parallel or one after the other? If so, which will run first?
Virtual Instrumentation 2
Communicating Among Multiple Loops with Queues | Laboratory 10
2) What is a potential modification that could be made to the code in question 1 so that both
loops run continuously until a single stop button is clicked?
Virtual Instrumentation 3
Communicating Among Multiple Loops with Queues | Laboratory 10
Lab Procedure
Configuring Hardware
1) Keep the same hardware configuration as was used in Lab 9.
4) In LabVIEW, select File>>New. Open the Producer/Consumer Design Pattern (Data) under
VI>>From Template>>Frameworks>>Design Patterns. Use this design pattern as an example
for implementing the design pattern into the state machine code.
2) Remember that the “Obtain Queue” needs to have the data type defined for the element
being stored in the queue. In this case, the waveform data from the analog case will be
passed through the queue. In order to define this data type, make a copy of the waveform
chart indicator and change it to a constant. Wire this constant to the “Obtain Queue.”
Virtual Instrumentation 4
Communicating Among Multiple Loops with Queues | Laboratory 10
3) Configure the “Idle Case,” “Digital Case,” and “Stop Cases” as shown.
Virtual Instrumentation 5
Communicating Among Multiple Loops with Queues | Laboratory 10
4) Include the “Enqueue Element” in the Analog Case and configure it as shown.
Virtual Instrumentation 6
Communicating Among Multiple Loops with Queues | Laboratory 10
2) Use a File Dialog Express VI to Create or Open a file. Set pattern (all files) to *.tdms.
4) Specify a file path to save a .tdms file in the file path constant.
6) Define the range of the temperature warning to create a warning. Notice that the LED turns
on.
7) Define the range of the temperature warning so that the LED turns off.
9) Use the TDMS Viewer VI used in Lab 5 to view the Analog data.
Virtual Instrumentation 7
Communicating Among Multiple Loops with Queues | Laboratory 10
Questions
1) How does the code know to stop if there is no stop button wired to the bottom loop
condition terminal?
2) Why is it good practice to not have analysis and acquisition in the same loop?
3) Could this same idea be implemented with variables? If so, what are the pros and cons of
using variables in this application?
4) Could notifiers be used in this application? If so what are the pros and cons of using
notifiers?
5) Could semaphores be used directly in this application in the same manner that the queues
are used? Why or why not?
Virtual Instrumentation 8
VIRTUAL INSTRUMENTATION
Lab 10
Communicating
Among Multiple
Loops with Queues
Section 1 – Communicating Among Multiple Loops with
Queues
--------------------------------------------------------------------------- 2
Configuring Hardware
--------------------------------------------------------------------------- 4
Implementing the Producer/Consumer Architecture
--------------------------------------------------------------------------- 4
The Top Loop
--------------------------------------------------------------------------- 4
The Bottom Loop
--------------------------------------------------------------------------- 7
Communicating Among Multiple Loops with Queues | Laboratory 10
Section 1
Communicating Among
Multiple Loops with Queues
The objective of this lab is to understand multiple ways of communicating between multiple
loops. Queues will be implemented in this lab, but through discussion questions, queues will be
contrasted to notifiers and variables.
In a temperature monitoring application, it is often important to log the data that is acquired. In this
application, temperature data will be logged to a TDMS file.
Often data logging is done in a loop that runs in parallel to the data acquisition loop. In this way, the
time it takes to save data to a file will not affect the timing of acquiring data.
You will explore these parallel loops and communication between them in this lab.
Pre-Lab Questions:
1) Will the loops below run in parallel or one after the other? If so, which will run first?
Virtual Instrumentation 2
Communicating Among Multiple Loops with Queues | Laboratory 10
2) What is a potential modification that could be made to the code in question 1 so that both
loops run continuously until a single stop button is clicked?
Virtual Instrumentation 3
Communicating Among Multiple Loops with Queues | Laboratory 10
Lab Procedure
Configuring Hardware
1) Keep the same hardware configuration as was used in Lab 9.
4) In LabVIEW, select File>>New. Open the Producer/Consumer Design Pattern (Data) under
VI>>From Template>>Frameworks>>Design Patterns. Use this design pattern as an example
for implementing the design pattern into the state machine code.
2) Remember that the “Obtain Queue” needs to have the data type defined for the element
being stored in the queue. In this case, the waveform data from the analog case will be
passed through the queue. In order to define this data type, make a copy of the waveform
chart indicator and change it to a constant. Wire this constant to the “Obtain Queue.”
Virtual Instrumentation 4
Communicating Among Multiple Loops with Queues | Laboratory 10
3) Configure the “Idle Case,” “Digital Case,” and “Stop Cases” as shown.
Virtual Instrumentation 5
Communicating Among Multiple Loops with Queues | Laboratory 10
4) Include the “Enqueue Element” in the Analog Case and configure it as shown.
Virtual Instrumentation 6
Communicating Among Multiple Loops with Queues | Laboratory 10
2) Use a File Dialog Express VI to Create or Open a file. Set pattern (all files) to *.tdms.
4) Specify a file path to save a .tdms file in the file path constant.
6) Define the range of the temperature warning to create a warning. Notice that the LED turns
on.
7) Define the range of the temperature warning so that the LED turns off.
9) Use the TDMS Viewer VI used in Lab 5 to view the Analog data.
Virtual Instrumentation 7
Communicating Among Multiple Loops with Queues | Laboratory 10
Questions
1) How does the code know to stop if there is no stop button wired to the bottom loop
condition terminal?
2) Why is it good practice to not have analysis and acquisition in the same loop?
3) Could this same idea be implemented with variables? If so, what are the pros and cons of
using variables in this application?
4) Could notifiers be used in this application? If so what are the pros and cons of using
notifiers?
5) Could semaphores be used directly in this application in the same manner that the queues
are used? Why or why not?
Virtual Instrumentation 8
VIRTUAL INSTRUMENTATION
Lab 11
Event Programming
and Improving an
Existing VI
Section 1 – Event Programming and Improving an
Existing VI
--------------------------------------------------------------------------- 2
Configuring Hardware
--------------------------------------------------------------------------- 3
Implementing Notify Events
--------------------------------------------------------------------------- 3
Implementing Filter Events
--------------------------------------------------------------------------- 5
Disregarding Errors
--------------------------------------------------------------------------- 6
Event Programming and Improving an Existing VI | Laboratory 11
Section 1
Event Programming and
Improving an Existing VI
The objective of this lab is to understand how events can be used as a case structure and can offer
more options as to how a case is handled. This lab builds directly off of Lab 10 and teaches how to
use events instead of a case structure in the producer/consumer design pattern. The lab also briefly
touches on using local variables. Finally, the lab discusses improving an existing VI.
In our temperature monitoring application, it is important that the monitoring code runs at the
proper frequency, but we want the front panel to be responsive to user interaction. In this lab you
will explore one way to implement this.
Pre-Lab Questions:
1) What could be improved in the code
shown?
2) What is a benefit of using an Event Structure over a Case Structure?
3) Can the functionality of a state machine be implemented with events? Why or why not?
Virtual Instrumentation 2
Event Programming and Improving an Existing VI | Laboratory 11
Lab Procedure
Configuring Hardware
1) Keep the same hardware configuration as was used in Lab 10.
2) Open the VI created in Lab 10, Data Acquisition with cDAQ – Producer Consumer.vi, and
copy and paste it into a new VI.
If you didn’t complete this VI, ask your instructor for access to a VI to use as the starting
point for this lab.
4) Place down an event structure inside of the case structure in the Idle case.
5) Right-click on the border of the event structure and select Add Event Case….
8) Move the terminal for the Stop button into the Stop case.
10) Wire a value of 250 into the Event Timeout terminal for the Event Structure.
Virtual Instrumentation 3
Event Programming and Improving an Existing VI | Laboratory 11
12) Run the code. Notice that every 250 ms, the analog case is running.
13) The analog case will still trigger the digital case if a digital warning appears.
Virtual Instrumentation 4
Event Programming and Improving an Existing VI | Laboratory 11
Virtual Instrumentation 5
Event Programming and Improving an Existing VI | Laboratory 11
Disregarding Errors
1) Copy and paste Lab 9 Part 1 into a new VI.
2) Create a local variable from the stop button in the “Stop” event case. Do this by either right-
clicking the button and selecting Create>>Local Variable or by placing down a blank local
variable from the Structures Palette and assigning it to the stop button by right-clicking it and
selecting Select Item>>Stop. You can also left-click on a new local variable to populate the
Front Panel controls the variable can be linked to.
3) A local variable can be changed from read to write by right-clicking on the local variable and
selecting Change to Read. Change the new local variable to be reading.
4) In the bottom loop, delete the error wire going into the loop condition terminal and wire the
new local variable to the loop condition terminal instead.
5) On the Front Panel, right-click on the stop button and change its mechanical action to Switch
Until Released.
7) Run the code and notice that it runs the same as before. Stop the code when done.
Virtual Instrumentation 6
Event Programming and Improving an Existing VI | Laboratory 11
Questions
1) What is the difference between a notify event and a filter event?
2) What happens if the Digital Button is clicked while the analog case is running? Will that
event be processed?
3) What is a potential application of using the local variable in the bottom loop instead of
wiring the error wire to the loop condition terminal?
4) What is the best way to handle code that is repeated multiple times in a VI?
Virtual Instrumentation 7
VIRTUAL INSTRUMENTATION
Lab 11
Event Programming
and Improving an
Existing VI
Section 1 – Event Programming and Improving an
Existing VI
--------------------------------------------------------------------------- 2
Configuring Hardware
--------------------------------------------------------------------------- 3
Implementing Notify Events
--------------------------------------------------------------------------- 3
Implementing Filter Events
--------------------------------------------------------------------------- 5
Disregarding Errors
--------------------------------------------------------------------------- 6
Event Programming and Improving an Existing VI | Laboratory 11
Section 1
Event Programming and
Improving an Existing VI
The objective of this lab is to understand how events can be used as a case structure and can offer
more options as to how a case is handled. This lab builds directly off of Lab 10 and teaches how to
use events instead of a case structure in the producer/consumer design pattern. The lab also briefly
touches on using local variables. Finally, the lab discusses improving an existing VI.
In our temperature monitoring application, it is important that the monitoring code runs at the
proper frequency, but we want the front panel to be responsive to user interaction. In this lab you
will explore one way to implement this.
Pre-Lab Questions:
1) What could be improved in the code
shown?
2) What is a benefit of using an Event Structure over a Case Structure?
3) Can the functionality of a state machine be implemented with events? Why or why not?
Virtual Instrumentation 2
Event Programming and Improving an Existing VI | Laboratory 11
Lab Procedure
Configuring Hardware
1) Keep the same hardware configuration as was used in Lab 10.
2) Open the VI created in Lab 10, Data Acquisition with ELVIS – Producer Consumer.vi, and
copy and paste it into a new VI.
If you didn’t complete this VI, ask your instructor for access to a VI to use as the starting
point for this lab.
4) Place down an event structure inside of the case structure in the Idle case.
5) Right-click on the border of the event structure and select Add Event Case….
8) Move the terminal for the Stop button into the Stop case.
10) Wire a value of 250 into the Event Timeout terminal for the Event Structure.
Virtual Instrumentation 3
Event Programming and Improving an Existing VI | Laboratory 11
12) Run the code. Notice that every 250 ms, the analog case is running.
13) The analog case will still trigger the digital case if a digital warning appears.
Virtual Instrumentation 4
Event Programming and Improving an Existing VI | Laboratory 11
Virtual Instrumentation 5
Event Programming and Improving an Existing VI | Laboratory 11
Disregarding Errors
1) Copy and paste Lab 9 Part 1 into a new VI.
2) Create a local variable from the stop button in the “Stop” event case. Do this by either right-
clicking the button and selecting Create>>Local Variable or by placing down a blank local
variable from the Structures Palette and assigning it to the stop button by right-clicking it and
selecting Select Item>>Stop. You can also left-click on a new local variable to populate the
Front Panel controls the variable can be linked to.
3) A local variable can be changed from read to write by right-clicking on the local variable and
selecting Change to Read. Change the new local variable to be reading.
4) In the bottom loop, delete the error wire going into the loop condition terminal and wire the
new local variable to the loop condition terminal instead.
5) On the Front Panel, right-click on the stop button and change its mechanical action to Switch
Until Released.
7) Run the code and notice that it runs the same as before. Stop the code when done.
Virtual Instrumentation 6
Event Programming and Improving an Existing VI | Laboratory 11
Questions
1) What is the difference between a notify event and a filter event?
2) What happens if the Digital Button is clicked while the analog case is running? Will that
event be processed?
3) What is a potential application of using the local variable in the bottom loop instead of
wiring the error wire to the loop condition terminal?
4) What is the best way to handle code that is repeated multiple times in a VI?
Virtual Instrumentation 7
VIRTUAL INSTRUMENTATION
Lab 12
Controlling the
User Interface
Section 1 – Controlling the User Interface
--------------------------------------------------------------------------- 2
Configuring Hardware
--------------------------------------------------------------------------- 3
Creating SubVIs
--------------------------------------------------------------------------- 3
Implicitly Linked Property Nodes
--------------------------------------------------------------------------- 5
Explicitly Linked Property Nodes
--------------------------------------------------------------------------- 7
Explicitly Linked Invoke Nodes
--------------------------------------------------------------------------- 9
Using VI Properties to Control the User Interface
------------------------------------------------------------------------- 10
Controlling the User Interface | Laboratory 12
Section 1
Controlling the User Interface
In this lab, you will learn how to programmatically control the user interface through Property
Nodes and Invoke Nodes as well as through VI Properties.
Programmatically controlling the user interface can be useful to visually indicate when something
important happens in a monitoring application. More generally, it is often useful to give the user
access to different properties of the front panel while the program is running.
Pre-Lab Questions:
1) What is a control reference?
3) Within the Boolean subclass, a Stop Button would be considered a(n) ___________________ ?
4) What is a class?
Virtual Instrumentation 2
Controlling the User Interface | Laboratory 12
Lab Procedure
Configuring Hardware
1) Keep the same hardware configuration as was used in Lab 11.
Creating SubVIs
1) Copy and paste the code from Lab 11, Data Acquisition with cDAQ – Events.vi, into a new
VI.
If you didn’t complete this VI, ask your instructor for access to a VI to use as the starting
point for this lab.
3) Creating subVIs can be a tool in simplifying the Block Diagram. Create subVIs for the code
in the Analog and Digital cases.
4) Edit the subVI icon for each subVI to be indicative of its function.
Virtual Instrumentation 3
Controlling the User Interface | Laboratory 12
5) Ensure that your Analog event case matches the first image and your Digital case matches
the second image.
Virtual Instrumentation 4
Controlling the User Interface | Laboratory 12
Virtual Instrumentation 5
Controlling the User Interface | Laboratory 12
4) Move the new Property Node to the same location on the Block Diagram used in Method 1.
5) Right-click the Property Node and select Link to>>Pane>>Stop. You should notice that you
have the ability to link the Property Node to any control on the Front Panel.
6) Right-click the Property Node again and select Change All to Write.
7) Left-click on the word “Property” to access a list of all properties available for a Boolean
control.
8) Select blinking.
10) Run the code and observe the same effect noticed in Method 1.
Virtual Instrumentation 6
Controlling the User Interface | Laboratory 12
3) Wire the VI Server Reference to the Reference input of the new Property Node.
4) Drag the bottom of the Property Node down to show three properties.
5) Right click on the Property Node and select Change All to Write.
6) Left-click the first property and select Front Panel Window>>Show Menu Bar.
7) Left-click the second property and select Front Panel Window>>Title Bar Visible.
10) Wire the Error Out of the new Property Node to the Error In of the blinking Property Node.
11) Run the VI and record the effect of these properties on the Front Panel.
14) Double-click on the Analog Case SubVI to access the subVI Block Diagram.
15) Place a new Property Node on the subVI Block Diagram from the Applications Control Palette.
16) Create a control for the reference input to the Property Node.
17) Right-click the reference control and select Select VI Server Class>>Generic>>GObject>>
Control>>GraphChart>>WaveformChart.
18) Right-click the Property Node and choose Change All to Write.
19) Left-click the word “Property,” and notice that a list of properties relevant for a waveform chart
is listed.
Virtual Instrumentation 7
Controlling the User Interface | Laboratory 12
21) From the Dialog & User Interface Palette place down a Color Box Constant and wire it to the
input of the property.
24) Switch to the Front Panel and notice that there is a reference control present on the Front
Panel.
25) Edit the icon Connector Pane for the subVI to create an input for the reference.
26) Save and close the subVI. Remember to relink the subVI in the main VI because the Connector
Pane was edited.
27) In the main VI, right-click on the waveform chart indicator and select Create>>Reference.
28) Wire the Waveform Chart Reference to the reference input you created for the subVI.
Virtual Instrumentation 8
Controlling the User Interface | Laboratory 12
2) Add a new Value Change event case for the “Center” button.
3) In the new event case, place an Invoke Node from the Application Control Palette.
7) Run the code and observe the behavior of the Invoke Node.
Virtual Instrumentation 9
Controlling the User Interface | Laboratory 12
3) Select Customize.
4) Deselect the boxes that show the horizontal and vertical toolbars.
Virtual Instrumentation 10
Controlling the User Interface | Laboratory 12
Questions
1) Is it possible to create implicitly linked Invoke Nodes? If so, how?
4) How do configure one reference to allow properties to be configured that would affect
multiple different types of controls?
Virtual Instrumentation 11
VIRTUAL INSTRUMENTATION
Lab 12
Controlling the
User Interface
Section 1
Controlling the User Interface
In this lab, you will learn how to programmatically control the user interface through Property
Nodes and Invoke Nodes as well as through VI Properties.
Programmatically controlling the user interface can be useful to visually indicate when something
important happens in a monitoring application. More generally, it is often useful to give the user
access to different properties of the front panel while the program is running.
Pre-Lab Questions:
1) What is a control reference?
3) Within the Boolean subclass, a Stop Button would be considered a(n) ___________________ ?
4) What is a class?
Virtual Instrumentation 2
Controlling the User Interface | Laboratory 12
Lab Procedure
Configuring Hardware
1) Keep the same hardware configuration as was used in Lab 11.
Creating SubVIs
1) Copy and paste the code from Lab 11, Data Acquisition with ELVIS – Events.vi, into a new
VI.
If you didn’t complete this VI, ask your instructor for access to a VI to use as the starting
point for this lab.
3) Creating subVIs can be a tool in simplifying the Block Diagram. Create subVIs for the code
in the Analog and Digital cases.
4) Edit the subVI icon for each subVI to be indicative of its function.
Virtual Instrumentation 3
Controlling the User Interface | Laboratory 12
5) Ensure that your Analog event case matches the first image and your Digital case matches
the second image.
Virtual Instrumentation 4
Controlling the User Interface | Laboratory 12
Virtual Instrumentation 5
Controlling the User Interface | Laboratory 12
4) Move the new Property Node to the same location on the Block Diagram used in Method 1.
5) Right-click the Property Node and select Link to>>Pane>>Stop. You should notice that you
have the ability to link the Property Node to any control on the Front Panel.
6) Right-click the Property Node again and select Change All to Write.
7) Left-click on the word “Property” to access a list of all properties available for a Boolean
control.
8) Select blinking.
10) Run the code and observe the same effect noticed in Method 1.
Virtual Instrumentation 6
Controlling the User Interface | Laboratory 12
3) Wire the VI Server Reference to the Reference input of the new Property Node.
4) Drag the bottom of the Property Node down to show three properties.
5) Right click on the Property Node and select Change All to Write.
6) Left-click the first property and select Front Panel Window>>Show Menu Bar.
7) Left-click the second property and select Front Panel Window>>Title Bar Visible.
10) Wire the Error Out of the new Property Node to the Error In of the blinking Property Node.
11) Run the VI and record the effect of these properties on the Front Panel.
14) Double-click on the Analog Case SubVI to access the subVI Block Diagram.
15) Place a new Property Node on the subVI Block Diagram from the Applications Control Palette.
16) Create a control for the reference input to the Property Node.
17) Right-click the reference control and select Select VI Server Class>>Generic>>GObject>>
Control>>GraphChart>>WaveformChart.
18) Right-click the Property Node and choose Change All to Write.
19) Left-click the word “Property,” and notice that a list of properties relevant for a waveform chart
is listed.
Virtual Instrumentation 7
Controlling the User Interface | Laboratory 12
21) From the Dialog & User Interface Palette place down a Color Box Constant and wire it to the
input of the property.
24) Switch to the Front Panel and notice that there is a reference control present on the Front
Panel.
25) Edit the icon Connector Pane for the subVI to create an input for the reference.
26) Save and close the subVI. Remember to relink the subVI in the main VI because the Connector
Pane was edited.
27) In the main VI, right-click on the waveform chart indicator and select Create>>Reference.
28) Wire the Waveform Chart Reference to the reference input you created for the subVI.
Virtual Instrumentation 8
Controlling the User Interface | Laboratory 12
2) Add a new Value Change event case for the “Center” button.
3) In the new event case, place an Invoke Node from the Application Control Palette.
7) Run the code and observe the behavior of the Invoke Node.
Virtual Instrumentation 9
Controlling the User Interface | Laboratory 12
3) Select Customize.
4) Deselect the boxes that show the horizontal and vertical toolbars.
Virtual Instrumentation 10
Controlling the User Interface | Laboratory 12
Questions
1) Is it possible to create implicitly linked Invoke Nodes? If so, how?
4) How do configure one reference to allow properties to be configured that would affect
multiple different types of controls?
Virtual Instrumentation 11
VIRTUAL INSTRUMENTATION
Lab 13
Advanced File I/O
and Creating/Distrib-
uting an Application
Section 1 – Advanced File I/O and Creating/Distributing
an Application
--------------------------------------------------------------------------- 2
Configuring Hardware
--------------------------------------------------------------------------- 3
Configuring the File/O
--------------------------------------------------------------------------- 3
Creating an Application
--------------------------------------------------------------------------- 8
Creating an Installer
--------------------------------------------------------------------------- 8
Testing
--------------------------------------------------------------------------- 9
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
Section 1
Advanced File I/O and Creating/
Distributing an Application
In this lab, you will expand upon the code from Lab 12 by writing data from more than one source
to a TDMS file and using TDMS Set Properties to distinguish between data sources within the TDMS
file. The code will then be turned into an executable. The executable will then be included in an
installer so that it can be distributed to other machines without LabVIEW or the necessary drivers.
Be building an executable and installer, you can create a package that will allow your temperature
monitoring program to be deployed to computers that don’t have the LabVIEW development
environment installed.
This is usually the final step when building an application that will be used in the field.
Pre-Lab Questions:
1) True / False: Use ASCII if you need to perform random access reads or writes and if numeric
precision and fast File I/O are requirements.
Please provide what file type(s) fits the above criteria more appropriately if the statement is
false.
3) What is TDMS and what are some benefits of this file type?
Virtual Instrumentation 2
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
Lab Procedure
Configuring Hardware
1) Keep the connections that are currently in place.
2) If you have a function generator or a similar device or sensor, connect it to channel AI2
of the analog input card. We will use this signal to simulate a second source of data to be
saved to the TDMS file.
3) If you don’t have a device that can be used, channel AI2 can remain unconnected. In this
case, data measured on this channel will have a value close to 0V.
4) Add a new value change event case for the “Second Source” button.
5) Place the “Second Source” Boolean control inside of the new event case.
6) Within the new event case, add a DAQ Assistant Express VI from the DAQmx palette on the
Mesurement I/O Palette.
7) Select Acquire Signals>>Analog Input>>Voltage. Then choose channel ai2 of the analog
input card plugged into the cDAQ and click Finish.
9) Create a Waveform Graph Indicator for the Data output of the DAQmx Express VI.
11) Use a “Bundle” to bundle the output of the DAQmx Express VI with a string constant
containing the value “Second Source.”
Virtual Instrumentation 3
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
14) Wire the Queue and Error wires into the Enqueue Element function.
15) Wire the Queue and Error wires out of the Enqueue Element function to the tunnels at the
right side of the Idle case.
16) You’ll now need to connect the Queue and Error wires through the Timeout, Stop, Panel
Close?, and Center cases of the Event Structure as well.
18) Wire the output of the Bundle within the Scope Event Case to the “Element” input of the
Enqueue Element as shown.
Virtual Instrumentation 4
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
20) Bundle the output of the Convert Thermistor Reading function with a string constant
containing the value “Analog.”
21) Notice that you cannot wire the new cluster to the Enqueue Element because the Enqueue
Element is referencing the old queue data type. To resolve this, create a control from the
queue reference wire within the main VI and copy it into the subVI.
23) Replace the existing Queue In control in the subVI with the new control. Notice that the data
type of the queue is now correct and the cluster can be wired to the “Element” input of the
Enqueue Element.
24) Create a new indicator for the queue out terminal of the Enqueue Element.
25) Edit the Connector Pane of the subVI so that the new queue control and indicator have
terminals on the subVI.
26) Ensure that your code matches the code shown, and save the subVI.
27) Within the Case structure in the bottom loop, create a new Case Structure around the current
File I/O code.
29) Wire the Element output terminal of the Dequeue Element to the cluster.
30) Wire the string output of the Unbundle to the Case Selector of the new case structure.
31) Label the “True” case to be “Analog” and the “False” case to be “Second Source”.
Virtual Instrumentation 5
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
32) Wire the waveform output of the Unbundle to the data input of the TDMS Write.
33) Add a new case to the case structure and make it the default case. Leave this case empty, but
wire the TDMS and error wires through the case.
34) Within the Analog Case, add a TDMS Set Properties before the TDMS Write and wire them
together appropriately.
35) Create a constant for the “Property Names” terminal of the TDMS Set Properties.
36) Enter “Test Number” into the first value of the array.
37) Create a string array control on the Front Panel and wire it to the “Property Values” terminal of
the TDMS Set Properties.
38) Make constants for the group name and channel name and give them values of “Producer/
Consumer” and “Analog” respectively.
39) Create the same code in the Second Source case, but replace the “Analog” constants with
“Second Source”.
Virtual Instrumentation 6
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
40) Ensure that your bottom loop code matches the code shown for each respective case.
Virtual Instrumentation 7
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
Creating an Application
1) Save the VI as Data Acquisition with cDAQ – MainVI.vi and add it to a Project.
2) In the project, right-click on Build Specifications and choose New>> Application (EXE).
4) In the “Information” category name the application Data Acquisition with cDAQ.exe.
5) Take note of the “Destination Directory” as this is where the application will be saved on your
computer when the application is built.
6) In the “Source Files” category, move the VI for Lab 13 to “Startup VIs.”
7) These are all of the modifications that need to be made for this application build, but take
note of the options found in the other categories.
9) Notice that your new application appears under “Build Specifications” in the project.
Creating an Installer
1) Right-click on Build Specifications and choose New>>Installer.
3) Under Source Files, move the Lab 13 executable to the “Destination View.” By default, it will
move to the Program Files folder.
4) In the Additional Installers Category, include the appropriate LabVIEW Run-Time Engine and
the NI-DAQmx Application Development Support.
6) You may be prompted to locate the location that DAQmx is installed from on your computer.
Virtual Instrumentation 8
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
Testing
1) Install the installer on a computer without LabVIEW if possible.
3) Enter the number 1 into the “Property Values” array for “Analog” and for “Second Source” to
record this run as the first test.
4) Make sure to click the Second Source button to log some data.
5) Use the TDMS File Viewer on a computer with LabVIEW to view the logged file.
6) If you have extra time, you could create an executable that includes the TDMS File Viewer so
that the entire process could be run on a machine without LabVIEW.
Virtual Instrumentation 9
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
Questions
1) What is the benefit of using TDMS?
2) If the executable created in this lab were distributed onto a computer without LabVIEW,
would it run? Why or why not?
5) Will any version of the LabVIEW Run-Time Engine installed on the target machine allow the
executable to run?
Virtual Instrumentation 10
VIRTUAL INSTRUMENTATION
Lab 13
Advanced File I/O
and Creating/Distrib-
uting an Application
Section 1 – Advanced File I/O and Creating/Distributing
an Application
--------------------------------------------------------------------------- 2
Configuring Hardware
--------------------------------------------------------------------------- 3
Configuring the File/O
--------------------------------------------------------------------------- 3
Creating an Application
--------------------------------------------------------------------------- 8
Creating an Installer
--------------------------------------------------------------------------- 8
Testing
--------------------------------------------------------------------------- 9
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
Section 1
Advanced File I/O and Creating/
Distributing an Application
In this lab, you will expand upon the code from Lab 12 by writing data from more than one source
to a TDMS file and using TDMS Set Properties to distinguish between data sources within the TDMS
file. The code will then be turned into an executable. The executable will then be included in an
installer so that it can be distributed to other machines without LabVIEW or the necessary drivers.
Be building an executable and installer, you can create a package that will allow your temperature
monitoring program to be deployed to computers that don’t have the LabVIEW development
environment installed.
This is usually the final step when building an application that will be used in the field.
Pre-Lab Questions:
1) True / False: Use ASCII if you need to perform random access reads or writes and if numeric
precision and fast File I/O are requirements.
Please provide what file type(s) fits the above criteria more appropriately if the statement is
false.
3) What is TDMS and what are some benefits of this file type?
Virtual Instrumentation 2
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
Lab Procedure
Configuring Hardware
1) Keep the connections that are currently in place.
2) If you have a function generator or a similar device or sensor, connect it to channel AI2 of
the NI ELVIS. We will use this signal to simulate a second source of data to be saved to the
TDMS file.
3) If you don’t have a device that can be used, channel AI2 can remain unconnected. In this
case, data measured on this channel will have a value close to 0V.
4) Add a new value change event case for the “Second Source” button.
5) Place the “Second Source” Boolean control inside of the new event case.
6) Within the new event case, add a DAQ Assistant Express VI from the DAQmx palette on the
Mesurement I/O Palette.
7) Select Acquire Signals>>Analog Input>>Voltage. Then choose channel ai2 of the NI ELVIS
and click Finish.
9) Create a Waveform Graph Indicator for the Data output of the DAQmx Express VI.
11) Use a “Bundle” to bundle the output of the DAQmx Express VI with a string constant
containing the value “Second Source.”
Virtual Instrumentation 3
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
13) Delete Queue and Error wires that run through the Idle case of the case structure.
14) Wire the Queue and Error wires into the Enqueue Element function.
15) Wire the Queue and Error wires out of the Enqueue Element function to the tunnels at the
right side of the Idle case.
16) You’ll now need to connect the Queue and Error wires through the Timeout, Stop, Panel
Close?, and Center cases of the Event Structure as well.
18) Wire the output of the Bundle within the Scope Event Case to the “Element” input of the
Enqueue Element as shown.
Virtual Instrumentation 4
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
21) Notice that you cannot wire the new cluster to the Enqueue Element because the Enqueue
Element is referencing the old queue data type. To resolve this, create a control from the
queue reference wire within the main VI and copy it into the subVI.
23) Replace the existing Queue In control in the subVI with the new control. Notice that the data
type of the queue is now correct and the cluster can be wired to the “Element” input of the
Enqueue Element.
24) Create a new indicator for the queue out terminal of the Enqueue Element.
25) Edit the Connector Pane of the subVI so that the new queue control and indicator have
terminals on the subVI.
26) Ensure that your code matches the code shown, and save the subVI.
27) Within the Case structure in the bottom loop, create a new Case Structure around the current
File I/O code.
29) Wire the Element output terminal of the Dequeue Element to the cluster.
30) Wire the string output of the Unbundle to the Case Selector of the new case structure.
31) Label the “True” case to be “Analog” and the “False” case to be “Second Source”.
Virtual Instrumentation 5
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
32) Wire the waveform output of the Unbundle to the data input of the TDMS Write.
33) Add a new case to the case structure and make it the default case. Leave this case empty, but
wire the TDMS and error wires through the case.
34) Within the Analog Case, add a TDMS Set Properties before the TDMS Write and wire them
together appropriately.
35) Create a constant for the “Property Names” terminal of the TDMS Set Properties.
36) Enter “Test Number” into the first value of the array.
37) Create a string array control on the Front Panel and wire it to the “Property Values” terminal of
the TDMS Set Properties.
38) Make constants for the group name and channel name and give them values of “Producer/
Consumer” and “Analog” respectively.
39) Create the same code in the Second Source case, but replace the “Analog” constants with
“Second Source”.
Virtual Instrumentation 6
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
40) Ensure that your bottom loop code matches the code shown for each respective case.
Virtual Instrumentation 7
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
Creating an Application
1) Save the VI as Data Acquisition with ELVIS – MainVI.vi and add it to a Project.
2) In the project, right-click on Build Specifications and choose New>> Application (EXE).
4) In the “Information” category name the application Data Acquisition with ELVIS.exe.
5) Take note of the “Destination Directory” as this is where the application will be saved on your
computer when the application is built.
6) In the “Source Files” category, move the VI for Lab 13 to “Startup VIs.”
7) These are all of the modifications that need to be made for this application build, but take
note of the options found in the other categories.
9) Notice that your new application appears under “Build Specifications” in the project.
Creating an Installer
1) Right-click on Build Specifications and choose New>>Installer.
3) Under Source Files, move the Lab 13 executable to the “Destination View.” By default, it will
move to the Program Files folder.
4) In the Additional Installers Category, include the appropriate LabVIEW Run-Time Engine and
the NI-DAQmx Application Development Support.
6) You may be prompted to locate the location that DAQmx is installed from on your computer.
Virtual Instrumentation 8
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
Testing
1) Install the installer on a computer without LabVIEW if possible.
3) Enter the number 1 into the “Property Values” array for “Analog” and for “Second Source” to
record this run as the first test.
4) Make sure to click the Second Source button to log some data.
5) Use the TDMS File Viewer on a computer with LabVIEW to view the logged file.
6) If you have extra time, you could create an executable that includes the TDMS File Viewer so
that the entire process could be run on a machine without LabVIEW.
Virtual Instrumentation 9
Advanced File I/O and Creating/Distributing an Application | Laboratory 13
Questions
1) What is the benefit of using TDMS?
2) If the executable created in this lab were distributed onto a computer without LabVIEW,
would it run? Why or why not?
5) Will any version of the LabVIEW Run-Time Engine installed on the target machine allow the
executable to run?
Virtual Instrumentation 10
VIRTUAL INSTRUMENTATION
Getting Started
How to Configure
Your System
2) Connect the power supply to the back of the NI ELVIS unit and to the wall.
3) Connect the USB cable to the back of the NI ELVIS unit and to an available USB port on
your computer.
4) Turn on the switch on the back of the NI ELVIS unit to provide power to the unit, and then
turn on the switch on top of the NI ELVIS unit to provide power to the protoboard. The
switch on top of the NI ELVIS unit allows you to turn off power to the protoboard and switch
protoboards without having to power down the entire unit.
2) Ensure that the c-series module cards are plugged into the cDAQ chassis.
3) The cDAQ should automatically be recognized by the PC and will appear under Devices and
Interfaces in the Measurement and Automation Explorer Configuration Menu. When this is
completed, the device is ready to use.
Virtual Instrumentation 2