LabVIEW Intro
LabVIEW Intro
Electrical Wiring
Music Instrument
GRAPHICAL PROGRAMMING
FOR ENGIEERS AND SCIENTI
Hands-On Material
From National Instruments
High-Speed High-Resolution Multifunction Dynamic Instrument Digital I/O Counter/ Machine Motion Distributed I/O and
Digitizers Digitizers and DMMs Data Acquisition Signal Acquisition Control Timers Vision Control Embedded Control
Signal Conditioning
and Switching
Sound Card
Built into most computers
ENGR 100 Section C
What type of device should I use?
Icon Found on
Windows Desktop
Startup Screen:
Start from a Blank VI:
NewBlank VI
or
Start from an Example:
ExamplesFind
Examples
Indicator:
Numeric Slide
Structure:
While Loop
Positioning/Resizing Tool
Labeling Tool
Wiring Tool
Run Button
Abort Execution
Additional Buttons on
the Diagram Toolbar
Graph
Indicator
Output
Terminal
Boolean
Control
Input
Terminals
Additional Help
Right-Click on the VI icon and
choose Help, or
Choose Detailed Help. on
the context help window
A. Loops
While Loop
For Loop
B. Functions and SubVIs
Types of Functions
Creating Custom Functions (SubVI)
Functions Palette & Searching
C. Decision Making and File IO
Case Structure
Select (simple If statement)
File I/O
For Loop
For Loops
i terminal counts iterations
Run according to input N of
count terminal
Requirements:
1. Create a basic calculator function with the ability to add, subtract, multiply,
and divide two numbers and display the output
2. Allow the program to keep on running until a stop button is pressed.
spreadsheetformattedfiles
ENGR 100 Section C
File I/O Programming Model Under the Hood
Open/ Read
Close Check for
Create/ and/or
File Errors
Replace File Write to File
FileI/O>>WritetoSpreadsheetFile
Section III Presenting your Results
A. Displaying Data on the Front Panel
Controls and Indicators
Graphs and Charts
Loop Timing
B. Signal Processing
MathScript
Arrays
Clusters
Waveforms
Requirements:
1. Create a VI which runs exactly 50 times or
until a stop button is pushed
2. At each intervals, it generates a random
number between 50 and 100.
3. Display the random number on a
waveform chart.
Requirements:
1. Modify the Previous Practice Problem so
that the total sum of all the random
numbers generated is displayed
2. Using another shift register to have
moving average of three numbers
3. Plot moving average and original random
number in the waveform chart , i.e. two
curves in one chart. (Hint: use bundle in
cluster pallets
Practice:
2D array?
Requirements:
1. Generate an array of 20 random numbers.
2. Find the maximum, minimum, and mean
of the array using a shift register.
3. Modify the array by multiplying the fifth
element by 5
(FunctionsProgramming
StructuresMathScript)
Prototype your equations in the interactive MathScript Window.
ENGR 100 Section C
The Interactive MathScript Window
Rapidly develop and test algorithms
View/Modify
Variable Contents
User Commands
m-file Script
(LabVIEWToolsMathScript Window)
Structure>>formula node
Requirements:
1. Create a formula node which has 3 inputs(X, Y, Z) and one output. If X>Y
output Z, otherwise output 0.
2. Create a subVI which performs the same task as the formula node. (Hint: Use
the selection function found in the comparison palette)
Voltage
Pressure,
Temperature,
Distance,
Signal Conditioning Current
Light
A/D
Power Convertor
Amp
Transduce Digital World
r
D/A
Convertor
Signal Processing
DAQ Practice
DAQ Assistant Express VI
Homework Practice Problem 6
Conti Acq&Graph Voltage int Clk.vi
Requirements:
1. Create a data acquisition task which reads
data from the audio input on your MyDAQ
using the low level DAQmx functions
2. Display the signal on a waveform chart
3. After collecting this data write it to a
comma separated file using the Read
From Measurement File express VI.
USB Cable
Audio Cable
1. Create an audio loopback program using the MyDAQ. Read the signal
from audio in port and output it to the audio out port. Stop the loop when
a user pushes a stop button
2. Display the acquired signal on a graph.
2V
1. While Loop
2. Shift Register
3. Case Structure
State Machines Transitions
Several programming
techniques exist for
transitioning from state
to state in LabVIEW
using state machines
Default transition
implies that after one
state, another state
always follows
Transitions between two
potential states can be
handled by a select
function
State Machine
Homework Practice Problem 7
Insert Change Insert 10 Cents Insert 5 Cents Collect Gum Collect Gum/Change
Right-click on the
Stop Button in the
Front Panel and
change the
Mechanical Action
to Switch When
Released since
Local Variables
cannot store
Latched data.
Producer/Consumer Design Pattern
Switch
LEVITION
LEVITION
ENGR 100 Section C
Single 2-Way Switch Layout
Contact bounce
frequency) is equally
subdivided into 12 subintervals
Octave
A5 880Hz
called semitones. (m=4,n=12)or
(m=5,n=0)
Requirements:
1. Modify the play music using express vi with Sampling Frequency
(=44.1kHz), A4 Concert Frequency (f0=440 Hz), Duration(=0.1s)
, Frequency fnm (=f0*2^((n/12)+m-4)), numeric control n (integer
0~12), m(integer 0~12)
2. Add a while loop and shift register so that the sound will be
played when the value of frequency fnm is changed.
DI2
DI3
DI4
DI5
.
.
.
5V DC