An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual...
Transcript of An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual...
![Page 1: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/1.jpg)
An introduction to LabVIEW
1/19/2005 Vincenzo Giordano
![Page 2: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/2.jpg)
Course Goals
• Introduce LabVIEW• Data-acquisition application• Control application-Simulation• Control application-Experiment
1/19/2005 Vincenzo Giordano
![Page 3: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/3.jpg)
LabVIEW
• Graphical programming language• Modular in design• Widespread in industrial settings
1/19/2005 Vincenzo Giordano
![Page 4: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/4.jpg)
LabVIEW Programs Are Called Virtual Instruments (VIs)
1/19/2005 Vincenzo Giordano
Front Panel
User interface• Controls = Inputs• Indicators = Outputs
Block Diagram
Source code • elementary function
blocks“wired” together
![Page 5: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/5.jpg)
VI Front PanelFront Panel Toolbar
GraphLegend
BooleanControl
WaveformGraph
Icon
PlotLegend
ScaleLegend
1/19/2005 Vincenzo Giordano
![Page 6: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/6.jpg)
VI Block Diagram
Wire Data
GraphTerminal
SubVI
While LoopStructure
Block Diagram Toolbar Divide
Function
Numeric Constant
Timing Function
Boolean Control Terminal
1/19/2005 Vincenzo Giordano
![Page 7: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/7.jpg)
Controls and Functions Palettes
Controls Palette(Front Panel Window)
Functions Palette(Block Diagram Window)
1/19/2005 Vincenzo Giordano
![Page 8: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/8.jpg)
• Floating Palette• Used to operate and modify
front panel and block diagram objects.
Tools Palette
Automatic Selection Tool
Operating Tool
Positioning/Resizing Tool
Labeling Tool
Wiring Tool
Shortcut Menu Tool
Scrolling Tool
Breakpoint Tool
Probe Tool
Color Copy Tool
Coloring Tool
1/19/2005 Vincenzo Giordano
![Page 9: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/9.jpg)
Creating a VI
ControlTerminals
Block Diagram Window
Front Panel Window
Indicator Terminals
1/19/2005 Vincenzo Giordano
![Page 10: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/10.jpg)
DataData--acquisition and processingacquisition and processing
Block diagram
Input
Control terminal
OutputIndicator terminal
Data-acquisition and processing
Control panel
1/19/2005 Vincenzo Giordano
![Page 11: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/11.jpg)
Debugging Techniques• Finding Errors
• Execution Highlighting
• Probe
Click on broken Run buttonWindow showing error appears
Click on Execution Highlighting button; data flow is animated using bubbles. Values are displayed on wires.
Right-click on wire to display probe and it shows data as it flows through wire segment
You can also select Probe tool from Tools palette and click on wire
1/19/2005 Vincenzo Giordano
![Page 12: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/12.jpg)
Dataflow Programming• Block diagram executes
dependent on the flow of data; block diagram does NOT execute left to right
• Node executes when data is available to ALL input terminals
• Nodes supply data to all output terminals when done
1/19/2005 Vincenzo Giordano
![Page 13: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/13.jpg)
Help Options
Context Help• Online help• Lock help• Simple/Complex Diagram help• Ctrl + H
Online reference• All menus online• Pop up on functions in diagram to access online info directly
1/19/2005 Vincenzo Giordano
![Page 14: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/14.jpg)
Other important functions
•For Loop•While Loop•Case structure (if-else)
1/19/2005 Vincenzo Giordano
![Page 15: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/15.jpg)
Loops
• While Loops– Have Iteration Terminal– Always Run at least Once– Run According to Conditional
Terminal
• For Loops– Have Iteration Terminal– Run According to input N of
Count Terminal
1/19/2005 Vincenzo Giordano
![Page 16: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/16.jpg)
SubVIs• A SubVI is a VI that can be used within another VI• Similar to a subroutine• Advantages
– Modular– Easier to debug– Don’t have to recreate code– Require less memory
1/19/2005 Vincenzo Giordano
![Page 17: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/17.jpg)
SubVIs
1/19/2005 Vincenzo Giordano
• What is a subVI?• Making an icon and
connector for a subVI• Using a VI as a subVI
![Page 18: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/18.jpg)
Icon and Connector
• An icon represents a VI in other block diagrams
• A connector shows available terminals for data transfer
Icon
Connector
Terminals
1/19/2005 Vincenzo Giordano
![Page 19: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/19.jpg)
Steps to Create a SubVI
• Create the Icon• Create the Connector• Assign Terminals• Save the VI• Insert the VI into a Top Level VI
1/19/2005 Vincenzo Giordano
![Page 20: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/20.jpg)
Create the Icon• Right-click on the icon in the block diagram or front panel
1/19/2005 Vincenzo Giordano
![Page 21: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/21.jpg)
Create the ConnectorRight click on the icon pane (front panel only)
1/19/2005 Vincenzo Giordano
![Page 22: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/22.jpg)
Assign Terminals
1/19/2005 Vincenzo Giordano
![Page 23: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/23.jpg)
Insert the SubVI into a Top Level VIAccessing user-made subVIs
Functions >>All Functions >> Select a VIOr
Drag icon onto target diagram
1/19/2005 Vincenzo Giordano
![Page 24: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/24.jpg)
Save The VI
• Choose an Easy to Remember Location• Organize by Functionality
– Save Similar VIs into one directory (e.g. Math Utilities)• Organize by Application
– Save all VIs Used for a Specific Application into one directory or library file (e.g. Lab 1 – Frequency Response)
• Library Files (.llbs) combine many VI’s into a single file, ideal for transferring entire applications across computers
1/19/2005 Vincenzo Giordano
![Page 25: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/25.jpg)
Hardware Connections
SC-2075BNC-2120
NI-ELVIS
SCB-68
1/19/2005 Vincenzo Giordano
![Page 26: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/26.jpg)
Control applicationsControl applications
• Simulation of dynamical systems using Control Module
• Hardware in the loop- robot navigation example
1/19/2005 Vincenzo Giordano
![Page 27: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/27.jpg)
Control applicationControl applicationHardware in the loopHardware in the loop
1/19/2005 Vincenzo Giordano
Sensor Sensor feedbackfeedback
Acquire dataAcquire dataControl algorithmControl algorithm
Navigation strategyNavigation strategy
Control lawControl lawControl Control actionaction
Apply controlApply control
ReadingReading WritingWriting
![Page 28: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/28.jpg)
Real-time control
Real-Time ControllerHost computer
LabView Real time module
Compile and download
1/19/2005 Vincenzo Giordano
![Page 29: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/29.jpg)
1/19/2005 Vincenzo Giordano
![Page 30: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/30.jpg)
Back-up slides
1/19/2005 Vincenzo Giordano
![Page 31: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/31.jpg)
Timed-loops
• Multi-tasking system• Each loop is executed a prespecified period• Different levels of execution priority
1/19/2005 Vincenzo Giordano
![Page 32: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/32.jpg)
Exercise 2 – Simple Data AcquisitionComplete Convert C to F.vi, then create Thermometer.vi.
1/19/2005 Vincenzo Giordano
![Page 33: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/33.jpg)
Charts
Waveform chart – special numeric indicator that can display a history of values
Controls >> Graph Indicators >> Waveform Chart
1/19/2005 Vincenzo Giordano
![Page 34: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/34.jpg)
Wiring Data into Charts
Single Plot Charts Multiplot Charts
1/19/2005 Vincenzo Giordano
![Page 35: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/35.jpg)
Exercise 3 – Using loops Students build Use a loop.vi.
1/19/2005 Vincenzo Giordano
![Page 36: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/36.jpg)
Section V – Arrays & File I/O• Build arrays manually• Have LabVIEW build arrays automatically• Write to a spreadsheet file• Read from a spreadsheet file
1/19/2005 Vincenzo Giordano
![Page 37: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/37.jpg)
Adding an Array to the Front PanelFrom the Controls >> All Controls >> Array and Cluster subpalette, select the Array Shell
Drop it on the screen.
1/19/2005 Vincenzo Giordano
![Page 38: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/38.jpg)
Creating 2D Arrays
1/19/2005 Vincenzo Giordano
![Page 39: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/39.jpg)
Where Do I Go From Here?
• Example programs (Help» Find Examples…)• LabVIEW Student Edition (www.ni.com/labviewse)• Web resources (ni.com)
– NI Developer Zone (zone.ni.com)– Application Notes – Info-labview newsgroup (www.info-labview.org/)– Instrument Driver Library (www.ni.com/idnet)
1/19/2005 Vincenzo Giordano
![Page 40: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/40.jpg)
Adding an Array (cont.)
Place data object into shell (i.e. Numeric Control)
1/19/2005 Vincenzo Giordano
![Page 41: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/41.jpg)
File I/OFile I/O – passing data to and from files- Files can be binary, text, or spreadsheet- Write/Read LabVIEW Measurements file (*.lvm)
1/19/2005 Vincenzo Giordano
Writing to LVM fileWriting to LVM file Reading from LVM fileReading from LVM file
![Page 42: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/42.jpg)
Block Diagram Nodes
Icon Expandable Node Expanded Node
• Function Generator VI• Same VI, viewed three different ways• Yellow field designates a standard VI• Blue field designates an Express VI
1/19/2005 Vincenzo Giordano
![Page 43: An introduction to LabVIEW - UTA tutorial_vin.pdf · LabVIEW Programs Are Called Virtual Instruments (VIs) 1/19/2005 Vincenzo Giordano Front Panel User interface • Controls = Inputs](https://reader030.fdocuments.us/reader030/viewer/2022040304/5ea28b3da04bfb6a613fd4ce/html5/thumbnails/43.jpg)
1/19/2005 Vincenzo Giordano
Status Toolbar
Run Button
Continuous Run Button
Abort Execution
Pause/Continue Button
Text Settings
Align Objects
Distribute Objects
Reorder
Resize front panel objects
Additional Buttons on the Diagram Toolbar
Execution Highlighting Button
Step Into Button
Step Over Button
Step Out Button