Sistemi automatici di misura -...
Transcript of Sistemi automatici di misura -...
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 1
Sistemi automatici di misura
2
Bus standard per strumentazione
Strumentazione virtuale
Sistemi automatici di misura
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 2
Strumentazione virtuale
4
Conoscenza sistemisticafilosofia della strumentazione virtualelinguaggio di programmazione graficaintegrazione delle schede di acquisizione dati in un sistema di misura
Capacità di programmazioneprogrammare e gestire un sistema di misuraintegrare problematiche tipiche delle misureelettroniche in un sistema programmabileprogettare interfacce “friendly” per uno strumento di misura virtuale
Obiettivi della lezione
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 3
5
Prerequisiti per la lezione
Elementi di programmazione:ambiente di programmazione ad oggetti
Fondamenti di Misure elettroniche:tecniche di campionamentoacquisizione e conversione A/D
Teoria dei segnali:teoremi del campionamento
6
“Misure Elettroniche”U. PisaniEd. Politeko,Torino, 2000,
capitoli 6, 7, 10
Bibliografia per la lezione
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 4
7
Strumentazione virtuale
LabVIEW generalLabVIEW front panelLabVIEW block diagramWiring Objects on the Block DiagramControl structuresArrays and ClustersRunning the VI and debugging toolsCreating sub VIData acquisition Systems
Contenuti della lezione
Strumentazione virtuale
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 5
9
LabVIEW 1/2
LabVIEW stands for Laboratory Virtual Instrument Engineering Workbench
LabVIEW is a graphical programming languagethat uses icons instead of lines of text to create programs
10
LabVIEW 2/2
LabVIEW programs are called Virtual Instruments, or VIs, because their appearance and operation imitate physical instruments
Every VI uses functions that manipulate inputfrom the user interface or other sources and displays that information or moves it to other files or other computers
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 6
11
LabVIEW dialog box
Click the New buttonto create a new VI
Click the Open button to display an existing VI
Click the Configureto configure NI measurement and control tools (Data acquisition board)
Click Help for step by step instructions
12
LabVIEW components 1/3
A VI contains the following three components:
front panel - Serves as the user interface
block diagram - Contains the graphical sourcecode that defines the functionality of the VI
icon and connector panel - Identifies the VI so that you can use the VI in another VI
a VI within another VI is called a subVI
a subVI corresponds to a subroutine in text-basedprogramming languages
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 7
13
LabVIEW components 2/3
LabVIEW contains:
a comprehensive set of tools for acquiring, analyzing, processing, displaying, and storing data
tools to help you troubleshooting your code
LabVIEW allows to communicate with hardwaresuch as data acquisition, vision, and motioncontrol devices and GPIB, PXI, VXI, RS-232, and RS-485 instruments
14
LabVIEW components 3/3
The front panel is the user interface of the VI
The code is contained in the block diagram
After you build the user interface, you add code using VIs and structures to control the front panel objects
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 8
Strumentazione virtuale
16
LabVIEW front panel 1/2
The user interface, or front panel, appears witha gray background and includes controls and indicators
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 9
17
LabVIEW front panel 2/2
The title bar of the front panel indicates that thiswindow is the front panel for the Generate and Display VI
18
Controls and Indicators 1/2
Controls are knobs, push buttons, dials, and other input devices
Indicators are graphs, LEDs, and other displays
Controls simulate instrument input devices and supply data to the block diagram of the VI
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 10
19
Controls and Indicators 2/2
Indicators simulate instrument output devices and display data the block diagram acquires or generates
Controls and indicators are located on the Controls palette of the Window menu of the front panel
20
Front panel Controls 1/3
You can configure the controls on the front panel to perform tasks depending on what you wantyour VI to do
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 11
21
Front panel Controls 2/3
Some examples of controls:Numeric Controls
22
Front panel Controls 3/3
Some examples of controls:Buttons & Switches
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 12
23
Place a Control on the Front Panel 1/2
Click the icon Num Ctrls toaccess the NumericControlspalette
Select the proper control and place it on the front panel by drag and drop
DRAG AND DROP
24
Place a Control on the Front Panel 2/2
Notice that when you move the cursor over iconson the Controls palette, the name of thatsubpalette appears in the grey space above allthe icons on the palette
When you idle the cursor over any icon on anypalette, the full name of the subpalette, control or indicator appears
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 13
25
Front panel Indicators 1/3
Many physical instruments have output devicesto display numerical values, graphs, and LEDs
On the front panel you can configure properindicators like graphs, LEDs, and other displaysthat simulate the output devices on a physicalinstrument
The displayed data are acquired or generated bythe block diagram
26
Front panel Indicators 2/3
The Indicatorsare located in the Controls Palette
An example:Graph Indicator
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 14
27
Front panel Indicators 3/3
An example:LED Indicator
28
Place an Indicator on the Front Panel
Apply same Controls procedure for placingIndicators
DRAG AND DROP
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 15
29
Graphs and Charts 1/2
Use graphs and charts to display data in a graphical form
Graphs and charts differ in the way they display and update
30
Graphs and Charts 1/2
Graphs usually collect the data in an array
Plot the data to the graph, as a spreadsheet thatfirst stores the data then generates a plot
X
Y
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 16
31
Graphs and Charts 2/2
Chart appends new data points to those alreadyin the display to create a history in the time
Time running
Strumentazione virtuale
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 17
33
LabVIEW block diagram 1/2
From Window menu of the front panelSelect Show Block Diagram to display the block diagram
34
LabVIEW block diagram 2/2
The block diagramappears with a whitebackground and includes VIs and structures that control the front panel objects
The title bar of the block diagram indicatesthat this window is the block diagram for the Generate and Display VI
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 18
35
Front panel & Block diagram
The block diagram and the front panel can beboth visible
If the front panel isnot visible, you can display the front panel by selecting Window⇒ Show Front Panel
By pressing the <Ctrl-E> keys you can open the block diagram or the front panel
36
Block Diagram objects
Block Diagram Terminals
Block Diagram Nodes
Functions
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 19
37
Block Diagram Terminals 1/3
A terminal is any point to which youcan attach a wire, other than toanother wire
LabVIEW has control and indicatorterminals, node terminals, constants, and specialized terminals on structures
You can configure the terminals on the block diagram to appear as icon ordata type terminals by right clikingon the icon and selecting View as Icon
38
Block Diagram Terminals 2/3
Control terminals have a thicker borderthan indicator terminals
Arrows appear on front panel terminalsto indicate whether the terminal is a control or an indicator
Output arrow for control
Input arrow for indicator
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 20
39
Block Diagram Terminals 3/3
The terminals represent the data typeof the control or indicator
For example DBL stands for doubleprecision floating point numeric data
The color and symbol of each terminal indicate the data type of the control or indicator
40
Data terminal codes
Examples of Control and Indicator Terminal Code
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 21
41
Block Diagram Nodes
Nodes are objects on the block diagram thathave inputs and/or outputs and performoperations when a VI runs
They are analogous to statements, operators, functions, and subroutines in text-basedprogramming languages
Strumentazione virtuale
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 22
43
Writing program by wiring objects 1/5
The program code is realized by connecting the objects positioned on the block diagramEach object presents one or more input and output terminalsTerminals are entry and exit ports that exchange information between the front panel and block diagramMove the cursor over the arrowof the object terminal, notice how the cursor becomes a wire spool, (the Wiring tool )
44
Writing program by wiring objects 2/5
Use the Wiring tool to wire objects together on the block diagram
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 23
45
Writing program by wiring objects 3/5
Each wire has a single data source, but youcan wire it to many VIs and functions
Wires are different colors, styles, and thicknessesdepending on their data types
A wire segment is a single horizontal or verticalpiece of wire
LEGENDA
1 Segment
2 Bend
3 Junction
46
Writing program by wiring objects 4/5
A bend in a wire is wheretwo segments join
The point at which two or more wire segments joinis a junction
LEGENDA
1 Segment
2 Bend
3 Junction
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 24
47
Writing program by wiring objects 5/5
You must wire all required block diagramterminals otherwise, the VI is broken and will notrun
A broken wire appears as a dashed black line with a red X in the middle
Broken wires occur for a variety of reasons, such as when you try to wire two objects withincompatible data types
48
Block Diagram Nodes
LabVIEW includes the following types of nodes:Functions - Built-in execution elements, comparable to an operator, function, or statementSubVIs - VIs used on the block diagram of another VI, comparable to subroutinesStructures - Process control elementsFormula Nodes - Resizable structures for entering equations directly into a block diagramExpression Nodes - Structures for calculating expressions, or equations, that contain a single variable…
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 25
49
Block Diagram Function palette
From Block DiagramWindow menu select Show FunctionPalette that contains VIs, functions, block diagram structures, and constants
50
Function palette 1/4
The icons of the Function palette allow to:
Input generate signals, generate drivers for I/O and instruments...Analyze signals (Spectral anaysis, filtering, statistics...)
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 26
51
Function palette 2/4
The icons of the Function palette allow to:
Execute and control software structuresArithmetic and Comparison tools
52
Function palette 3/4
The icons of the Function palette allow to:
Signal Manipulation (merge signals, split signals…)User libraries and other functions
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 27
53
Function palette 4/4
The Express VIs and structures located on the subpalettes of the Functions palette are a subset of the complete set of built-in VIs, functions, and structures available in LabVIEW
54
An example of Input function 1/2
Simulate Signal:
type of signalssine wavesquare wavetriangle wavesawtooth wavenoise signal
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 28
55
An example of Input function 2/2
setting options:
signal typefrequency (Hz)phase (deg) amplitudeoffsetduty cycle (%)add noisenoise type
56
Simulate Signal Icon
INPUTPARAM
OUTPUTDATA
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 29
57
Simulate Signal Properties 1/3
58
Simulate Signal Properties 2/3
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 30
59
Simulate Signal Properties 3/3
Strumentazione virtuale
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 31
61
Execution Control (Exec Ctrl) 1/2
While Looploop structure that repeats a section of code until a condition is met
Flat Sequence structureprogram control structure that executes its subdiagrams in numeric defined order
62
Execution Control (Exec Ctrl) 2/2
Case structure
conditional branchingcontrol structure, that executes one of its subdiagramsbased on the input to the Case structure. It is the combination of the IF, THEN, ELSE, and CASE statements in control flow languages
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 32
63
While loop
The default conditionto STOP the whileloop is clicking a stop button on the front panel
All the code includedin the loop rectangleis executed
While loop
Loop index
Condition
64
Flat Sequence structure
The Flat Sequence structure displays all theframes at once and executes the frames from left to right until the last frame executes
Flatsequence
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 33
65
Stacked Sequence structure
The stacked sequencesubstitutes in a more compact mode the flatsequenceUse it to save space in the block diagramTo scroll through the available subdiagrams, click the decrement and increment arrows in the structure selector label
66
Case structure
Case selector terminal
Input tunnelOutput tunnel
CASE FALSE
CASETRUE
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 34
67
All functions
Includes a miscellaneous of icons of functions, I/O handling, operators and so on
68
All functions -> Structures
The palette Structures includes icons of alreadydescribed structures and other ones like
For Loop
Formula Nodes
Event Structures
...
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 35
69
For Loop
Executes its subdiagramN times, where N is the value wired to the count(N) terminal
The iteration (i) terminal provides the current loop iteration count, which ranges from 0 to N -1
70
Formula Node
Evaluates mathematicalformulae and expressionson the block diagram
The Formula Node syntax is similar to the syntax used in text-based programminglanguages
Remember to end assignments with a semicolon (;)
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 36
71
Event Structure
The event structure contains one or moresubdiagrams that execute depending by an event
An event is an asynchronous notification thatsomething has occurred
Events can originate from:
the user interfaceexternal I/Oother parts of the program
72
Event types
User interface events include:
mouse clickskey presses, and so on
External I/O events include hardware timers or triggers that signal when data acquisition completes or when an error condition occurs
Programmatically generated events can be usedto communicate and execute different parts of the program
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 37
73
Shift registers 1/4
When, using For Loops or While Loops, you wantto transfer values from one loop iteration to the next, use shift registers
A shift register appears as a pair of terminals, directly opposite each other on the vertical sidesof the loop borders
LabVIEW transfers the data connected to the right sideof the register to the left sidein the next iteration
74
Shift registers 2/4
Create a shift registerby right-clicking one of the vertical bordersof a loop and selectingAdd Shift Registerfrom the shortcut menu
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 38
75
Shift registers 3/4
Initialize a shift register by wiring a control or constant to the shift register terminal on the leftside of the loop
Initialize
76
Shift registers 4/4
The data you wire to the terminals of each shiftregister must be the same type
Initialize
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 39
77
Strings
A string is a sequence (displayable or not) of ASCII characters, that provides a platform-independent format for information and data
On the front panel, strings appear as tables, textentry boxes, and labels
78
Using the Strings
Some of the more common applications of strings include the following:
creating simple text messagespassing numeric data as character strings to instruments and then converting the strings to numericsstoring numeric data to disk. To store numerics in an ASCII file, you must first convert numerics to strings before writing the numerics to a disk fileinstructing or prompting the user with dialogboxes
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 40
Strumentazione virtuale
80
Arrays
Arrays is a group of data elements of the sametype
An array consists of elements and dimensions: elements are the data that make up the array a dimension is the length, height, or depth of an array
An array can have one or more dimensions (as many as 231 – 1 elements per dimension memory permitting)
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 41
81
Grouping Data Arrays
You can build arrays of numeric, Boolean, path, string, waveform, and cluster data types control or indicator
Consider using arrays when you work with a collection of similar data and when you performrepetitive computations
Arrays are ideal for storing data you collect from waveforms or data generated in loops, where each iteration of a loop produces one element of the array
82
Array functions
The Array functions allow to create and manipulate arrays, such as the following tasks:
extract individual data elements from an array
add individual data elements to an array
split arrays
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 42
83
Example of 1D array 1/2
An example of an array is a waveformrepresented as a 1D numeric array in which eachsuccessive element is the voltage value at successive time intervals
NoteThe index is zero-based, which means it is in the range0 to n – 1, where n is the number of elements in the array
84
Example of 1D array 2/2
A more complex example of an 1D array is a graph represented as an array of points whereeach point is a cluster containing a pair of numerics that represent the X and Y coordinates
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 43
85
Example of 2D array 1/2
You can generalize the 1D waveform arrayexample to two dimensions by adding rows tothe array
Figure shows a collection of waveformsrepresented as a 2D array of numerics
86
Example of 2D array 2/2
The row index selects the waveform, and the column index selects the point on the waveform
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 44
87
Creating an array 1/2
An array control or indicator on the front panel is created by placing anarray shell on the front panel
Drag a data object or element into the array shell
The array shell automatically resizesto accommodate the new object
Indexdisplay
Array element
Array shell
88
Creating an array 2/2
To create a multidimensional array right-clickthe index display and select Add Dimension fromthe shortcut menu
2D Array
LEGENDA
1 Row Index
2 Column Index
3 Value at row, column
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 45
89
Clusters 1/3
Clusters are groups of data elements of mixedtypes
Clusters differ from arrays in that they are a fixed size
Like an array a cluster is either a control or anindicator
A cluster cannot contain a mixture of controlsand indicators
90
Clusters 2/3
Bundling several data elements into clusters:
eliminates wire clutter on the block diagram reduces the number of connector pane terminalsthat subVIs need assign the cluster to a terminal on the connector pane
Cluster elements have a logical order unrelated to their position in the shell
The first object you place in the cluster is element 0, the second is element 1, and so on
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 46
91
Clusters 3/3
If you delete an element, the order adjustsautomatically
The cluster order determines the order in whichthe elements appear as terminals on the Bundleand Unbundle functions on the block diagram
92
Cluster example 1/2
Cluster of 3 control elements (example)
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 47
93
Cluster example 2/2
Cluster output is reordered by unbundle operator in 3 corrispondent indicators (example)
94
Build a Cluster 1/3
After creratingthe Clusterelements in the front panel
Open Arrays&Clusters palette
SelectCluster
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 48
95
Build a Cluster 2/3
Drag and drop Cluster box in the front panelResize the cluster areaDrag and drop the cluster elements intothe clusterFollowing a defined order
Element 0
Element 1
Element2
96
Build a Cluster 3/3
Cluster Icon will appearon the block diagram
Right-clicking the clustericon select the clusterpalette
Cluster functions palettewill appear
Cluster Icon
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 49
97
Cluster functions
The Cluster functions allow to create and manipulate clusters, such as the following tasks:
extract individual data elements from a cluster
add individual data elements to a cluster
break a cluster out into its individual data elements
Strumentazione virtuale
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 50
99
Running a VI executes your solution
A Run button is present in the block diagramwindow as well in the front panel
Clicking the Run button executes the program
Clicking the Run Continuosly button the program executes repetitively
To indicate that the VI is running, the buttonschanges to a darkened arrow
Running the VI
100
Block Diagram Data Flow 1/3
Text-based programming languages follow a control flow model (the execution order is thesequential order of the program code)
LabVIEW VIs run following a data flow model
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 51
101
Block Diagram Data Flow 2/3
A block diagram node executes when all itsinputs are available
When a node completes execution, it supplies data to its output terminals
The output data pass to the next node in the data flow path
102
Block Diagram Data Flow 3/3
In LabVIEW you can create block diagrams that have“simultaneous” operations
For example, you can runtwo While Loops“simultaneously” and display the results on the front panel
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 52
103
Broken VIs
The Run button appears broken when the VI you are creating or editing contains errors
If it is still broken when you finish wiring the block diagram, the VI is broken and cannot run
104
Execution Highlighting
Clicking the HighlLight Execution button , when running the program, the movement of flow data from one node to another is shownusing bubbles that move along the wires
Lamp lights
Data move along the wire
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 53
105
Single-step through a VI to view each action of the VI on the block diagram as the VI runsThe single-stepping buttons affect execution onlyin a VI or subVI in single-step mode
Move the cursor over the Step Over, Step Into, or Step Out button to view a tip strip thatdescribes the next step if you click that button
Debug by Single-Stepping
Step Over Step OutStep Into
106
Debugging by Probe 1/2
You can set a Probe in the block diagram tovisualize data passing through a wireA window numbered with the correspondingprobe number will show you the data
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 54
107
Debugging by Probe 2/2
To set a probe when the VI is not running
Right-click a wire and select CustomProbe»Generic from the shortcut menu to use the generic probe
The generic probe displays the data
108
Debugging by Probe tool 1/2
Use the Probe tool to check intermediate valueson a wire as a VI runsBy positioning the mouse on the wire the probe tool will appear
Probe tool
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 55
109
Debugging by Probe tool 2/2
If data are available, by clicking the probe toolthe probe immediately updates while the VI isrunning
Probe tool
110
Debug by Breakpoints
Use the Breakpoint tool to placea breakpoint on a VI, node, or wire on the block diagram andpause execution at that location
When you set a breakpoint on a wire, execution pauses after data pass through the wire
To set a breakpoint Right-click a wire and select Breakpoint fromthe shortcut menu
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 56
111
Using Built-In VIs and Functions
LabVIEW includes VIs and functions to help youbuild specific applications, such as:
data acquisition VIs and functionsVIs that access other VIsVIs that communicate with other applications
LabVIEW includes hundreds of example VIs youcan use and incorporate into VIs that you create reducing development time
112
Instrument Control
You can use the built-in VIs and functions tocontrol external instruments such asoscilloscopes, voltmeter frequency meters ...
To control instruments in LabVIEW, you musthave the correct hardware installed, powered on, and operating on your computer
The VIs and functions you use to control instruments depend on the instrumentationcommunication protocols your hardware supports
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 57
113
Data acquisition 1/2
Use the Data Acquisition VIs and functions toacquire data from DAQ devices
To use these VIs, you must have the NI-DAQ driver software and DAQ hardware installed
114
Data acquisition 2/2
After you acquire data, you can use the built-inAnalyze, Report Generation, and Mathematics VIs and functions to:
analyze data
generate reports
perform mathematical operations on that data
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 58
115
Communicate with Other Applications 1/2
Use the File I/O VIs and functions to write data to or read data from other applications, such asMicrosoft Excel
You can use these VIs and functions to generate reports or incorporate data from anotherapplication in the VI
116
Communicate with Other Applications 2/2
Use the Communication VIs and functions to transfer LabVIEW data across the Web using a communication protocol such as FTP and to buildclient-server applications using communication protocols
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 59
Strumentazione virtuale
118
Building SubVIs as Icons
After you build a VI and create its icon and connector pane, you can use it in another VI
A VI called from the block diagram of another VI is called a subVI
A subVI corresponds to a subroutine in text-based programming languages
A subVI node corresponds to a subroutine call in text-based programming languages
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 60
119
To create a SubVI
Click the Select a VIicon on the Functions palette
Browse and select the VI, and place it on the block diagram to create a subVI
120
Setting up the Connector Pane 1/2
To use a VI as a subVI, you need to build a connector pane
The connector pane is a set of terminals that corresponds to the controls and indicators of thatVI
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 61
121
Setting up the Connector Pane 1/2
To define a connector pane, right-click the icon in the upper right corner of the front panel windowand select Show Connector from the shortcutmenu
122
Setting up the Connector Pane 2/2
The connector pane replaces the icon
Each rectangle on the connector pane representsa terminal
Use the rectangles to assign inputs and outputs
INPUTS OUTPUTS
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 62
Strumentazione virtuale
124
Measurement data acquisition
Acquiring data include plug-in DAQ and instrument devices, GPIB instruments, PXI (PCI eXtensions for Instrumentation) instruments, and RS-232 instruments
A general-purpose DAQ device is a device that:
acquires analog or digital data also on multiple channelsgenerates analog and digital signals also on multiple channels
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 63
125
On board data acquisition
Typically you connect these devices directly tothe internal bus of a computer through a plug-inslot (PCI slot of a desktop computer or the PCMCIA slots of a laptop computer)
DAQ device can be external and connects to the computer through an existing port (ex., such asthe USB connector, serial port or Ethernet port)
126
External data acquisition
Many instruments are external to the computer and do not rely on a computer to take a measurement
That is the case of a GPIB instrument, connectedto the PC by a standard IEEE488 board
All the solutions are supported by LabView that can programatically control and monitor the instruments, collect and further process data and also present/store in files
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 64
127
NI-DAQ 7.0
NI-DAQ 7.0 contains two NI-DAQ drivers eachwith its own Application Programming Interface (API), hardware configuration, and software configuration:
Traditional NI-DAQ NI-DAQmx
Traditional NI-DAQ is an upgrade to NI-DAQ 6.9.x, the earlier versionof NI-DAQ: has the sameVIs and functions and works the same way asNI-DAQ 6.9.x.
128
NI-DAQmx
NI-DAQmx is the latest NI-DAQ driver with new VIs, functions, and development tools forcontrolling measurement devices
The advantages of NI-DAQmx over previousversions of NI-DAQ include the DAQ Assistant forconfiguring channels and measurement tasks fora device
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 65
129
Instrument driver 1/3
An instrument driver is a collection of functionsthat control and operate the instrument thatsimplify instrument programming to high-levelcommands (not need to learn low-level, instrument-specific syntax)
130
Instrument driver 2/3
Using instrument drivers provides the following advantages:
quickly build complete systems
reduce software development costs
help make test programs easier to maintain(because instrument drivers contain all the I/O for an instrument within one library, separate from other code, which is easy to upgrade when or if the hardware changes)
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 66
131
Instrument driver 3/3
NI provides more than 2,200 instrument drivers from more than 150 vendors
Refer to the NI Instrument Driver Network at ni.com/idnet for a list of available instrument drivers
132
Types of Data Acquisition boards
Easy I/O → Base I/O VIAnalog Input →Analog Output →Counter/Timer → Intermediate VIDigitalInput and Output →Calibration and Config →Advanced → Advanced VIDAQ Utilities → Utility DAQ
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 67
133
Waveform Acquisition VI
Example of VI icon for multichannel sampling and acquisition
134
Multiple channel Waveform Acquisition
Sottoprogramma che effettua la conversione tra la tensione misurata da un sensore e la
temperatura
Sottoprogramma che effettua la misura delle tensioni dei
sensori mediante la scheda di acquisizione dati
Controllo che calcola il valore medio di un vettore
Controllo che seleziona una colonna nella matrice con le
tensioni misurate
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 68
135
Transducer signal acquisition
PhysicalPhenomena
Transducers SignalConditioning
DAQBoard
PersonalComputer
136
Analog DAQ board Features
Choose PCI E Series DAQ Boards with• 20 kS/s to 5 MS/s• 12 or 16-bit resolution• 16 to 64 analog inputs• Multiplexed or simultaneous S/H• 8 to 32 digital I/O lines• Calibration certificates for NIST traceability
AO Features• Up to 32 analog outputs• Up to 1 MS/s update rates• Up to 16-bit resolution• 0-20 or 2-20 mA current sinks• 8 digital I/O lines• Up to two 24-bit counter/timers• Digital triggering
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 69
137
Digital IO Board Features
DIO Features• Up to 76 Mb/s• Up to 96 I/O lines• Pattern generation• Handshaking• Pattern and change detection• Start/stop triggering• Electromechanical relays and optical isolation
138
Multiple channel SCXI system
Per gentile concessione della National Instruments
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 70
139
Digital PXI IO Board
Per gentile concessione della National Instruments
140
PXI System
Per gentile concessione della National Instruments
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 71
Strumentazione virtuale
142
Si elencano alcuni argomenti che devono risultare chiari dallo studio della lezione:
tipologia degli strumenti utilizzabili per progettare un front panel ed un block diagramtipologia degli strumenti per presentare segnali e informazioni di misuratipologia degli strumenti per elaborare e processare segnalistrutture per il controllo per la programmazionestrumenti di debuggestione di schede di acquisizione dati
Approfondimenti
Misure Elettroniche II Strumentazione virtuale
© 2006 Politecnico di Torino 72
143
Sommario della lezione
Strumentazione virtualeLabVIEW generalLabVIEW front panelLabVIEW block diagramWiring Objects on the Block DiagramControl structuresArrays and ClustersRunning the VI and debugging toolsCreating subVIData acquisition Systems
Domande di riepilogo