Lab view introduction-threehour
-
Upload
e-labview -
Category
Technology
-
view
234 -
download
1
Transcript of Lab view introduction-threehour
Virtual Instrumentation With LabVIEW
Course GoalsCourse Goals
• Understand the components of a Virtual InstrumentUnderstand the components of a Virtual Instrument• Introduce LabVIEW and common LabVIEW functions • Build a simple data acquisition application• Create a subroutine in LabVIEWCreate a subroutine in LabVIEW
Section ISection I
• LabVIEW termsLabVIEW terms• Components of a LabVIEW application• LabVIEW programming tools• Creating an application in LabVIEWCreating an application in LabVIEW
LabVIEW Programs Are Called Virtual Instruments (VIs)
Front Panel• Controls = Inputs
O• Indicators = Outputs
Block Diagram• Accompanying “program”Accompanying program
for front panel• Components “wired”
together
VI Front PanelVI Front PanelFront Panel Toolbar
IconToolbar
G hBooleanControl Graph
LegendControl
WaveformWaveformGraph
PlotL d
ScaleL dLegend Legend
VI Block DiagramgBlock Diagram
SubVI
Toolbar DivideFunction
GraphTerminal
SubVI
Wire Data
Terminal
Data
While LoopStructure
Numeric Constant
Timing Function
Boolean Control Terminal
Express VIs, VIs and FunctionsExpress VIs, VIs and Functions• Express VIs: interactive VIs with configurable dialog page• Standard VIs: modularized VIs customized by wiring• Functions: fundamental operating elements of p g
LabVIEW; no front panel or block diagramFunctionFunction
Express VIExpress VI Standard VIStandard VI
Controls and Functions PalettesControls and Functions Palettes
Controls Palette(Front Panel Window)
Functions Palette(Block Diagram Window)
Tools Palette• Floating Palette• Used to operate and modify• Used to operate and modify
front panel and block diagram objects.j
Automatic Selection Tool
Operating Tool
Positioning/Resizing Tool
Scrolling Tool
Breakpoint Tool
Labeling Tool
Wiring Tool
Probe Tool
Color Copy ToolWiring Tool
Shortcut Menu Tool
Color Copy Tool
Coloring Tool
Status Toolbar
R B tt
Status Toolbar
Run Button
Continuous Run Button Additional Buttons on the Diagram Toolbar
Abort Execution
Pause/Continue Button Execution Highlighting Button
g
Text Settings
Align ObjectsStep Into Button
Step Over ButtonDistribute Objects
Reorder
Step Over Button
Step Out Button
Resize front panel objects
Open and Run a Virtual InstrumentOpen and Run a Virtual InstrumentExample finder
Creating a VIFront Panel Window
Creating a VI
Block Diagram WindowBlock Diagram Window
ControlTerminals
Indicator Terminals
Creating a VI – Block Diagramg g
Wiring Tips – Block DiagramWiring Tips Block DiagramWiring “Hot Spot” Click To Select Wires
Clean Up WiringUse Automatic Wire Routing
Dataflow Programming• Block diagram executes
dependent on the flo of data
g g
dependent on the flow of data; block diagram does NOT execute left to rightexecute left to right
N d t h d t i • Node executes when data is available to ALL input terminals
• Nodes supply data to all output t i l h dterminals when done
Help OptionsHelp Options
C t t H lContext Help• Online help• Lock helpLock help• Simple/Complex Diagram help• Ctrl + H
Online reference• All menus online• Pop up on functions in diagram to access online info directly
Exercise 1 - Convert °C to °FExercise 1 Convert C to F
Debugging TechniquesDebugging Techniques• Finding Errors
• Execution Highlighting
Click on broken Run buttonWindow showing error appears
• Execution HighlightingClick on Execution Highlighting button; data flow is animated using bubbles. Values are
• Probe
gdisplayed on wires.
Ri ht li k i t di l b d itRight-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
Section II – SubVIsSection II SubVIs
• What is a subVI?• Making an icon and • Making an icon and
connector for a subVIUsing a VI as a s bVI• Using a VI as a subVI
Block Diagram NodesBlock Diagram Nodes
Icon Expandable Node Expanded Node Icon Expandable Node Expanded Node
• Function Generator VI• Same VI, viewed three different waysSame VI, viewed three different ways• Yellow field designates a standard VI
Blue field designates an Express VI• Blue field designates an Express VI
SubVIsSubVIs• A SubVI is a VI that can be used within another VI• Similar to a subroutine• Advantagesg
– Modular– Easier to debugas e to debug– Don’t have to recreate code– Require less memoryRequire less memory
Icon and Connector
• An icon represents a VI in other block di
Icondiagrams
• A connector shows available Terminals
A connector shows available terminals for data transfer
ConnectorConnector
SubVIs S b VIS b VISubVIs Sub VIsSub VIs
Steps to Create a SubVISteps to Create a SubVI
• Create the IconCreate the Icon• Create the Connector• Assign Terminals• Save the VISave the VI• Insert the VI into a Top Level VI
Create the IconCreate the Icon• Right-click on the icon in the block diagram or front panel
Create the ConnectorCreate the ConnectorRight click on the icon pane (front panel only)
Assign TerminalsAssign Terminals
Save The VISave The VI
• Choose an Easy to Remember Locationy• Organize by Functionality
– Save Similar VIs into one directory (e g Math Utilities)– Save Similar VIs into one directory (e.g. Math Utilities)• Organize by Application
S ll VI U d f S ifi A li ti i t– Save all VIs Used for a Specific Application into one directory or library file (e.g. Lab 1 – Frequency Response)Response)
• Library Files (.llbs) combine many VI’s into a single file, ideal for transferring entire applications across computers
Insert the SubVI into a Top Level VIInsert the SubVI into a Top Level VIAccessing user-made subVIs
Functions >>All Functions >> Select a VIOr
D i diDrag icon onto target diagram
Tips for Working in LabVIEWTips for Working in LabVIEW
• Keystroke Shortcutsy– <Ctrl-H> – Activate/Deactivate Context Help Window– <Ctrl-B> – Remove Broken Wires From Block DiagramCtrl B Remove Broken Wires From Block Diagram– <Ctrl-E> – Toggle Between Front Panel and Block
Diagramg– <Ctrl-Z> – Undo (Also in Edit Menu)
• Tools » Options… – Set Preferences in LabVIEWTools » Options… Set Preferences in LabVIEW• VI Properties – Configure VI Appearance, Documentation etcDocumentation, etc.
Section III – Data AcquisitionSection III Data Acquisition
DAQ Device• Data acquisition (DAQ) basics• Connecting Signals• Simple DAQ application
Computer
Sensors
Terminal Block
Cable
DAQ – Data AcquisitionDAQ Data AcquisitionTemperature Acquisition using the DAQ Assistant
Data Acquisition TerminologyData Acquisition Terminology
• Resolution - Determines How Many Different Voltage Resolution Determines How Many Different Voltage Changes Can Be Measured
Larger Resolution More Precise Representation of Signal– Larger Resolution More Precise Representation of Signal• Range - Minimum and Maximum Voltages
– Smaller range More Precise Representation of Signal• Gain Amplifies or Attenuates Signal for Best Fit in • Gain - Amplifies or Attenuates Signal for Best Fit in Range
Hardware ConnectionsHardware Connections
SC-2075BNC-2120
SC 2075
SCB-68
NI-ELVIS
SCB-68
Exercise 2 – Simple Data AcquisitionExercise 2 Simple Data AcquisitionComplete Convert C to F.vi, then create Thermometer.vi.
Section IV – Loops and ChartsSection IV Loops and Charts
• For Loopp• While Loop• Charts• Charts• Multiplots
LoopsLoops
• While Loopsp– Have Iteration Terminal– Always Run at least Once– Run According to Conditional
Terminal
• For LoopsHave Iteration Terminal– Have Iteration Terminal
– Run According to input N of Count Terminal
Loops (cont.)p ( )1. Select the loop 2. Enclose code to be repeated
3. Drop or drag additional nodes and then wire
ChartsCharts
Waveform chart – special numeric indicator that can display a history of values
Controls >> Graph Indicators >> Waveform Chart
Wiring Data into ChartsWiring Data into Charts
Single Plot Charts Multiplot Chartsg p
Exercise 3 – Using loops Exercise 3 Using loops Students build Use a loop.vi.
Section V – Arrays & File I/OSection V Arrays & File I/O• Build arrays manually• Have LabVIEW build arrays automatically• Write to a spreadsheet filep• Read from a spreadsheet file
Adding an Array to the Front PanelAdding an Array to the Front PanelFrom the Controls >> All Controls >> Array and Cl t b l tt l t th A Sh llCluster subpalette, select the Array Shell
Drop it on the screen.
Adding an Array (cont.)Adding an Array (cont.)
Place data object into shell (i.e. Numeric Control)j ( )
Creating an Array with a LoopCreating an Array with a Loop
• Loops accumulate arrays at their boundariesp y
Creating 2D ArraysCreating 2D Arrays
File I/OFile I/OFile I/O – passing data to and from files- Files can be binary, text, or spreadsheet- Write/Read LabVIEW Measurements file (*.lvm)( )
Writing to LVM fileWriting to LVM file Reading from LVM fileReading from LVM file
Write LabVIEW Measurement FileWrite LabVIEW Measurement File• Includes the open, write, close and error handling functions
f• Handles formatting the string with either a tab or comma delimiter
• Merge Signals function is used to combine data into the dynamic data type
Exercise 4 – Analyzing and Logging DataExercise 4 Analyzing and Logging DataStudents build Temperature Logger.vi
Where Do I Go From Here?Where Do I Go From Here?
• Example programs (Help» Find Examples…)Example programs (Help» Find Examples…)• LabVIEW Student Edition (www.ni.com/labviewse)• Web resources (ni.com)
– NI Developer Zone (zone.ni.com)NI Developer Zone (zone.ni.com)– Application Notes
Info labview newsgroup (www info labview org/)– Info-labview newsgroup (www.info-labview.org/)– Instrument Driver Library (www.ni.com/idnet)