Prog-Dev Chap4
Prog-Dev Chap4
Programmable Devices
Pr. H. BENTARZI
1
Chapter IV Introduction to data acquisition and
virtual instruments.
Front Panel
• Controls = Inputs
• Indicators = Outputs
Block Diagram
• Accompanying
“program”
for front panel
• Components wired
together
4
2
Chapter IV Introduction to data acquisition and
virtual instruments.
3
Analyze with LabVIEW
LabVIEW includes the following
tools to help you analyze your data:
• More than 400 measurement analysis
functions for Differential Equations,
Optimization, Curve Fitting, Calculus,
Linear Algebra, Statistics, etc.
Powerful measurement
analysis is built in to • 12 new Express VIs specifically
the LabVIEW designed for measurement analysis,
development including filtering and spectral analysis
environment. • Signal Processing VIs for Filtering,
Windowing, Transforms, Peak
Detection, Harmonic Analysis,
Spectrum
7 Analysis, etc.
4
5
How is composed a Virtual
Instrument (VI)
Front Panel
• Controls = Inputs
• Indicators = Outputs
Block Diagram
• Accompanying “program”
for front panel
• Components wired
together
11
Free Text
Simple
Numeric
Numeric Indicator
Control
Numeric Waveform
Indicator Graph
Scale
Legend
12
6
How is composed the Block Diagram Window
Block
Diagram
Toolbar
SubVI
(VI Express)
Numeric Graph
Constant Terminal
Wire
Data Numerical
Indicator
Terminal
While Loop
Structure
Timing Boolean Control
Function Terminal
13
14
7
Tools Palette
• LabVIEW can automatically select the tool needed
• Available on the front panel and the block diagram
• A tool is a special operating mode of the mouse cursor
• Use the tools to operate and modify front panel and
block diagram objects
• To show the tools palette, select
Window»Show Tools Palette
15
Controls Palette
Contains the most commonly used controls
16
8
Block Diagram − Functions Palette
Functions Palette
Contains the Express VIs (interactive VIs with
configurable dialog page) and the most commonly
used functions
All Functions Palette
Shows all functions
17
Tools Palette
Click pushpin to tack down palette
18
9
Menu
19
20
10
Labview help
21
Property Page
Right-click a control
or indicator on the
front panel and select
Properties from the
shortcut menu to
access the property
dialog box for that
object
Labview 2009-2010 22
11
Some shortcuts
Labview 2011-2012 23
TOPICS
New VI creation
Dataflow Programming
Customization of VI
24
12
Exercise 1 - Convert °K to °F
• Goal
– Create a simple VI
– Topic : convert a Kelvin temperature into Fahrenheit
• Concepts
– Simple mathematic function, numeric format
– Commands and indicators
– Dataflow, help, debugging
– Displays customized
• Homework
– Open a new VI
– Build a VI that converts °K to °F
– Save in « 1_KtoF.vi »
25
26
13
Composition of a new VI
Diagram (D)
27
Numeric
Owned Indicator
Labels
Increment
Buttons Numeric
Boolean Boolean Control
Control Indicator
Labview 2009-2010 28
14
Step 2 : Create the Front Panel
Create this Front Panel using the Controls Palette
29
Labview 2009-2010 30
15
Step 3 : Creating a VI Block Diagram
Front Panel
Control
Terminal
Constant Indicator
Wires Nodes Terminal
31
Wiring Techniques
Hot Spot
• Automatic Wiring
• Use Context Help Window when wiring
• Right-click wire and select Clean Up Wire
• Tip Strips
• Automatic wire routing
• Right-click terminals
and select Visible
Items»Terminals
View the terminal connections to a function
32
16
Block Diagram Terminals
33
Context Help
To display the Context Help window, select
Help»Show Context Help, press the <Ctrl-H> keys,
or press the Show Context Help Window button in
the toolbar
Move cursor over object
to display help
Connections:
Required – bold
Recommended – normal
Optional - dimmed
Simple/Detailed Context Help Lock Help More Help
34
17
LabVIEW Help
Click the More Help button in the Context Help
window
Select Help»VI, Function, & How-To Help
Click the sentence Click here for more help in the
Context Help window.
Dataflow Programming
18
Step IV : Save the VI
Then execute it !
37
Customization of displays
Goals
Insert comments for users
Adapt displays to the application
19
1) Free text
Useful to inform user
Authorized on FP et D
In example,
1. Add something like : ‘ Temperature
conversion ’.
2. Then, change font, size, color … (via FP
Toolbar)
39
2) Customization of displays
40
20
Customization of displays
• Goal
– Modify a VI
– Topic : Customization with specific models of indicator and messages
• Concepts
– Free text
– Customization of displays
• Homework
– Open « 1_KtoF.vi »
– Replace numerical indicator with temperature indicator
– Insert free text in FP and D to legend them
– Save in « 2_KtoF.vi » 41
Exercise 2 : FP customized
42
21
Exercise 2 : D customized
43
Modular Programming
TOPICS
SubVIs
Icon and Connector Pane
Using SubVIs
Creating a SubVI from sections of a VI
44
22
LabVIEW Hierarchy
SubVI
45
SubVIs
Function Pseudo Code Calling Program Pseudo Code
function average (in1, main
in2, out) {
{ average (point1, point2,
out = (in1 + in2)/2.0; pointavg)
} }
46
23
Icon/Connector
terminals
Icon
47
SubVI Example
– Conversion temperature
• A VI within another VI is called a subVI
• To use a VI as a subVI, create an icon and a connector pane after
building the front panel and block diagram
48
24
Steps for creating a SubVI
Create the Icon
Create the Connector
Assign Terminals
Save the VI
Insert the VI into a Top Level VI
49
50
25
Creating the Connector
51
52
26
Assign terminals via
the Connector Pane
Terminal colors match the data types to which they are connected
Click the terminal to see its associated front panel object
53
… and save the VI !
Using a VI as a SubVI
54
27
Help and Classifying Terminals
• Goal
– Create a simple VI
– Topic : convert a Kelvin temperature into Fahrenheit
• Concepts
– SubVI
• Homework
– Create icon and connector of « 1_KtoF.vi », save it and close
– Create a new VI in order to generate a randomly temperature between T0–DT et
T0+DT :
• 2 inputs T0(°K) and DTmax(°K)
• 2 outputs T(°K) and T(°F)
– You have to use the VI « 1_KtoF.vi »
– Save in « 3_Gen_temp_conv.vi »
56
28
Searching for Controls, VIs, and Functions
Exercise 3 : D
58
29
Exercise 3 : FP
59
60
30
Selection of the program part
61
62
31
Terminal assignment & icon
63
Exercise 4
• Goal
– SubVI creation
• Homework
– Open "3_Gen_temp_conv.vi".
– Replace the generation part by a subVI.
– Customize the SubVI icon.
– Suppress the automatic assignment of "T0" and "dTmax"
– Save the SubVI as "3Compl1_Gen_temp_conv.vi"
64
32
Summary
• VIs can be used as subVIs after you make the icon and connector
• Icon created using Icon Editor
• Connector defined by choosing number of terminals
• Load subVIs using the Select a VI option in the All Functions palette
or dragging the icon onto a new diagram
• Online help for subVIs using the Show Context Help option
• Descriptions document functionality
• Use Create SubVI feature to easily modularize the block diagram
65
Simple acquisition
TOPICS
Replacing simulation by acquisition
Data acquisition, acquisition of 1 point
66
33
Data Acquisition Hardware
34
Data Acquisition Hardware
35
Data Acquisition Hardware
Data acquisition (DAQ) basics DAQ Device
Connecting Signals
Simple DAQ application
Computer
Sensors
Cable
Terminal Block
71
ai 2 Sine Wave 3
Tasks
Timing and Triggering
72
36
Data Acquisition in LabVIEW
NI-DAQmx
Traditional NI-DAQ
Next generation driver:
Specific VIs for
• VIs for performing a
performing:
task
• Analog Input
• One set of VIs for all
• Analog Output
measurement types
• Digital I/O
• Counter operations
73
74
37
Exercise 4 – Simple Data Acquisition
• Goal
– Acquire analog signal
– Topic : acquire voltage from thermistor
• Concepts
– Assistant acquisition data
and hardware
– Formula node
• Homework
– Step 1 : In a blank vi, create an acquisition task, 1point, tension, -10/+10, RSE
– Step 2 : Convert the measured voltage into temperature with formula node or
express. Save it as “Acq_Temp.vi”
– Step 3 : Open the vi “Sim_temp_conv2.vi” and replace the simulation part
(“specifications and generation”) by the acquisition part and save it in
“Acq_Temp_conv.vi”
75
76
38
Vcc
Electronic system
R0
Rth = f(Uth) ?
77
Ref thermistor :
Ambient temperature
vs
thermistor value
325
1
320 T(R)=
R
315 Ln( )
1 10500
310 +
298.15 5524
305
T(°K)
300
295
290
285
280
0 5000 10000 15000 20000 25000
R(Ohms)
78
39
Exercise 4 – D
79
Exercise 4 – FP
80
40
Exercise 4 – D
With subVI
81
82
41
Complement : another way for
implementing mathematical function
For sure, basic mathematical functions for huge calculus won't be very
practical nor very efficient. They lead to complicated programs, and
Labview propose the use of higher level functions like "expression node"
or "formula node"…
83
Exercise 5
• Goal
– Use of higher level function for mathematical calculus
– Creation of SubVI
• Homework
– Open "4_Acq_Temp_conv.vi"
– Replace the Calculus part by a "formula node" or an "expression node"
– Create a SubVI performing the acquisition and the conversion.
This SubVI won't have any input terminal and just one output terminal.
– Save as "4Compl2_Acq_Temp_conv.vi"
84
42
Chapter IV Introduction to data acquisition and
virtual instruments.
Graphical Programming
for Test, Measurement, and
Control
• Rapid application
development and easy-
to-use graphical
environment
• Interactive
measurement assistants
and redesigned DAQ
interface for connecting
to all types of I/O
protective system :
supply breaker n motor
43
Chapter IV Introduction to data acquisition and
virtual instruments.
Example:
PC based
protective system :
44
Thank You
45