labview basic i-中文版
TRANSCRIPT
TM
Course Software Version 7.0June 2003 EditionPart Number 320628L-01
LabVIEW
Copyright© 1993�–2003 National Instruments Corporation. All rights reserved. Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying, recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of National Instruments Corporation.
TrademarksCVI�™, IVI�™, FieldPoint�™, LabVIEW�™, Measurement Studio�™, MXI�™, National Instruments�™, National Instruments Alliance Program�™, NI�™, NI Developer Zone�™, NI-488.2�™, ni.com�™, NI-DAQ�™, and SCXI�™ are trademarks of National Instruments Corporation.Tektronix® and Tek are registered trademarks of Tektronix, Inc. Other product and company names mentioned herein are trademarks or trade names of their respective companies.
PatentsFor patents covering National Instruments products, refer to the appropriate location: Help»Patents in your software, the patents.txt file on your CD, or ni.com/legal/patents.
Worldwide Technical Support and Product Informationni.com
National Instruments Corporate Headquarters11500 North Mopac Expressway Austin, Texas 78759-3504 USA Tel: 512 683 0100
Worldwide OfficesAustralia 1800 300 800, Austria 43 0 662 45 79 90 0, Belgium 32 0 2 757 00 20, Brazil 55 11 3262 3599, Canada (Calgary) 403 274 9391, Canada (Montreal) 514 288 5722, Canada (Ottawa) 613 233 5949, Canada (Québec) 514 694 8521, Canada (Toronto) 905 785 0085, Canada (Vancouver) 514 685 7530, China 86 21 6555 7838, Czech Republic 420 2 2423 5774, Denmark 45 45 76 26 00, Finland 385 0 9 725 725 11, France 33 0 1 48 14 24 24, Germany 49 0 89 741 31 30, Greece 30 2 10 42 96 427, India 91 80 51190000, Israel 972 0 3 6393737, Italy 39 02 413091, Japan 81 3 5472 2970, Korea 82 02 3451 3400, Malaysia 603 9131 0918, Mexico 001 800 010 0793, Netherlands 31 0 348 433 466, New Zealand 1800 300 800, Norway 47 0 66 90 76 60, Poland 48 0 22 3390 150, Portugal 351 210 311 210, Russia 7 095 238 7139, Singapore 65 6226 5886, Slovenia 386 3 425 4200, South Africa 27 0 11 805 8197, Spain 34 91 640 0085, Sweden 46 0 8 587 895 00, Switzerland 41 56 200 51 51, Taiwan 886 2 2528 7227, Thailand 662 992 7519, United Kingdom 44 0 1635 523545
© National Instruments Corporation 1 LabVIEW
LabVIEW 2 ni.com
© National Instruments Corporation 3 LabVIEW
LabVIEW 4 ni.com
LabVIEWBasics I:
Introduction
LabVIEWBasics II:
Development
© National Instruments Corporation 5 LabVIEW
LabVIEW 6 ni.com
1 2 3 * *
1 2
3
© National Instruments Corporation 7 LabVIEW
LabVIEW palette
LabVIEW Tools' OptionsControls/Functions Palettes Palette View Express FormatStandard OK
Exercises
nidevsim.zip
Solutions
LabVIEW 8 ni.com
© National Instruments Corporation 9 LabVIEW
LabVIEW 10 ni.com
» »File»Page Setup»Options File
Page Setup Options
<Ctrl> Windows <Ctrl>(Mac OS) <Command>
(Sun) <Meta> (Linux) <Alt>
<Enter> (Mac OS) <Return> <Enter>
monospace
monospace bold
Platform
(Mac OS) <Command>
© National Instruments Corporation 1-1 LabVIEW
LabVIEW
Getting Started with LabVIEW LabVIEWGetting Started with LabVIEW LabVIEW
LabVIEW
PDF LabVIEW Help»Search the LabVIEW Bookshelf LabVIEW Bookshelf Getting Started with LabVIEW
A. LabVIEWB. LabVIEWC. LabVIEWD. LabVIEWE. (dataflow programming)F. LabVIEWG.
1
LabVIEW 1-2 ni.com
LabVIEW VILabVIEW
LabVIEW VI Front Panel Block Diagram
LabVIEW
LED
LabVIEWGPIB, PXI, VXI, RS-232, RS-485 LabVIEW
LabVIEW Web Server TCP/IPActiveX .
LabVIEW
DLL LabVIEW
1
© National Instruments Corporation 1-3 LabVIEW
LabVIEW
LabVIEW�• File»Exit�• VI
�– New VI NewVI New
�– Open VI Open
�– ConfigureConfigure LabVIEW
�– Help LabVIEW Help HelpNI Example Finder
1
LabVIEW 1-4 ni.com
LabVIEW New NewFile»New Create
new Front panel preview Block diagram preview VIDescription 1-2 New Error Handling VI
VI SubVI
OK Create newVI
VI VILabVIEW New
Blank VI <Ctrl-N> VI
New Create new Blank VIFile»New VI VI
1
© National Instruments Corporation 1-5 LabVIEW
New LabVIEWVI VI
New
�• Create new�— VILabVIEW OK
VI LabVIEW�– Blank VI�—�– VI from Template�—
VI�• DAQ�— DAQ
Assistant Express VI NI-DAQmx
�• Frameworks�—VI
�• Instrument I/O�—GPIB
�• Simulated�—
�• Tutorial (Getting Started)�—Getting Started VI
�– Other Document Types�— LabVIEW
�• Browse for Template�— Browse VI
Browse
�• Front panel preview�— Create new VI
�• Block diagram preview�— Create new VI
�• Description�— Create new VI
1
LabVIEW 1-6 ni.com
VI File»Open Choose the VI to open VI
VI C:\Exercises\LabVIEW Basics I
VI
VI subVI LoadingNumber Loaded subVI
Stop
LabVIEW subVI VI Search PathTools»Options
Paths VI Search Path LabVIEWSearching VI Ignore SubVILabVIEW subVI BrowsesubVI
File Save Save As Save All Save with OptionsVI VI
VI VI .llb National Instruments VI
LabVIEWTools»
Options MiscellaneousLabVIEW
VI VI
1
© National Instruments Corporation 1-7 LabVIEW
VI Mac OSWindows LabVIEW VI
VIVI FTP Z XModem
VIVI
�• (Windows) MacDisk TransferPro Mac OS PC
�• (Mac OS) DOS Mounter MacLink Apple File ExchangePC Mac OS
�• (Sun) PC File System (PCFS) PC Sun
VI DDEVI ActiveX VI AppleEvent
Porting and Localizing LabVIEW VIs Application NoteVI Help»Search the LabVIEW
Bookshelf
VI OpenSave Copy Paste LabVIEW
(Mac OS)
(Windows and UNIX)
Tools»OptionsMiscellaneous
VI
�• File
�• Edit LabVIEW�• Operate VI�• Tools LabVIEW VI�• Browse VI
1
LabVIEW 1-8 ni.com
�• WindowError List
�• Help LabVIEWLabVIEW National Instruments
VIVI LabVIEW
1
© National Instruments Corporation 1-9 LabVIEW
123456
78 Multiply9101112 XY
1314 XY15 Bundle16 SubVI17 For Loop
2
9
11
12
10
4
2
2
1
3
6
7
8
513
14
16
15
17
1
LabVIEW 1-10 ni.com
VI
Run VI LabVIEW VIRun VI
VI connector paneVI subVI
VI VI VI Runcaller subVI
VI subVI Run
VI RunRun
VIError list
Run ContinuouslyVI
VI Abort ExecutionVI VI
VI VI
Abort Execution VI VIVI VI
VI
Pause VIPause LabVIEW
Pause VI
Text Settings VI
Align Objects
Distribute Objects
1
© National Instruments Corporation 1-11 LabVIEW
Resize Objects
ReorderMove Forward Move Backward
Move To Front Move To Back
Show Context Help WindowContext Help
Type<Enter>
Enter
VIVI
Highlight Execution Run
Step Into nodeStep Into subVI
<Ctrl>VI VI
Step Over<Ctrl>
By stepping over the node, you execute the node without single-stepping through the node.
Step OutVI Step Out
<Ctrl> By stepping out of a node, you complete single-stepping through the node and go to the next node.
VI Error List Show Warnings Warning
VI
1
LabVIEW 1-12 ni.com
LabVIEW palette VITools Controls
Functions
Tools VI Tools
Window»Show Tools Palette Tools
<Shift>
LabVIEW
<Tab>Automatic Tool Selection
<Shift-Tab> Automatic Tool Selection
<Tab><Shift-Tab> Automatic Tool Selection
OperatingOperating
1
© National Instruments Corporation 1-13 LabVIEW
PositioningPositioning
LabelingLabeling
Wiring wire
Object Shortcut Menu
Scrolling
Breakpoint VI
Probeprobe Probe VI
Color Copy Coloring
Coloring
Controls FunctionsVI
1-4
1
LabVIEW 1-14 ni.com
Functions 1-5VI
VI VIVI
Controls Functions Options
1. Controls Functions Options Options
Controls/Functions Palettes2. Palette View3. Format Standard All Icons
All Text Icons and Text4. OK Controls Functions
Controls FunctionsVI
�• Up to Owning Palette�—
1
© National Instruments Corporation 1-15 LabVIEW
�• Search�—VI
Random NumberFunctions Search
Random Number LabVIEW
Up to Owning Palette
LabVIEW
1-6meter
1
LabVIEW 1-16 ni.com
1
© National Instruments Corporation 1-17 LabVIEW
property dialog box
Properties1-7 1-6
1
LabVIEW 1-18 ni.com
front panel VI 1-8
control indicatorVI
LEDVI block diagram
ControlsWindow»
Show Controls Palette
Express
Express Controls FunctionsExpress VI
All Controls All FunctionsVI
1
© National Instruments Corporation 1-19 LabVIEW
Advanced Controls FunctionsVI
Express Express VI
Express (Controls)(Functions) All Controls All Functions Advanced
Controls Functions Options
OperatingLabeling Operating
<Enter>
BooleanLED
LED
12
3
21
3
1
LabVIEW 1-20 ni.com
block diagramterminal
VI (wire)
1-9 VI (Node)(terminal)
Functions VI Window»Show Functions Palette
Express
LabVIEW Express VI VIExpress VI
VI
1 2 3 4
1
2
4
3
1
© National Instruments Corporation 1-21 LabVIEW
VIExpress VI
Express VI Express VIExpress VI
subVI LabVIEW User Manual Express VI subVI
VI LabVIEW VI VI subVI
subVILabVIEW
VI VI
VI subVIVI subVI
LabVIEWconnector pane
VI
subVI structuresCase For Loop While Loop
1-9 Add Subtract
1
LabVIEW 1-22 ni.com
VI Express VISubVI Express VI
Basic Function Generator VIBasic Function Generator VI
subVIExpress VI
subVI Express VI subVI Express VI View As Icon
1. Positioning
2.3.
terminal4.
Basic Function Generator VI
subVI Express VI
1
© National Instruments Corporation 1-23 LabVIEW
terminal
DBL
View As IconDBL
1-9a b AddSubtract Add Subtract
1-9a+b a�–b 1-9Add Subtract
Visible Items»Terminals
1-9Add Subtract
VI
X
1
LabVIEW 1-24 ni.com
LabVIEWVI
terminal
Express VI
dynamic data type Express VI
Express VI
LabVIEW VIVI
Convert from Dynamic Data Express VIVI
Convert from Dynamic Data Express VIConfigure Convert from Dynamic Data
Configure Convert from Dynamic DataConvert from Dynamic Data Express VI
LabVIEWConvert from Dynamic Data Express VI Convert from Dynamic Data Express VI Configure
1
© National Instruments Corporation 1-25 LabVIEW
Convert from Dynamic Data
Convert to Dynamic Data Express VIExpress VI
Convert to Dynamic Data Express VIConfigure Convert to Dynamic Data
LabVIEWLabVIEW
LabVIEW
LabVIEW
Positioning Tools»Options Block
Diagram
Wiring terminalContext Help
1
LabVIEW 1-26 ni.com
VILabVIEW
VI LabVIEW
VI1. LabVIEW2. LabVIEW New
New
3. Create new VI from Template»Tutorial (Getting Started)»Generate and Display VI
Front panel preview Block diagram previewVI New Generate and
Display VI
1
© National Instruments Corporation 1-27 LabVIEW
4. OK Create new VI
5. VI Front Panel
Generate and Display VI
Window»Show Front Panel
VI block diagramVI
Generate and Display VI
Window»Show Block Diagram
7. Run
1
LabVIEW 1-28 ni.com
8. STOP VI
VI
Edit»Undo <Ctrl-Z>
1. Controls Window»Show Controls Palette
2. Numeric Controls
3. Numeric Controls Numeric Controls4. Numeric Controls
5. File»Save As VI Acquiring a Signal.viC:\Exercises\LabVIEW Basics I
VI C:\Exercises\LabVIEW Basics I
Simulate SignalSimulate Signal Express VI Simulate Signal Express VI
1. Window»Show Block Diagram
Simulate Signal Express VI Express VI
Simulate Signal Express VI2. Simulate Signal Express VI
Properties Configure Simulate Signal3. Signal type Sawtooth
1
© National Instruments Corporation 1-29 LabVIEW
Result PreviewConfigure Simulate Signal
4. OK Configure Simulate Signal
5. Simulate Signal Express VI6. Express VI
AmplitudeSimulate Signal Express VI
Amplitude
Amplitude Configure Simulate SignalAmplitude
Simulate Signal Express VI Amplitude1. Knob Positioning
1
LabVIEW 1-30 ni.com
PositioningPositioning
2. Knob Simulate Signal Express VI Knob
3. Knob4. Knob
WiringWiring
5. Wiring Simulate Signal Express VI Amplitude
Express VI6. File»Save VI
VI Acquiring a Signal VI1. Window»Show Front Panel
<Ctrl-E>
2. Run3.
OperatingOperating
4. Operating
yVI Run
VI5. STOP VI
1
© National Instruments Corporation 1-31 LabVIEW
Abort Execution Abort Execution VI National Instruments
STOP VI STOPAbort Execution
1. Positioning Simulate Signal Express VIWaveform Graph
2. <Delete>3. Functions Window»Show
Functions Palette4. Arithmetic & Comparison Scaling and Mapping
Express VI Simulate Signal Express VI Waveform GraphExpress VI Waveform Graph
Express VI Configure Scaling and Mapping
5. Slope (m) 10 Configure Scaling and Mapping
1
LabVIEW 1-32 ni.com
6. OK Configure Scaling and Mapping
7. Simulate Signal Express VI Sawtooth8. Wiring Scaling and Mapping
Express VI Signals
9. Wiring Scaling and Mapping Express VI Scaled Signals Waveform Graph
Express VI Express VI
10. File»Save VI
Simulate Signal Express VIScaling and Mapping Express VI Merge
Signals1. Simulate Signal Express VI Sawtooth
2. Wiring Sawtooth Waveform Graph
Merge Signals ,
1
© National Instruments Corporation 1-33 LabVIEW
3. File»Save VI <Ctrl-S> VI4. VI
yScaling
and Mapping Express VI slope 105. STOP
Amplitude
1. PropertiesKnob Properties
2. Appearance Label KnobAmplitude
Knob Properties
1
LabVIEW 1-34 ni.com
3. Scale Scale Range 5.0
4. OK Knob Properties
5. VI
VIEdit»Undo <Ctrl-Z>
6. Knob PropertiesScale Marker
Text Color7. Cancel
OK
1.
1
© National Instruments Corporation 1-35 LabVIEW
2.
3. PropertiesGraph Properties
4. Plots Sawtooth Line Color
5. Sawtooth (Scaled)6. Don�’t use waveform names for plot names7. Name
Scaled Sawtooth8. OK Graph Properties
9. Graph PropertiesScales autoscale
10. CancelOK
11. VI
1
LabVIEW 1-36 ni.com
LabVIEW VI
Visual Basic C++ JAVA
50.0Subtract
Add Subtract
Add Random Number Divide Add Divide
Random Number
error clusters
1
© National Instruments Corporation 1-37 LabVIEW
NI Example FinderVI 10 Hz 10 1
filter1. Help»Find Examples NI Example Finder2. Search Type in the word(s) to search for
filter
Express VI
3. filter filter VI4. Express Filter.vi VI5. VI
6. Highlight Execution
7. Run
1
LabVIEW 1-38 ni.com
8.Tone Measurements2 Express VI Filter
9. VI
1
© National Instruments Corporation 1-39 LabVIEW
Context Help LabVIEW Help NI Example FinderVI LabVIEW Help
LabVIEW
Context HelpLabVIEW Context Help
Context Help Help»Show Context Help <Ctrl-H> Show Context Help Window
Context HelpsubVI
Context Help
1-10 Context Help
Context Help Hide Optional Terminals and Full Path Optional Terminal
VI Full Pathdetailed mode
1-11
1
LabVIEW 1-40 ni.com
Lock Context Help Context Help
Help
Context Help LabVIEW HelpHelp Click here for more help.
More Help LabVIEW Help
Context Help More Help Help»VI, Function, & How-To Help Context HelpClick here for more help. LabVIEW Help
LabVIEW Help VILabVIEW Help LabVIEW LabVIEW
Help�• LabVIEW Bookshelf LabVIEW Application
Notes PDF�• National Instruments NI Developer
Zone KnowledgeBase Product Manuals Library
New LabVIEW VIVI VI LabVIEW
VI VIVI
LabVIEW VI ni.com/zoneNI Developer Zone VI LabVIEW VI
1
© National Instruments Corporation 1-41 LabVIEW
NI Example Finder NI Example FinderNI Developer Zone
NI Example FinderHelp»Find Examples LabVIEW Open
Examples NI Example Finder
1
LabVIEW 1-42 ni.com
VI Express VIVI VI
VIExpress VI
VI1. LabVIEW New
Blank VI <Ctrl-N> VI
2. FunctionsFunctions
FunctionsControls
Express VI
1
© National Instruments Corporation 1-43 LabVIEW
1. Context Help <Ctrl-H> Context Help Show Context Help Window
Context Help2. Functions Input Input
Express VIContext Help Express VI
3. Context HelpExpress VI
4. Express VI Configure Simulate Signal
5. Configure Simulate SignalFrequency (Hz) Amplitude Samples per second
(Hz) Context Help6. Simulate Signal Express VI frequency 10.7
amplitude 2
7. Result Preview8. OK Configure Simulate Signal9. Simulate Signal Express VI Context
HelpContext Help Simulate Signal Express VI
10. VI Reduce Samples.vi C:\Exercises\LabVIEW Basics I
LabVIEW HelpExpress VI
1. Help»VI, Function, & How-To Help LabVIEW Help2. Search Type in the word(s) to search for
sample compressionExpress VI
3. <Enter> List Topics4. Sample Compression Sample
Compression Express VI5. Express VI Place on the block diagram
Express VI6.
LabVIEW Sample Compression Express VI
1
LabVIEW 1-44 ni.com
7. Sample Compression Express VI Simulate Signal Express VI
8. Sample Compression Express VI25
9. Configure Sample Compression10. Wiring Simulate Signal Express VI Sine
Sample Compression Express VI Signals
Controls
1. Sample Compression Express VI MeanCreate»Numeric Indicator
2. Sample Compression Express VI MeanInsert Input/Output Enable
3. Enable Create»Control Enable
4. Simulate Signal Express VI Sine Signal Compression Express VI Signals
Create»Graph Indicator
LabVIEW terminal
5. Wiring Sample Compression Express VI MeanSine
Merge Signals6.
1
© National Instruments Corporation 1-45 LabVIEW
7.
8. VI
VIVIWhile Loop While Loop
1. VIVI
STOP2. Functions»Execution Control While
Loop3. While Loop
1
LabVIEW 1-46 ni.com
4. Express VI
While Loop, STOPWhile Loop STOP
5. VIVI STOP While Loop
STOPWhile Loop
VI1. Functions»Execution Control Time
Delay Express VI2. Time delay (seconds) .250
.250
3. Configure Time Delay4. VI5. VI6. Enable
EnableEnable
1
© National Instruments Corporation 1-47 LabVIEW
7. STOP VI
1. Controls»Text Indicators Express Table
2.Table Build Table Express VI
3. Build Table Express VI TableBuild Table Express VI Table
Build Table Express VITable
Build Table Express VITable
4. Mean While LoopWhile Loop Build Table Express VI
Table5. Wiring Sample Compression Express VI Mean
Build Table Express VI Signals
6. VI 7. Enable
1
LabVIEW 1-48 ni.com
Enable8. VI9. Table Properties
10. VI
1
© National Instruments Corporation 1-49 LabVIEW
VI Run VI RunVI
VI
Run Windows»Show Error ListError list
Highlight Execution
VI
VI
VI VI VIsingle-step VI
subVI Step Over Step IntoStep Over Step Into Step Out
subVI
VIsubVI
Probe VIbreakpoint
1
LabVIEW 1-50 ni.com
Custom Probe»New
Breakpoint VI
VILabVIEW
LabVIEWBreakpoint
Breakpoint
1
© National Instruments Corporation 1-51 LabVIEW
VIVI
1. File»Open C:\Exercises\LabVIEW Basics I Debug Exercise (Main) VI
RunVI
2. Window»Show Block Diagram
Functions»Arithmetic & Comparison»Express NumericRandom Number (0-1) 0 1Functions»Arithmetic & Comparison»Express NumericMultiply function 10.0
Functions»Arithmetic & Comparison»Express Numericnumeric constant
C:\Exercises\LabVIEW Basics I Debug Exercise (Sub) VI 100.0
3.a. Run Error list
b. Error list Details
1
LabVIEW 1-52 ni.com
c. Help LabVIEW Help
d. Show Error
e. Error list4. File»Save VI5. Window»Show Front Panel
6. Run VI7. Window»Show Block Diagram8.
a. Highlight Execution
b. Step Into
c. Step OverStep Over
VI VI10.0 subVI 100.0
d. Step OutDebug Exercise (Main) VI
9. VI subVIa. Step Intob. Debug Exercise (Sub) VI Step Into
subVIc. Debug Exercise (Main) VI
Debug Exercise (Main) VIsubVI subVI
d. Debug Exercise (Sub) VIe. Step Out subVI Debug
Exercise (Main) VI f. Step Out
10. VI
1
© National Instruments Corporation 1-53 LabVIEW
a. Probe
LabVIEW Probe
b. VI Probe11. breakpoint
a. Breakpoint
b. Run VI VIPause
c. ContinueVI
d. Breakpoint12. Highlight Execution13. File»Close VI
1
LabVIEW 1-54 ni.com
�• (VI) front panelblock diagram icon and connector
pane�• VI VI�•�• Tools VI <Shift>
Tools�• Controls
Controls�• Functions VI
Functions�• Controls Functions Search
VI�• LabVIEW
�• Help Context Help LabVIEW HelpVI
�• Help»Search the LabVIEW BookshelfLabVIEW Bookshelf LabVIEWApplication Notes PDF
�• VI
�•
Change to Indicator Change to Control�•�• Run VI
Run Error list
�•VI
1
© National Instruments Corporation 1-55 LabVIEW
�•VI File»Save <Ctrl-S>
�– <Ctrl-R> VI�– <Ctrl-E> �– <Ctrl-H> Context Help�– <Ctrl-B> �– <Ctrl-F> VI VI global
�• OperatingLabeling
<Shift>�•
File»VI Properties ExecutionAllow Debugging
�• Show Context Help Window Context Help Context Help
�•�•
<Shift>�• <Esc>
�• Wiring�• Visible Items»
Terminals connector pane�•
1
LabVIEW 1-56 ni.com
�• constant�– Create»
Constant Create»Control Create»Indicator�–�–
�• Positioning<Ctrl>
�• Positioning<Shift>
�•<Shift>
�•<Ctrl>
�•Replace
�• VI subVI <Ctrl>Operating Positioning subVI
�• VI subVI OperatingPositioning subVI
Browse»This VI�’s SubVIs�• <Enter>�• ring control Case
<Shift-Enter> <Shift-Enter>
Case�•
Color Copy
1 2
12
1 2
1
© National Instruments Corporation 1-57 LabVIEW
Coloring Coloring<Ctrl>
�• Edit»Undo�• Positioning
<Ctrl>
�•�– <Ctrl-down arrow> �– <Ctrl-right arrow> �– <Ctrl-up arrow>
1
LabVIEW 1-58 ni.com
1
© National Instruments Corporation 1-59 LabVIEW
1
LabVIEW 1-60 ni.com
© National Instruments Corporation 2-1 LabVIEW
LabVIEW LabVIEW VIVI subVI
VI subVI
A. subVIB.C. VI subVID. VI subVI
2
LabVIEW 2-2 ni.com
LabVIEW VI VIVI
VI VI subVI subVIsubVI
front panel block diagram
subVILabVIEW
VI VI
VI subVI VIVIVI subVI
VI subVI
VI subVIVI
VI subVI
VIsubVI
2
© National Instruments Corporation 2-3 LabVIEW
subVI subVITemperature VI subVI
VI subVI
LabVIEW Basics II: Development Course Manual
subVI
function average (in1, in2, out)
{
out = (in1 + in2)/2.0;
}
main
{
average (point1, point2, pointavg)
}
2
LabVIEW 2-4 ni.com
2
© National Instruments Corporation 2-5 LabVIEW
VI subVI
VIVIVI subVI VI
subVI
LabVIEWVI
Edit IconFile»
VI Properties Category General Edit Icon
Icon Editor
LabVIEW
EditLabVIEW
LabVIEW 32 32
Icon Editor Copy fromCopy from
OK
2
LabVIEW 2-6 ni.com
VI
Icon Editor
Pencil
Line<Shift>
Color Copy
Fill
Rectangle
Filled Rectangle
Select<Delete>
Text(Windows) Small Fonts
Foreground/Background
�• Show Terminals�—�• OK�—�• Cancel�—
Icon Editor UndoRedo Cut Copy Paste Clear
VI subVIVI
2
© National Instruments Corporation 2-7 LabVIEW
VI subVI
Show Connector
LabVIEW
LabVIEW
Patterns VI
VI
subVI28
passing references
VI VI
Flip Horizontal Flip Vertical Rotate 90 Degrees
2
LabVIEW 2-8 ni.com
VI
Wiring
2
© National Instruments Corporation 2-9 LabVIEW
VI
1. VI
2. Window»Tile Left and RightWindow»Tile Up and Down
3.a. Controls»Numeric Controls Numeric Controls
Controls
b. Numeric Control
c. deg C <Enter> EnterLabVIEW
LabelingProperties
4.a. Controls»Numeric Indicators Numeric
Indicatorb.c. deg F <Enter> Enter
2
LabVIEW 2-10 ni.com
5. Window»Show Block Diagram
LabVIEWterminal
6. Functions»Arithmetic & Comparison»Express NumericMultiply deg CFunctions
7. Functions»Arithmetic & Comparison»Express NumericAdd Multiply
8. Functions»Arithmetic & Comparison»Express NumericNumeric Constant Multiply
1.80
Labeling9. Add Functions»Arithmetic &
Comparison»Express Numeric Numeric Constant32.0
10. Wiring
�• Wiring
�•
�• Multiply AddVisible Items»Terminals
Visible Items»Terminals
2
© National Instruments Corporation 2-11 LabVIEW
�• Wiring
Context Help Context Help
�• <Esc>
11. Window»Show Front Panel
12. Convert C to F.vi VI C:\Exercises\LabVIEW Basics I
13. VIa. Operating Labeling
b. Run VIc. VI
14.Edit Icon Icon Editor
15. Icon Editor Select
16. <Delete>17. Rectangle
18.
2
LabVIEW 2-12 ni.com
a. TextSmall Fonts
b. Textc. C F
d. Pencil
Pencil <Shift>
e. Selectf. B & W Copy from 256 Colors
LabVIEW
g. 16 Colors Copy from 256 Colorsh. OK Icon Editor
19. Show ConnectorLabVIEW
deg C deg F LabVIEW
20.a. Help»Show Context Help Context Helpb. Wiring
c. deg Cd.
e. deg Ff.g. Context Help
21. VI VI
2
© National Instruments Corporation 2-13 LabVIEW
VI VIsubVI subVI Functions»All Functions»Select a VI subVI VI
VI VIPositioning subVI VI
VI
VI subVI OperatingPositioning subVIBrowse»This VI�’s SubVIs VI subVI
<Ctrl> Operating PositioningsubVI
subVI subVIsubVI subVI
subVI
Context Help Help»Show Context Helprequired recommended
optional Context Help Hide Optional Terminals and Full Path
subVI
This Connection Is RequiredRecommended Optional
subVI
subVIVI
LabVIEW VIRecommended VI
required Functions»All Functions»File I/ORead File
2
LabVIEW 2-14 ni.com
VI DAQ Signal Accessory
23 °C0.23 V Device 1 Channel 0
Device 1 DAQ DAQ
1. LabVIEW NewBlank VI <Ctrl-N> VI
2.
a. Controls»Numeric Indicators
b. Temperature <Enter>Enter
c. Visible Items»Digital Display
d. Controls»Buttons & Switches
e. Temp Scale <Enter> Enter
f. Labelingdeg C
g. FALSE deg F
2
© National Instruments Corporation 2-15 LabVIEW
3. VI VI Context Helpa. File»VI Properties VI Propertiesb. Category Documentationc. VI description
This VI measures temperature using the temperature sensor on the DAQ Signal Accessory.
d. OK4.
Context Help VI
a. Description and Tip
b. Description Displays the temperature measurement.
c. Tip temperature
d. OKe. Description
and Tipf. Description
Determines the scale (Fahrenheit or Celsius) to use for the temperature measurement.
g. Tip scale – C or Fh. OK
5. Help»Show Context Help Context Help6. VI Context Help
2
LabVIEW 2-16 ni.com
7. Window»Show Block Diagram
8. DAQ Assistant Express VI Functions»InputExpress VI DAQ
Assistanta. Analog Input»Voltageb. Dev1»ai0 Dev2»ai0 Finish
c. 100Settings Custom Scaling»Create NewLinear Temperature. 100
OKd. Task Timing Acquire 1 Sample OK
DAQ (Demo) Read Voltage VI C:\Exercises\LabVIEW Basics I
9. Convert from Dynamic Data Express VI Functions»Signal Manipulation VI
Resulting data typeSingle scalar
10. Convert C to F VI Functions»All Functions»Select a VI C:\Exercises\LabVIEW Basics I\Convert C to F.vi VI
11. Select Functions»Arithmetic & Comparison»Express Comparison Temp Scale
(FALSE) (TRUE)PositioningWiring
2
© National Instruments Corporation 2-17 LabVIEW
Visible Items»Terminals
12. Window»Show Front Panel
13. Run Continuously VI14.15. Run Continuously VI VI
VI
16. Thermometer VI subVI
a.Edit Icon Icon Editor
b. Icon Editor Select
c. <Delete>d. Rectangle
e. Pencilf. Foreground Fill
Pencil Shift
2
LabVIEW 2-18 ni.com
g. TextSmall Fonts
h. Temp
i. B & W Copy from 256 ColorsLabVIEW
j. OK
17. Show Connector
a.b. Temp Scalec.d. Temperaturee.
18. Thermometer.vi VI C:\Exercises\LabVIEW Basics I VI
19. VI
2
© National Instruments Corporation 2-19 LabVIEW
VI subVI VIsubVI Positioning
Edit»Create SubVI subVILabVIEW subVI
subVI subVI
subVI subVIsubVI
28 subVI 28
2
LabVIEW 2-20 ni.com
�• VI VI subVI subVI
�• VIVI subVI
�• terminal VI of that VI. Define connections by assigning a front panel
�• Icon Editor
�• Icon Editor Text
�• requiredrecommended optional
subVIThis Connection Is
�• File»VI Properties CategoryDocumentation VI VI
Context Help
�• Add descriptions and tip strips to Description and Tip
Context Help
�• PositioningEdit»Create SubVI VI subVI
2
© National Instruments Corporation 2-21 LabVIEW
2
LabVIEW 2-22 ni.com
© National Instruments Corporation 3-1 LabVIEW
loopcase
LabVIEWWhile Loop For Loop Case Stacked Sequence Flat
Sequence Event Formula Node
While Loop For Loopshift register
Feedback Node
A. While LoopB. For LoopC.
3
LabVIEW 3-2 ni.com
While Loop While Loop Do Loop Repeat-Until Loop
LabVIEW While Loop While LoopWhile Loop
While Loop Functions»Execution ControlWhile Loop
While Loop
While Loop While Loop
While Loop
While Loop conditional terminal
Stop If TrueStop If True While Loop
TRUE
iteration iteration
0
While Loop subVI10.00 Enable
And FALSE
1 LabVIEW While Loop 2 3
Code
End
Repeat (code);
Until Condition met;
End;Code
1 2 3
Conditionmet?
Yes
No
3
© National Instruments Corporation 3-3 LabVIEW
While LoopContinue if True
OperatingContinue if True While LoopFALSE
While Loop subVI 10.00 Enable
3
LabVIEW 3-4 ni.com
tunnel While LoopWhile Loop
iterationWhile Loop Iteration Number
iteration Iteration Number
3
© National Instruments Corporation 3-5 LabVIEW
VIiteration
1. VI
a. Controls»Numeric Controls Number to Match
b. Controls»Numeric Indicators Current Number
c. # of iterations
0 10,000 150
2. Number to MatchData Range Numeric Properties Data Range
a. Use Default Rangeb. Default Value 50
3
LabVIEW 3-6 ni.com
c. Minimum 0 Out of Range ActionCoerce
d. Maximum 10,000 Out of Range ActionCoerce
e. Increment 1 Out of Range ActionCoerce to Nearest
LabVIEWSI
0
3. Format and PrecisionNumeric Properties Current
Number Format & Precision Numeric Properties Format & Precision
a. Floating Point Significant digits Digits of precision
b. Digits of precision 0 OK4. 3 Current Number # of iterations
5.
a. Random Number (0-1) Functions»Arithmetic & Comparison»Express Numeric
0 1b. Multiply Functions»Arithmetic &
Comparison»Express Numeric10,000 0 10,000
3
© National Instruments Corporation 3-7 LabVIEW
c. Multiply yCreate»Constant 10000 <Enter>
d. Round To Nearest Functions»Arithmetic & Comparison»Express Numeric
e. Not Equal? Functions»Arithmetic & Comparison»Express Comparison
Number to Match
f. While Loop Functions»Execution Control
Continue if Trueg. iteration While Loop While Loop
Incrementiteration
h. Increment Functions»Arithmetic & Comparison»Express Numeric While Loop
# of iterationsLabVIEW iteration # of iterations
6. Auto Match.vi VI C:\Exercises\LabVIEW Basics I
7. Number to Match8. VI Number to Match VI
Current Number # of iterations
9. VIHighlight Execution
VI10. Number to Match 0 10,000
1
11. VI LabVIEW
12. VI
3
LabVIEW 3-8 ni.com
3
© National Instruments Corporation 3-9 LabVIEW
For Loop LabVIEWFor Loop For Loop For Loop
For Loop Functions»All Functions»StructuresWhile Loop While Loop
Replace with For Loop While LoopFor Loop
iteration iteration
0
For Loop While Loop For LoopWhile Loop
For Loop 60
1 LabVIEW For Loop 2 3
N=100
i=0i=i+1
Code
End
i=N?
N=100;
i=0;
Until i=N:
Repeat (code; i=i+1);
End;
Code
1 2 3
No
Yes
3
LabVIEW 3-10 ni.com
Wait Until Next ms Multiple
Wait Until Next ms Multiple
. . .0 100
VI Begins:Pre-loop Code
1st LoopIterationBegins
1st LoopIteration
Ends
2 ms2 ms
2nd Loop Iteration Begins
96 ms
. . . 200
2nd LoopIteration
Ends
2 ms 98 ms
3rd Loop Iteration Begins
. . . Internal Computer Timer
Pre-loopCode Loop Code
3
© National Instruments Corporation 3-11 LabVIEW
Wait (ms)
Time Delay Express VI Functions»Execution ControlWait (ms) (error cluster)
LabVIEW8 16 32
LabVIEW coercion dot
For Loop 32LabVIEW
32 For Loop
. . . 0 100
VI Begins:Pre-loop Code
1st Loop Iteration Begins
1st Loop Iteration
Ends
2 ms2 ms
2nd Loop Iteration Begins
100 ms
104
InternalComputer Timer
Pre-loopCode Loop Code
3
LabVIEW 3-12 ni.com
LabVIEWLabVIEW
LabVIEW
32 (I32)(DBL) Divide 32
Representation
LabVIEWLabVIEW x.5
LabVIEW 2.5 2 3.5 4
LabVIEW
Coercion Dot
3
© National Instruments Corporation 3-13 LabVIEW
VI Thermometer VI
1. VI
a. Controls»Numeric Indicators
b. Controls»Numeric Indicators Seconds Elapsed
Representation»I32
2.
a. For Loop Functions»All Functions»Structures For Loop Loop Count
Create Constant60 For Loop 60
b. Thermometer VI Select Functions»All Functions»Select a VI C:\Exercises\LabVIEW Basics I\Thermometer.vi VI VI
3
LabVIEW 3-14 ni.com
DAQ Temp ScaleCreate»Constant Fahrenheit
FALSE Celsius TRUE
Channel 0 DAQ(Demo) Thermometer VI
c. Wait Until Next ms MultipleFunctions»All Functions»Time & Dialog
Create»Constant1000
d. Increment Functions»Arithmetic & Comparison»Express Numeric iteration
3. Timed Temperature.vi VI C:\Exercises\LabVIEW Basics I
4. VI DAQ
5. VI
6. VI While Loop
7. General While Loop.vi VI C:\Exercises\LabVIEW Basics I
8. General While Loop VI While Loop
9. File»Save As Combo While-For Loop.vi VIC:\Exercises\LabVIEW Basics I
3
© National Instruments Corporation 3-15 LabVIEW
VI
shift register Feedback Node
For Loop While Loop
static variable
LabVIEW
Add Shift Register
VIVI
VI
3
LabVIEW 3-16 ni.com
Add Element
subVI subVI VIFor
Loop While Loop
Structures For LoopWhile Loop tunnel
VI3-3
3
© National Instruments Corporation 3-17 LabVIEW
1. C:\Exercises\LabVIEW Basics I Feedback VI
2.Tools Functions
For Loop 1 1
Wait Until Next ms TimerHighlight Execution wait
3
LabVIEW 3-18 ni.com
3. VI
Multiply
Multiply4. Highlight Execution
VIVI
5.
a. <Delete>b. For Loop Add Shift Registerc. 1
d. Shift RegisterFeedback Node
6. VI
7. VI
3
© National Instruments Corporation 3-19 LabVIEW
8. For Loop
a.Add Element
b. 1
c.Create»Indicator
9. VI10. VI
3
LabVIEW 3-20 ni.com
�•
�• While Loop conditional terminal While Loop
TRUE�• For Loop�•
�• Wait Until Next ms Multiple
�• Wait (ms)�• LabVIEW
Coercion dot�• For Loop While Loop
�•Add Shift Register
�•Add Element
�•
�•
3
© National Instruments Corporation 3-21 LabVIEW
3
LabVIEW 3-22 ni.com
© National Instruments Corporation 4-1 LabVIEW
A.
B. auto-indexing
C. Array
D. polymorphism
4
LabVIEW 4-2 ni.com
dimension
231
0 n �– 1 n
n = 9 0 82
Controls»All Controls»Array & Cluster
XY
1 2
2
1
4
© National Instruments Corporation 4-3 LabVIEW
grid
6 4 = 24
Add Dimension Positioning
Functions»All Functions»Array
subVI
Column Index
0123
Row Index
0 1 2 3 4 5
4
LabVIEW 4-4 ni.com
For Loop While Loop input tunnel
Disable Indexing
For LoopFor Loop
LabVIEW While Loop
Enable Indexing
For Loop For LoopFor Loop For Loop For Loop
4
© National Instruments Corporation 4-5 LabVIEW
For Loop LabVIEWcount terminal
For LoopFor Loop
10For Loop 15
4
LabVIEW 4-6 ni.com
Functions»All Functions»Array
�• Array Size�— nsize n
Array Size size 3
�• Initialize Array�— n element
element 4 dimension size 3 dimension size Initialize Array
�• Array Subset�— index length
index 2 length 3 Array Subset
�• Build Array�— n
Build Array
Concatenate Inputs
�• Index Array�— n index element or sub-array
index 0 Index Array 2
Index Array
7 4 2
4 4 4
2 4 4
7 4 2
4 4 4
7 4 2 4 4 4
4
© National Instruments Corporation 4-7 LabVIEW
index index
index
index (row) 0 Index Array
7 4 2
4 4 4
7 4 2
4
LabVIEW 4-8 ni.com
Functions»Express Numeric Functions»All Functions»Numeric
Add2
Add
Add
Add
1 3 2
3 5 4
4 8 6
3 1 2 3
7 9 8
4
© National Instruments Corporation 4-9 LabVIEW
VI
1. VI
a. Controls»All Controls»Array & Cluster
b. Random Array
c. Controls»Numeric Indicators
d. Positioning 10
e. Random Array <Ctrl>
f. Final Array Subset Array
g. Controls»Numeric ControlsScaling Factor Start Subset
# of Elements
h. Start Subset # of ElementsRepresentation»I32
i.
4
LabVIEW 4-10 ni.com
2.
a. Random Number (0-1) Functions»Arithmetic & Comparison»Express Numeric
0 1
b. For Loop Functions»All Functions»Structures
10
c. Multiply Functions»Arithmetic & Comparison»Express Numeric
Random Array Scaling Factor Final Array
d. Array Subset Functions»All Functions»ArrayStart Subset # of Elements
3. Array Exercise.vi VI C:\Exercises\LabVIEW Basics I
4. VI
For Loop 10Random Array
VI Random Array Scaling FactorFinal Array VI Final Array Start
Subset # of Elements Subset Array
5. VI
4
© National Instruments Corporation 4-11 LabVIEW
�•
�• 0 n �– 1 n
�•
�• Controls»Array & Cluster
�• For Loop While Loopauto-indexing
�• Functions»All Functions»Array Array
�• LabVIEW For LoopWhile Loop
�•
4
LabVIEW 4-12 ni.com
4-2 VI 100array[0] array[99] array[1]
array[98]
Reverse 1D Array Functions»All Functions»Array
Reverse Random Array.vi VIC:\Exercises\LabVIEW Basics I
4-3 VI 2-2 Thermometer VITemperature Array
Initialize Array10
Final ArrayMid Value Temperature Array Initialized Array
Final Array Mid Value.
Find Mid Value.vi VI C:\Exercises\LabVIEW Basics I
4-4 VI
Extract 2D Array.vi VIC:\Exercises\LabVIEW Basics I
4-5 VI 1 6
Die Roller.vi VIC:\Exercises\LabVIEW Basics I
4-6 VI0 11 23 10 5 7 11 23 50 77
Decimate 1D Array Functions»All Functions»Array
Array Pair Multiplier.vi VIC:\Exercises\LabVIEW Basics I
Challenge
Challenge
4
© National Instruments Corporation 4-13 LabVIEW
4
LabVIEW 4-14 ni.com
© National Instruments Corporation 5-1 LabVIEW
A. clusterB.C. error cluster
5
LabVIEW 5-2 ni.com
subVI28 28
Unbundle By Name
Controls»All Controls»Array & Cluster
Cluster
Create»Constant
0 1
5
© National Instruments Corporation 5-3 LabVIEW
Bundle Unbundle
Reorder Controls In Cluster
Click to set to
ConfirmCancel
0 1
0 1
01
12
34
5
5 4
1
3
2
5
LabVIEW 5-4 ni.com
Functions»All Functions»Cluster ClusterBundle Bundle by Name
Unbundle Unbundle by Name
Cluster Palette Bundle Bundle by Name UnbundleUnbundle by Name Bundle Unbundle
Bundle by Name Unbundle by NamePositioning Bundle by Name
Unbundle by Name
BundlePositioning
elementAdd Input cluster
cluster element
BundleCommand
5
© National Instruments Corporation 5-5 LabVIEW
Bundle by NameBundle by Name Bundle
output cluster
OperatingSelect Item
Bundle by Name CommandFunction
Bundle by NameBundle by
Name
Unbundle
Unbundle by Name
OperatingSelect Item
Unbundle
0Unbundle by Name
5
LabVIEW 5-6 ni.com
5
© National Instruments Corporation 5-7 LabVIEW
1. VI
a. Controls»Buttons & Switches Controls»Numeric Indicators LED Controls»LEDs
b. Controls»All Controls»Array & Cluster
c. Controls»Numeric Controls Controls»Buttons & Switches horizontal fill slide Controls»Numeric Controls
d. Modified ClusterModified ClusterChange to Indicator
e. Modified Cluster Small Cluster
Slide value
2. Cluster Small Cluster Modified ClusterCluster
a.Reorder Controls in Cluster
5
LabVIEW 5-8 ni.com
b.
3.
a. Unbundle Functions»All Functions»ClusterPositioning
b. Bundle Functions»All Functions»Cluster Small Cluster
c. P Unbundle by Name Functions»All Functions»Cluster Cluster
Select Item
d. Increment Functions»All Functions»Numeric Numeric
5
© National Instruments Corporation 5-9 LabVIEW
e. Not Functions»Arithmetic & Comparison»Express Boolean Unbundle by Name Boolean
f. Bundle by Name Functions»All Functions»Cluster Cluster Numeric
Boolean Modified Cluster
Select Itemg.
4. Cluster Exercise.vi VI C:\Exercises\LabVIEW Basics I
5. VI6. Cluster VI Cluster
Modified Cluster Small Cluster
7. Modified Cluster VI
8. VI
5
LabVIEW 5-10 ni.com
VI
VI
1. Cluster Scaling VI C:\Exercises\LabVIEW Basics I
2.
3. Raw Data
4. VI5. VI6. VI7. VI
5
© National Instruments Corporation 5-11 LabVIEW
VIVI
I/OI/O VI
I/O
VI�•�•�• VI
VI
LabVIEW VIsubVI
I/O VIVI LabVIEW VI
VIVI
LabVIEW VIVI VIVI
VIVI
VI LabVIEWLabVIEW LabVIEW
Simple Error Handler VI Simple Error Handler VIFunctions»All Functions»Time & Dialogerror in
5
LabVIEW 5-12 ni.com
Functions»All Functions»Array & Cluster
�• status TRUEVI
Stop Quit LabVIEWSelectTRUE
�• code 32status FALSE
�• source
subVI
Explain Error Explain Error Explain ErrorVI
Explain Warning
Help»Explain Error Explain Error
While Loop conditional terminal While Loop
status TRUE FALSEWhile Loop
5
© National Instruments Corporation 5-13 LabVIEW
Stop if TrueContinue if True Stop on Error Continue while Error
5
LabVIEW 5-14 ni.com
�•
�• 28
�• Controls»All Controls»Array & Cluster
�• Functions»All Functions»Cluster Cluster
�•�• status code source
�• subVI
5
© National Instruments Corporation 5-15 LabVIEW
5
LabVIEW 5-16 ni.com
© National Instruments Corporation 6-1 LabVIEW
waveform chart waveform graph XY XY graph intensity plot
A.B. XYC. intensity plot
6
LabVIEW 6-2 ni.com
Controls»Graph Indicators
Raw Data Running Avg
Advanced»Update ModeStrip Chart Scope Chart Sweep Chart Strip
Chart
strip chartscope chart
sweep chart
retracing display
12 Y
3 X4
5 Graph6
1
2
4
3
5
6
6
© National Instruments Corporation 6-3 LabVIEW
Cluster BundleBundle
VI
BundlePositioning Bundle
6
LabVIEW 6-4 ni.com
VI
1. VI
a. Controls»Buttons & Switches Power
b. Controls»Graph Indicators Temperature History
c. Plot 0 LabelingPlot 0 Temp
d. Labeling y10.0 90 x
e. y 10.0 70
f. y Temp (Deg F) x Time (sec)
2. Window»Show Block Diagram3. While Loop
6
© National Instruments Corporation 6-5 LabVIEW
4. Continue if True5.
a. Thermometer VI Functions» All Functions»Select a VI C:\Exercises\LabVIEW Basics I\Thermometer.vi subVI
DAQ (Demo) Thermometer VI
b. P Wait Until Next ms MultipleFunctions»All Functions»Time & Dialog
c. Wait Until Next ms Multiple millisecond multipleCreate»Constant
500 <Enter> 500
Functions»Arithmetic & Comparison»Express Boolean TRUE Thermometer VI
Temp Scale20 32 70 90
6. Temperature Monitor.vi VI C:\Exercises\LabVIEW Basics I
7. Window»Show Front Panel8. Operating ON
9. VIWhile Loop (TRUE)
(TRUE) Thermometer VI
6
LabVIEW 6-6 ni.com
10. FALSE
11. x ya. Properties
Chart Propertiesb. Format and Precision Deg F
(Y-axis) Digits of precision 1c. Plots y
d. Scales Time (sec) (X-axis)Multiplier
0.50 Wait 500
6
© National Instruments Corporation 6-7 LabVIEW
e. Scales Deg F (Y-axis)
f. OK
6
LabVIEW 6-8 ni.com
12. Data Operations»Clear Chart
VI Clear Chart
13. VI Run
VI
a. VIb. Operating ON
c. Data Operations»Make Current Value Default ON
d. Mechanical Action»Latch When Pressed
VI
While LoopVI
14. VI15. Operating
OFF ON16. VI 6-2 VI
6
© National Instruments Corporation 6-9 LabVIEW
Temperature Monitor VI
1. 6-1 Temperature Monitor VI2. File»Save As VI Temperature Running
Average.vi C:\Exercises\LabVIEW Basics I
3. Display .4. While Loop
Add Shift Register5. Add
Element6.
a. Thermometer VI <Ctrl> While Loop subVIThermometer VI
b. Compound Arithmetic Functions»Arithmetic & Comparison»Express Numeric
Positioning
6
LabVIEW 6-10 ni.com
c. Divide Functions»Arithmetic & Comparison»Express Numeric
d. Divide y Create»Constant3 <Enter>
7. VI
8. VIWhile Loop Thermometer VI
VIVI
VIVI
9.
a. Bundle Functions»All Functions»Cluster
10. VI VI
11. VI VI
12. VI
6
© National Instruments Corporation 6-11 LabVIEW
13. ya. Labeling y 70.0
75.0 <Enter>b. Labeling y
80.0 <Enter> y
75.0 77.5 y2.5 77.5 80.0 y 5.0
75.0 80.0 85.0
6
LabVIEW 6-12 ni.com
14. VisibleItems»Scale Legend
15.a. Lock Autoscale
Autoscale LED y
b. Scale Formatformat precision mapping mode
scale visibility grid options16.
a. Positioningb. Labeling Temp Running Avg Plot 1
Current Temp Positioning
c.
17. Visible Items»Graph Palette graph graph
1 X2 Y
34
56
43 65
1
2
6
© National Instruments Corporation 6-13 LabVIEW
graph ZoomPanning
Cursor Movement18. VI VI graph
19. Operating Power VI20. VI
12 Zoom
3 Panning4
1 32
4
6
LabVIEW 6-14 ni.com
VI
Controls»Graph Indicators XYy = f(x) x
XY
XY
xx = 0 x
x y NI Example Finder Waveform Graph VI
123
45 Graph6
789 X
10Y11
10
11
9
1
3
4
8
5
7
6
2
6
© National Instruments Corporation 6-15 LabVIEW
xx = 0
Transpose ArrayNI Example Finder Waveform Graph VI (Y)
Multi Plot 1
x x yy x
x x = 0 NI Example FinderWaveform Graph VI (Xo, dX, Y) Multi Plot 3
x xy
Bundle Build ArrayBuild Cluster Array
NI Example Finder Waveform Graph VI (Xo, dX, Y) Multi Plot 2
XY x y XYx y
NI Example Finder XY Graph VIXY
XYx y XY
xy NI Example Finder XY Graph VIXY
6
LabVIEW 6-16 ni.com
VIVI
1. VI
a. Controls»All Controls»Array & Cluster
b. Waveform Arrayc. Controls»Numeric
Indicatorsd. Controls»Graph
Indicators
2.
6
© National Instruments Corporation 6-17 LabVIEW
a. Thermometer VI Functions»All Functions»Select a VI C:\Exercises\LabVIEW Basics I\Thermometer.vi subVI For Loop
DAQ (Demo) Thermometer VI
b. For Loop Functions»All Functions»Structures For Loop
100
c.
Context HelpBuild Array Bundle
yXY x y
Context HelpHelp»Find Examples NI Example Finder Fundamentals
Graphs and Charts Waveform Graph VI
3. Graph Waveform Array.vi VI C:\Exercises\LabVIEW Basics I
6
LabVIEW 6-18 ni.com
4. VI VI
5. Waveform Array100
6. Positioning Waveform Array
x xx x Bundle x x
7.
a. Bundle Functions»All Functions»Cluster
x (20) x (0.5) y
b. x x
c. x Dx Labeling DText Settings Symbol D
( )d.
8. VI
6
© National Instruments Corporation 6-19 LabVIEW
9. VIx 20 x 0.5
10020 50
x Dx Bundle Waveform Graph Properties
10. VI
11. Visible Items»Graph Palette graph Zoom
12. Visible Items»Scale Legend
13.
a. Sine Functions»Arithmetic & Comparison»Express Numeric»Express Trigonometric
b. Build Array Functions»All Functions»Array
c. pi Functions»Arithmetic & Comparison»Express Numeric»Express Numeric Constants
d.14. VI15. VI
6
LabVIEW 6-20 ni.com
16. .17. Waveform Array
Custom Probes»Controls»Graph Indicatorsgraph probe
18. VI
19. Probe20.
a. graph Zoom Zoom
b. Zoom by X Rectangle
c.
d. Zoom by Y Rectangle Zoom by Selected Area
e. Undo Zoomx y
21. Panningx y
22. Cursor Movement
23. VI
6
© National Instruments Corporation 6-21 LabVIEW
VI 0.2510 VI
VIVI
1. VI
a. x
b.c. Temperature Chart
d. Temperature Graph
e. Temperature Chart X Scale»Formatting X 0.25 Digits of Precision
2 Temperature Graph
f. Positioningg. Plot 0 Temp Plot 1 Fitted
h. Tempi. Mean Max Min
2.
6
LabVIEW 6-22 ni.com
a. Thermometer VI Functions»All Functions»Select a VI C:\Exercises\LabVIEW Basics I\Thermometer.vi subVI
b. Wait Until Next ms MultipleFunctions»All Functions»Time & DialogFor Loop 0.25 250
c. Array Max & Min Functions»All Functions»Array
d. Mean VI Functions»All Functions»Analyze»Mathematics»Probability and StatisticssubVI
e. Array Max & Min Mean VICreate»Indicator Max Min
Meanf. General Polynomial Fit VI Functions»All
Functions»Analyze»Mathematics»Curve FittingsubVI
g. Bundle Functions»All Functions»Cluster
<Ctrl> x (0)x (0.25) y x 0.25
VI 0.25h. Build Array Functions»All
Functions»Array
i.
6
© National Instruments Corporation 6-23 LabVIEW
3. Temperature Analysis.vi VI C:\Exercises\LabVIEW Basics I
4. VI
5. VI6.
a. TempCommon Plots»Scatter Plot
b. FittedBar Plots
7. VI
6
LabVIEW 6-24 ni.com
VI x y
1. VI
a. XY Controls»Graph Indicatorsb. XY Circle Graphc. Plot 0 Circle
d.Point Style
e.
2.
6
© National Instruments Corporation 6-25 LabVIEW
a. Sine & Cosine Functions»Arithmetic & Comparison»Express Numeric»Express Trigonometric
b. Bundle Functions»All Functions»Cluster
c. Pi Multiplied by 2 Functions»Arithmetic & Comparison»Express Numeric»Express Numeric Constants
3. Graph Circle.vi VI C:\Exercises\LabVIEW Basics I
4. VI5. VI
6
LabVIEW 6-26 ni.com
intensity graph
256
4 3
Visible Items
6
© National Instruments Corporation 6-27 LabVIEW
Operating PositioningMarker Color
Add Marker Operating
Labeling
1 Y2 X
34
5 Graph6 Z
5
1
2
3 4
6
6
LabVIEW 6-28 ni.com
VIVI
1. Intensity Graph Example VIC:\Exercises\LabVIEW Basics I VI Property Node
Color Array
2. Plot User Data User Data0.0 10.0 VI
6
© National Instruments Corporation 6-29 LabVIEW
3. VI
6
LabVIEW 6-30 ni.com
�•�•
�– strip chart�– scope chart
�– sweep chart EKG
�• XY�•
�• XYBuild Array Functions»All Functions»ArrayBundle Functions»All Functions»Cluster
�•
�• Context Help
6
© National Instruments Corporation 6-31 LabVIEW
6-7 VI
�• For Loop (n = 200) While Loop�•
�• Random Number (0-1) Functions»Arithmetic & Comparison»Express Numeric
�• Bundle Functions»All Functions»Cluster
Random Average.vi VI C:\Exercises\LabVIEW Basics I
6-8 VI
VI LED
Temperature Limit.vi VIC:\Exercises\LabVIEW Basics I
6-9 6-8 VI
Max & Min Functions»All Functions»Comparison
Select File»Save As Temp Limit (max-min).viVI C:\Exercises\LabVIEW Basics I
6
LabVIEW 6-32 ni.com
© National Instruments Corporation 7-1 LabVIEW
VI Select CaseFormula Node
A. SelectB. CaseC. Formula Node
7
LabVIEW 7-2 ni.com
VIa
b c d
if-else case switchLabVIEW
Select
Select Functions»Express Comparison s
tf
2-2 Thermometer VI Select
SelectCase
7
© National Instruments Corporation 7-3 LabVIEW
Case
Case caseif...then...else
Case case selector identifier
Case
TRUE FALSE231 �– 1
Case
1 2 3 4 Case
Case
Thermometer VI CaseSelect Case True
7
LabVIEW 7-4 ni.com
Labeling
VI
LabVIEW
Case
Create»Constant Create»Control
Use Default If Unwired
7
© National Instruments Corporation 7-5 LabVIEW
Case
Case
VIVI
Case
Integer Controls»Text Controls
0 (add) VI 1 (subtract) VI0 (add) 1 (subtract)
VI
7
LabVIEW 7-6 ni.com
Case
String add VI String ubtract VI
Case
enumerated control
CaseCase
Enum add VI Enumsubtract VI
7
© National Instruments Corporation 7-7 LabVIEW
Case
CaseError No Error Case
Error No Error Case
Case status
7
LabVIEW 7-8 ni.com
VIVI VI
1. VI
2.
a. Case structure Functions»Execution Control FALSE
b. Greater or Equal to 0? Functions»Arithmetic & Comparison»Express ComparisonNumeric 0
c. PropertiesFormat and Precision Digits of precision
1 Floating point OK Case
d. One Button Dialog Functions»All Functions»Time & Dialog
Error...Negative Numbere. One Button Dialog message
Create»ConstantError...Negative Number Enter
f.
7
© National Instruments Corporation 7-9 LabVIEW
3. Case TRUESquare Root Functions»Arithmetic &
Comparison»Express Numeric Numeric
4. Square Root.vi VI C:\Exercises\LabVIEW Basics I
5. VI
Numeric VI TRUE NumericNumeric VI FALSE
–99999 Error...Negative Number
6. VI
7
LabVIEW 7-10 ni.com
VI
1. 6-2 Temperature Running Average VI2.
a. horizontal smooth box Controls»All Controls»Decorations
Analysisb. Power ANALYSIS
Mechanical Action»Switch When Pressed
c. Controls»Numeric Controls High Limit
d. LED Controls»LEDsWarning
e. Controls»Numeric Indicators High Value
f. Visible Items»Digital Display
3. File»Save As Temperature Control.vi VIC:\Exercises\LabVIEW Basics I
7
© National Instruments Corporation 7-11 LabVIEW
4. While Loop
a. Case Functions»Execution ControlAnalysis
TRUEb. Greater? Functions»Arithmetic &
Comparison»Express Comparison High Limit
c. Select Functions»Arithmetic & Comparison»Express Comparison
d. TRUEe. FALSE
5. Case FALSE
a. Warning Create»Constant operatingFALSE
b. High Value Create»Constant -99999
6. VI VI
7
LabVIEW 7-12 ni.com
7. High Limit 80 VIANALYSIS VI High
Value –99999 ANALYSISHigh Value VI Warning LED High
Value8. VI
7
© National Instruments Corporation 7-13 LabVIEW
LabVIEWMATLAB
Add Input Add Output
(;)
if-then
LabVIEW Help
Formula Express VI Functions»Arithmetic & ComparisonExpress VI
LabVIEW HelpFormula Express VI
7
LabVIEW 7-14 ni.com
VI
1. VI
1.
a. Functions»All Functions»Structures
b. Add Inputx x
c. Add Outputy a y a
a
7
© National Instruments Corporation 7-15 LabVIEW
d. **LabVIEW Helpa = tanh(x) + cos(x);
y = a**3 + a;
e.2. Formula Node Exercise.vi VI
C:\Exercises\LabVIEW Basics I
3. VI y = f(x)3 + f(x)f(x) = tanh(x) + cos(x)
VI 15.0VI
4. VI
7
LabVIEW 7-16 ni.com
�• Select�• Case
�• TRUE FALSE
231 �– 1�• Case
�• Case subVIsubVI No Error
subVI�•
(;)
7
© National Instruments Corporation 7-17 LabVIEW
7-4 VIy1 = x3 + x2 + 5
y2 = mx + b
(;)Equations.vi VI
C:\Exercises\LabVIEW Basics I
7-5 VIVI
Calculator.vi VIC:\Exercises\LabVIEW Basics I
7-6 7-1 Square Root VI VI
Select File»Save As to Square Root 2.vi VIC:\Exercises\LabVIEW Basics I
7-7 Threshold Input ArrayOutput Array VI Output Array
Input Array ThresholdArray Over Threshold.vi VI
C:\Exercises\LabVIEW Basics IVI 0 1Array Over Threshold VI
0.5
Using Array Over Threshold.vi VIC:\Exercises\LabVIEW Basics I
Challenge
7
LabVIEW 7-18 ni.com
© National Instruments Corporation 8-1 LabVIEW
ASCIII/O
A.B.C. I/OD. I/O VIE. I/O VIF.
8
LabVIEW 8-2 ni.com
ASCII
�•�•
�• ASCII
�•
Controls»Text ControlsControls»Text IndicatorsOperating Labeling
Positioning
Visible Items»Scrollbar
Controls»All Controls»List & TableExpress Table VI Controls»Text Indicators
Normal Display
There are four display types.
\ is a backslash.
�‘\�’ Codes Display
There\sare\sfour\sdisplay\stypes.\n\\\sis\sa\sbackslash.
Password Display
(*) *****************************
*****************
Hex Display ASCII 5468 6572 6520 6172 6520 666F 7572 2064 6973 706C 6179 2074 7970 6573 2E0A 5C20 6973 2061 2062 6163 6B73 6C61 7368 2E
8
© National Instruments Corporation 8-3 LabVIEW
Operating Labeling
1234
567
7
6
5
4
3
21
8
LabVIEW 8-4 ni.com
Functions»All Functions»String
�• String Length�— length stringString Length
length 19
The quick brown fox
�• Concatenate Strings�—
Add Input
Concatenate StringsThe quick brown fox jumped over the lazy dog.
�• String Subset�— offset stringsubstring length string
offset 0offset 4 length 5 String Subsetsubstring
quick
�• Match Pattern�— string offset regular expression string
match substring offset past match–1 regular expression :
VOLTS DC: +1.22863E+1;
Match Pattern before substring VOLTS DC match substring : after substring +1.22863E+1; offset past match 9
Build Text Express VI Build Text Express VI Functions»Output
Express VI Express VI
Build Text Express VI Configure Build Text Express VI
voltage 4
jumped over the lazy dog.
8
© National Instruments Corporation 8-5 LabVIEW
Voltage is Voltage is
probeBuild Text Express VI Beginning Text
voltage
Scan From String 0�–9 +– e E (.) input string format string
8
LabVIEW 8-6 ni.com
format string input stringoutput
format string %f initial search location 8 VOLTS DC+1.28E+2 input string 128
format string % fEdit Scan
String format string Edit Scan String%4f
LabVIEW Help
8
© National Instruments Corporation 8-7 LabVIEW
VI
VI
1. VI
�• String 2 �‘\�’ Codes Display
�• String Length Offset Past Match 32(I32)
�• Edit»Make Current Values Default
8
LabVIEW 8-8 ni.com
2.
a. Build Text Express VI Functions»Output Number Build Text
�– Text with Variables in Percents%Header% %Number% %Trailer%
Configure Variables�– Variable Number
�– Variable Properties NumberFormat Format fractional number Use specified precision Precision 4Header Trailer
�– OKb. String Length Functions»All
Functions»String Resultc. Match Pattern Functions»All
Functions»String String 2 (:)regular expression
Create»Constant (:)<Enter> Enter
<Enter>
d. Scan From String Functions»All Functions»String
e.
8
© National Instruments Corporation 8-9 LabVIEW
3.VI subVI
4. Create String.vi VI C:\Exercises\LabVIEW Basics I VI
5. VIVI Header Number Trailer Combined String
VI String 2Number Out Offset Past Match
6. VI
8
LabVIEW 8-10 ni.com
I/O Functions»All Functions»File I/O I/O VI I/O
�•�•�•�•�•�•
File I/O high-level low-leveladvanced express
File I/O VI Functions»All Functions»File I/OI/O I/O VIFile I/O VI
VIVI
VIVI
VIVI
File I/O VI Functions»All Functions»File I/OAdvanced File I/O Functions»All
Functions»File I/O»Advanced File FunctionsI/O
VI I/O LabVIEW Basics II: Development Course Manual Advanced
File I/O
Express VI File I/O Read LabVIEW Measurement File Express VI Write LabVIEW Measurement File Express VILabVIEW (.lvm)
8
© National Instruments Corporation 8-11 LabVIEW
Express VI.lvm
File I/O Express VI
LabVIEW Data LabVIEW.lvm .txt LabVIEW LabVIEW Data
LabVIEWWrite LabVIEW Measurement File Express VI
.lvm Read LabVIEW Measurement File Express VIDefault Data Directory Default Data Directory
LabVIEW Data
Tools»Options Paths
VI VI LabVIEW
I/O1.
LabVIEW
2.3.
8
LabVIEW 8-12 ni.com
I/O VI I/OI/O VI I/O
VI
File I/O VI File I/O I/O
�•�•�•�• 16
I/O VI�• Write to Spreadsheet File�—
byte stream file VI
VI�• Read From Spreadsheet File�—
VIVI
�• Write Characters to File�— character stringbyte stream file
VI�• Read Characters From File�— start of
read offset VI
�• Read Lines From File�—VI
�• Binary File VIs�— VI
8
© National Instruments Corporation 8-13 LabVIEW
VI
1. Spreadsheet Example VI C:\Exercises\LabVIEW Basics I
2. VIVI 128 3
VI
3. Choose file to write wave.txt VIC:\Exercises\LabVIEW Basics I OK
8
LabVIEW 8-14 ni.com
4. VI
Sine Pattern VI Functions»All Functions»Analyze»Signal Processing»Signal Generation 128
Sine Pattern VI 90.0phase
Uniform White Noise VI Functions»All Functions»Analyze»Signal Processing»Signal Generation 128
Build Array Functions»All Functions»Array
Transpose 2D Array Functions»All Functions»Array[i,j] [j,i]
Write To Spreadsheet File VI Functions»All Functions»File I/O
Sine Array �…
Noise Array �…
Cosine Array �…
S N C
�… �… �…
8
© National Instruments Corporation 8-15 LabVIEW
( ) (¶)
Number To Fractional String Functions»All Functions»String»String/Number Conversion
5. VI
Build Array
wave.txt
6. (Windows) NotepadWordPad (Mac OS) SimpleText (UNIX) Text Editor
7. wave.txt
8. LabVIEW
S N C
¶
¶
¶
�… �… �…
¶
8
LabVIEW 8-16 ni.com
I/O VI I/O�• Open/Create/Replace File�—
promptstart path pattern file path VI
�• Read File�— refnum datapos mode pos
offset
�• Write File�— refnumpos mode pos offset
data header
�• Close File�— refnum refnumI/O
I/O VI VIVI VI Time
& Dialog Simple Error Handler VI VIVI error in error out
VI
I/O VI
ASCII LabVIEW Basics II: Development Course Manual LabVIEW
Open/Create/Replace File VIfile path
VI
8
© National Instruments Corporation 8-17 LabVIEW
Open/Create/Replace File VI test1.dat VIrefnum
LabVIEWrefnum
refnum
Open/Create/Replace File VIrefnum Write FileWrite File refnum Close File
Simple Error Handler VI
VI Simple Error Handler VI
Windowsc:\testdata\test1.dat
testdata test1.dat
UNIX/home/testdata/test1.dat /home
testdata test1.dat
Mac OSHard
Disk:testdata:test1.dat Hard Disk testdatatest1.dat
8
LabVIEW 8-18 ni.com
VI8-4
VI
1. VI
a. path indicatorControls»Text Indicators
b. String to WriteVisible Items»Scrollbar
2.
8
© National Instruments Corporation 8-19 LabVIEW
a. 8-1 Create String VI Functions»All Functions»Select a VIC:\Exercises\LabVIEW Basics I\Create String.vi
subVIb. Open/Create/Replace File VI Functions»
All Functions»File I/O VI
promptCreate»Constant Enter Filename VI
Enter Filename
functionCreate»Constant Operatingcreate or replace
c. Write File Functions»All Functions»File I/O
d. Close File Functions»All Functions»File I/O
e. Simple Error Handler VI Functions»All Functions»Time & Dialog
f.3. File Writer.vi VI C:\Exercises\LabVIEW
Basics I
4. VI Enter Filename
5. demofile.txt Save OKVI String to Write Numeric to Write Unit to Write
6. VI
8
LabVIEW 8-20 ni.com
VI 8-3
1. VI Controls»Text ControlsControls»Text Indicators
2.
a. Open/Create/Replace File VI Functions»All Functions»File I/O VI
promptCreate»Constant
Select Filename functionCreate»Constant Operating
openb. Read File Functions»All Functions»
File I/Ocount
c. Close File Functions»All Functions»File I/O
8
© National Instruments Corporation 8-21 LabVIEW
d. Simple Error Handler VI Functions»All Functions»Time & Dialog
e.3. File Reader.vi VI C:\Exercises\LabVIEW
Basics I
4. OperatingBrowse
5. demofile.txt Open OK6. VI String Read from File7. VI
8. VIVI
Match Pattern
8
LabVIEW 8-22 ni.com
Functions»All Functions»String(Windows) (Mac OS)
(UNIX)
Write To Spreadsheet File VI Array To Spreadsheet String
StringArray
Format Into File
Format Into String Build Text Express VIWrite Characters To File VI Write File
Format Into File
Format Into String Write FileFormat Into File
input file
Open/Create/Replace File VI For Loop Format Into File
VI
8
© National Instruments Corporation 8-23 LabVIEW
VI ( ) (¶)
0 0.798141¶1 0.659364¶2 0.581409¶3 0.526433¶4 0.171062¶
Write LabVIEW Measurement File Express VI
Merge Signals
8
LabVIEW 8-24 ni.com
Write LabVIEW Measurement File Express VI
VI .lvmWrite LabVIEW Measurement File Express VI
Write LabVIEW Measurement File Read LabVIEW Measurement File Express VI
8
© National Instruments Corporation 8-25 LabVIEW
VI
1. 7-2 Temperature Control VITemperature Logger.vi VIC:\Exercises\LabVIEW Basics I
2. While LoopI/O
a. Open/Create/Replace File VI Functions»All Functions»File I/O
prompt Create Constant Enter File Name
functionCreate Constant Operating create or replace
b. Get Date/Time String Functions»All Functions»Time & Dialog
8
LabVIEW 8-26 ni.com
want seconds? Create»Constant Operating FALSE
TRUE TRUE
c. Build Text Express VI Functions»Output Express VIConfigure Build Text�– Text with Variables in Percents
%tab%%temp%%end%Build Text
Express VI Beginning Text�– Configure Variables temp Number
Format fractional number tabend
�– OK�– Build Text Express VI View As Icon
d. Tab End of Line Functions»All Functions»String
e. Write File Functions»All Functions»File I/O refnum
f. Close File Functions»All Functions»File I/O
g. Simple Error Handler VI Functions»All Functions»Time & Dialog VI
h.3. VI VI
4. VI Enter File Name5. temp.txt Save OK
VI temp.txt VIPower
VI6. (Windows) Notepad
WordPad (Mac OS) SimpleText (UNIX) Text Editor7. temp.txt
8
© National Instruments Corporation 8-27 LabVIEW
8. LabVIEW9. VI
VI While LoopVI Power
10.
a. Unbundle by Name Functions»All Functions»Cluster status
b. Not function and the And Functions»Arithmetic & Comparison»Express Boolean
Power
11. VI 12. Write File While Loop
refnum Write FileCreate»Constant
13. VI VIVI
VI
8
LabVIEW 8-28 ni.com
14. VI
15. Build Text Express VI Write File Format Into File
16. VI17. VI
8
© National Instruments Corporation 8-29 LabVIEW
1. VIa. VIb.c. LEDd.
e. best-fit curve XY
8-5 Temperature Logger VI eTemperature Analysis VI 6-4
Challenge
8
LabVIEW 8-30 ni.com
2. Temperature Application.vi VIC:\Exercises\LabVIEW Basics I
8
© National Instruments Corporation 8-31 LabVIEW
�• ASCII
�• Show Scrollbar
�• Functions»All Functions»String
�• Build Text Express VI�• Scan From String�• Scan From String Edit
Scan String format string�• I/O VI I/O�• I/O VI I/O�• I/O VI Advanced File I/O
I/O�• Express File I/O VI�•
�• Open/Create/Replace File VIfile path
�•Format Into
File
8
LabVIEW 8-32 ni.com
8-7 VI 3 100
File I/O File I/O VI
Write Characters To File VI Write To Spreadsheet File VI
More Spreadsheets.vi VIC:\Exercises\LabVIEW Basics I
8-8 VI
Search and Replace String
Spreadsheet Converter.vi VIC:\Exercises\LabVIEW Basics I
8-9 8-5 Temperature Logger VI VIVI Temperature Logger VI
temp.dat VIVI
Format Into File Format Into String Write FileWrite File pos mode pos offset
File»Save As Temperature Logger 2.viVI C:\Exercises\LabVIEW Basics I
Challenge
8
© National Instruments Corporation 8-33 LabVIEW
8
LabVIEW 8-34 ni.com
© National Instruments Corporation 9-1 LabVIEW
LabVIEW (DAQ)LabVIEW Measurements Manual LabVIEW
A. DAQB. LabVIEWC.D.E.F. counterG. I/O
9
LabVIEW 9-2 ni.com
LabVIEW VI DAQ
(A/D) (D/A) I/ODAQ
DAQni.com/daq DAQ
DAQ
DAQ signal conditioning accessories DAQ
DAQ
DAQ�• DAQ
PCI PCMCIA DAQ
�• DAQ
DAQDAQ
DAQ
LabVIEW
NI NI-DAQVI
NI-DAQ 7.0 NI-DAQ Traditional NI-DAQNI-DAQmx (API)
�• Traditional NI-DAQ NI-DAQ 6.9.x Traditional NI-DAQNI-DAQ 6.9.x VI
9
© National Instruments Corporation 9-3 LabVIEW
Traditional NI-DAQ NI-DAQmxNI-DAQ 6.9.x
�• NI-DAQmx NI-DAQ VINI-DAQmx
NI-DAQ DAQ AssistantI/O
API NI-DAQ VIDAQ
Traditional NI-DAQ NI-DAQmx National Instruments ni.com/daq
NI-DAQmx API
NI NILabVIEW LabWindows�™/CVI�™ Measurement Studio
ANSI C (DLL) ADE NI
�• LabVIEW LabVIEW DAQ VIVI NI
�• C LabWindows/CVI ANSI CLabWindows/CVI Data Acquisition NI
�• Measurement Studio Microsoft Visual Studio .NETMeasurement Studio Visual C#
Visual Basic .NET Visual C++ .NET
9
LabVIEW 9-4 ni.com
Data Acquisition VI
Windows Configuration ManagerNational Instruments DAQ (PnP)
E Series MIO Windows Configuration ManagerPnP
WindowsData Acquisition Devices DAQ
DAQGeneral Resources
DMANI-DAQ Information
DAQ DriverDAQ
LabVIEW Measurement & Automation Explorer (MAX)DAQ
MAX Device Manager Windows Registry DAQLabVIEW MAX
LabVIEW Tools»Measurement & Automation Explorer MAX
MAX SCXI SCC
1: AT-MIO-64E-3
9
© National Instruments Corporation 9-5 LabVIEW
MAX National Instruments GPIBGPIB
MAX Windows Registry
Windows DAQPCI-6024E
Traditional NI-DAQ (virtual channel)
(scale) Traditional NI-DAQ
NI-DAQmx channel) Traditional NI-DAQ
NI-DAQmx API task
Traditional NI-DAQNI-DAQmx
Traditional NI-DAQ MAXNI-DAQmx MAX
9
LabVIEW 9-6 ni.com
MAX DAQMAX
1. LabVIEW Tools»Measurement & Automation Explorer MAX
National Instruments
2. Devices and Interfaces National Instruments PCI-6024E PCI-GPIB
MAX National InstrumentsData Acquisition VI
DAQ MAX
MAXShow Help/Hide Help DAQ
9
© National Instruments Corporation 9-7 LabVIEW
3. Device Routes
4. Calibration
9
LabVIEW 9-8 ni.com
5. NI-DAQmx Self CalibrateDAQ
Calibration Self Calibration
6. Self-Test
7. Test Panels DAQTest Panels
a. Analog Input DAQChannel Dev1/ai0 DAQ Signal Accessory
Start 0DAQ
Signal Accessory Noise On Stop
b. Analog Output DAQ
Output Mode Sinewave Generation Start Sine Generator LabVIEW 0
c. DAQ Signal Accessory Analog Out Ch0Analog In Ch1
d. Analog Input Dev1/ai1 Start1 LabVIEW
0e. Digital I/O DAQf. 0 3 Logic Level
DAQ LEDLED
g. Close Test Panel MAX8. Counter I/O DAQ
Counter ModeEdge Counting Start Counter Value
Stop9. File»Exit MAX
9
© National Instruments Corporation 9-9 LabVIEW
LabVIEW Data Acquisition VI Data Acquisition DAQmx - Data Acqusition Data Acquisition Traditional NI-DAQ VI DAQmx - Data Acquisition NI-DAQmx VI
DAQmx - Data Acquisition I/O I/OVI VI
VI Property Nodestask
DAQ Assistant Express VIDAQ Assistant Express VI
NI-DAQmx NI-DAQmx HelpLabVIEW Data Acquisition and Signal Conditioning
DAQ Assistant Express VIDAQ Assistant Express VI
local task
DAQ Assistant Express VI
VI DAQ Assistant Express VI
9
LabVIEW 9-10 ni.com
(A/D)
Acquire 1 SampleAcquire n Samples n Acquire
Continuously
NI-DAQmx
9
© National Instruments Corporation 9-11 LabVIEW
sample rate sample mode (finite)
NI-DAQmx
continuous
NI-DAQmx
NI-DAQmxtrigger
9
LabVIEW 9-12 ni.com
VI DAQ Signal Accessory
DAQ 0
1. VI
a. Meter Controls»Numeric Indicators0.0 0.4
Labeling 10.0 0.4
b. Vertical Toggle Switch Controls»Buttons & Switches
FALSE Latch When Pressed
c. Labeling Off On
2.
9
© National Instruments Corporation 9-13 LabVIEW
a. DAQ Assistant Express VI Functions»Input VI
�– Analog Input»Voltage�– Dev1»ai0�– Finish�– Analog Input Voltage Task Task Timing
Acquire 1 Sample�– OK Analog Input Voltage Task
ConfigurationDAQ Assistant Express VI
b. Wait Until Next ms MultipleFunctions»All Functions»Time & Dialog
Create Constant100 100 ms
c. Unbundle by Name Functions»All Functions»Clusterstatus
d. Or Functions»Arithmetic & Comparison»Express Boolean
3. Voltmeter.vi VI C:\Exercises\LabVIEW Basics I You will use this VI later in the course.
4. VI
5. VI
DAQ Signal Accessory100 100
DAQ Assistant Express VI 100 DAQ Assistant Express VI VI
6. DAQ Assistant Analog Input Voltage Task Configuration
7. Custom Scaling Create New8. Linear temperature Finish9.
a. 100 Scaled Units Celsius
9
LabVIEW 9-14 ni.com
b. OK10. Analog Input Voltage Task Configuration
0 100 OK
11. VI 100
12. VI VI 9-3VI
9
© National Instruments Corporation 9-15 LabVIEW
1. 9-2 Voltmeter VI2. DAQ Signal Accessory Temp Sensor Noise ON
3. VI 100
4. Collector Express VI Functions»Signal Manipulation Express VI
Express VI Configure Collector
Maximum number of samples 100OK
5. Statistics Express VI Functions»AnalysisConfigure Statistics
Arithmetic MeanOK
6. File»Save As Measurement Averaging.vi VIC:\Exercises\LabVIEW Basics I
7. VI Temp Sensor Noise
8. VI
9
LabVIEW 9-16 ni.com
DAQ
�• LabVIEW
�•LabVIEW
LabVIEW LabVIEW ASCIILabVIEW
LabVIEW LabVIEW
Write LabVIEW Measurement File Express VI Functions»OutputLabVIEW Express VI
Read LabVIEW Measurement File Express VI Functions»InputLabVIEW Express VI
9
© National Instruments Corporation 9-17 LabVIEW
9-3 Measurement Averaging VI LabVIEW
VI
1. Measurement Averaging VI C:\Exercises\LabVIEW Basics I
2.
Write LabVIEW Measurement File Express VI Functions»Output Express VI DAQ
Configure Write LabVIEW Measurement Filea. Action Ask user to choose fileb. Segment Headers One header only
c. X Value Columns One column per channelASCII
d. Delimiter Tab
e. OKMerge Errors VI Functions»All Functions»
Time & Dialog DAQ I/O
9
LabVIEW 9-18 ni.com
3. File»Save As Simple Data Logger.vi VIC:\Exercises\LabVIEW Basics I
4. VI logger.lvm C:\Exercises\LabVIEW Basics I
5. VI
6. VI Controls»Graph Indicators
7.
a. Read LabVIEW Measurement File Express VI Functions»Input Express VI
LabVIEWConfigure Read LabVIEW
Measurement File�– Action Ask user to choose file�– Segment Size Retrieve segments of original size
9
© National Instruments Corporation 9-19 LabVIEW
�– Time Stamps Relative to start of measurement
�– Generic Text File Read generic text files LabVIEW
�– OKb. Data Available While Loop
LabVIEW While Loop
c. Unbundle by Name Functions»All Functions»Cluster
d. Or Functions»Arithmetic & Comparison»Express Boolean
8. Simple Data Reader.vi VI C:\Exercises\LabVIEW Basics I
9. VI4 logger.lvm
10. LabVIEW
y
11. Simple Data Reader VI
9
LabVIEW 9-20 ni.com
(D/A) (task)
Generate 1 SampleGenerate n Samples Generate
Continuously
DC
9
© National Instruments Corporation 9-21 LabVIEW
TTL
sample ratesample mode (finite)
ACGenerate n Samples
nevent
AC continuous
NI-DAQmx
NI-DAQmxtrigger start
trigger
9
LabVIEW 9-22 ni.com
VI 0 0.5 V9.5 V
1. Analog Out CH0 DAQ Signal Accessory Analog In CH1
2. Voltage Output VI C:\Exercises\LabVIEW Basics I
Voltage Output
3.
Wait Until Next ms Multiple Functions»All Functions»Time & Dialog For Loop 500 msSelect VI Functions»Arithmetic & Comparison»Express Comparison
DAQ 0
DAQ4.
9
© National Instruments Corporation 9-23 LabVIEW
P For Loop DAQ Assistant Express VI Functions»Input Express VI
a. Analog Output»Voltageb. Dev1»ao0 Finishc. Analog Output Voltage Task Configuration
Task Timing Generate 1 Sample0 10
d. OK Analog Output Voltage Task ConfigurationDAQ Assistant
Express VI5. VI6.
7. 9-2 Voltmeter VI8. 0.0 10.0
9. Voltmeter VI DAQ Assistant Express VIAnalog Input Voltage Task Configuration
10. Channel List Voltage Change Physical Channel ai1 DAQ
Analog Out CH0 Analog In CH1
11. Custom Scaling No Scale
9
LabVIEW 9-24 ni.com
12. 0 10
13. OK14. Voltmeter VI15. Voltage Output VI
Voltage Output VI 0.5 V 0 9.5 V For Loop VI 0 V
16. VI
9
© National Instruments Corporation 9-25 LabVIEW
counter
�• Count Register �—
�• Source �—
�• Gate �—
�• Output �—pulse train
24
2( ) �– 1 = 224 �– 1 = 16,777,215
24 16,777,215 terminal count 0
9
LabVIEW 9-26 ni.com
VI DAQ Signal Accessoryquadrature encoder
1. VI
2.
DAQ Assistant Express VI Functions»InputWhile Loopa. Counter Input»Edge Countb. Dev1»ctr0c. Counter Input Edge Count Task Configuration
Programmable Function Input (PFI) 8 0DAQ Signal Accessory 0 PFI
8d. OK Counter Input Edge Count Task
ConfigurationDAQ Assistant Express VI
3. Simple Event Counting.vi VIC:\Exercises\LabVIEW Basics I
4. DAQ Signal Accessory A0 SOURCE
9
© National Instruments Corporation 9-27 LabVIEW
5. VI DAQ Signal AccessoryNumber of Events
6. VI7. DAQ Assistant Express VI Count Direction
Externally Controlled OK
DAQ Signal Accessory B 0Up/Down
8. VI DAQ Signal Accessory Number of Events
9. VI
9
LabVIEW 9-28 ni.com
I/O
DAQ
DAQ
9
© National Instruments Corporation 9-29 LabVIEW
VIDAQ Signal Accessory Port 0 LED LED
DAQ 0 1 2 3LED
LED 1 LED LED0 LED LED
1. Digital Example VI C:\Exercises\LabVIEW Basics
DAQ Assistant Express VI Functions»InputWhile Loopa. Digital I/O»Port Outputb. Dev1»port0 Finishc. Digital Output Port Task Configuration
Invert All Lines In Port LEDd. OK
DAQ Assistant VIArray
Subset0 Boolean
Array to NumberDAQ Assistant Express VI
2. VI3. VI Boolean LED DAQ Signal
Accessory4. VI
9
LabVIEW 9-30 ni.com
�• MAX DAQ�• DAQ Assistant DAQ�• DAQ Assistant
NI-DAQmx VI�• DAQ Assistant I/O
9
© National Instruments Corporation 9-31 LabVIEW
9-8 VIVI
LED DAQ Signal Accessory LED 0LED
Temp Monitor with LED.vi VIC:\Exercises\LabVIEW Basics I
9
LabVIEW 9-32 ni.com
© National Instruments Corporation 10-1 LabVIEW
LabVIEW GPIBInstrument I/O Assistant
I/O
A.B. GPIBC. Instrument I/O AssistantD. VISAE. LabVIEW F. VIG.H.
10
LabVIEW 10-2 ni.com
GPIBVXI PXI SCSI CAMAC
GPIB
PC�•�•�•�• ASCII�•
10
© National Instruments Corporation 10-3 LabVIEW
ANSI/IEEE Standard 488.1-1987 General Purpose Interface Bus GPIB
GPIB1 Mbyte/s
System Controller 14ANSI/IEEE Standard 488.2-1992 IEEE 488.1
GPIB
GPIB
GPIB 24ATN EOI IFC REN SRQ
GPIB
GPIBASCII
GPIB GPIB 0 300 GPIB GPIB 1
30 GPIB
GPIB GPIB VI
GPIB�• GPIB (EOI)
�• (EOS)EOI
�•
EOI OR EOS
10
LabVIEW 10-4 ni.com
GPIB
�•
�•�•
�•�•�•
bus extender
National Instruments
ni.com/support/gpibsupp.htm
LabVIEW GPIB DAQGPIB LabVIEW CD
ni.com/support/gpib/versions.htm GPIB
LabVIEW
(Windows) MAX GPIB MAXWindows Registry
Device Manager DLLGPIB Instrument I/O VI
(Mac OS UNIX)
MAX National Instruments
10
© National Instruments Corporation 10-5 LabVIEW
MAX LabVIEWTools»Measurement & Automation Explorer
MAX Configuration My System�• Data Neighborhood�— Use
this section to create and test virtual channels, aliases, and tags to channels or measurements configured in Devices and Interfaces.
�• Devices and Interfaces�—
�• IVI Instruments�— IVIIVI
�• Scales�—DAQ Signal Accessory
�• Historical Data�—�• Software�— National Instruments
�• VI Logger Tasks�—VI Logger
Scan For InstrumentsMAX GPIB
10
LabVIEW 10-6 ni.com
Configuration Remote SystemsRT Series PXI Controller MAX
10
© National Instruments Corporation 10-7 LabVIEW
1. NI Instrument SimulatorGPIB
2. NI Instrument Simulator Power Ready LED
3. MAX LabVIEWTools»Measurement & Automation Explorer
4. Devices and InterfacesGPIB NI-488.2
5. GPIB PropertiesProperties
6. GPIB OK7. Devices and Interfaces GPIB
Scan for Instruments8. GPIB Instrument0 9. Instrument0 MAX
NI Instrument Simulator GPIB (PAD) 210. Communicate with Instrument
10
LabVIEW 10-8 ni.com
11. Send String *IDN? Query String Received
12. Send String MEAS:DC? QueryNI Instrument Simulator
13. Query14. Exit15. NI Instrument Simulator VISA alias
a. MAX Instrument0 VISA PropertiesProperties
b. VISA Alias devsim OK
16. File»Exit MAX
10
© National Instruments Corporation 10-9 LabVIEW
Instrument I/O Assistant Functions»Input Functions»All Functions»Instrument I/O LabVIEW Express VI
GPIBInstrument I/O Assistant
Instrument I/O AssistantInstrument I/O Assistant
Step SequenceI/O
Instrument I/O Assistant Instrument I/O Assistant Express VI Instrument I/O Assistant
Instrument I/O AssistantInstrument I/O Assistant
1. MAX Select an instrument
2. Code generation type VISAGPIB
3. Add Step�• Query and Parse�— *IDN?
Write Read and Parse
�• Write�—�• Read and Parse�—
4. Run Express VI
5. OK Instrument I/O Assistant
LabVIEW Instrument I/O Assistant Express VI
Instrument I/O Assistant Instrument I/O Assistant Open Front Panel
Express VI subVI
Express VI subVI
10
LabVIEW 10-10 ni.com
VI NI Instrument Simulator
1. VI2.
3.
a. Instrument I/O Assistant Express VI Functions»Input Instrument I/O Assistant Express VI(1) Select an instrument devsim Code
generation type VISA Code Generation(2) Add Step Query and Parse
Instrument Simulator(3) *IDN? \n Termination
character Run this step
(4) Auto parseToken Outputs
identification query
10
© National Instruments Corporation 10-11 LabVIEW
Token name ID String Token
(5) Add Step Query and ParseMEAS:DC? Run this step
(6) Auto parseToken name
Voltage Token .(7) OK I/O Assistant
b. ID StringCreate»Indicator
c. Voltage Create»Indicator
d. Error Out Simple Error Handler VI4. VI5. Read Instrument Data.vi VI C:\Exercises\
LabVIEW Basics I
6. I/O Assistant Show Front PanelsubVI Convert
7. I/O Assistant *IDN? Instrument Simulator
8. File»Exit subVI
10
LabVIEW 10-12 ni.com
Virtual Instrument Software Architecture VISA) LabVIEW VI
1993 National Instruments GenRad Racal Instruments Tektronix Wavetek VXIplug&play Systems Alliance
VXI
I/O VXIplug&play
VXIplug&play
�•�•�•�•�•�•�•�•�•�•
VISA VXIplug&play I/O VXIplug&play Systems Alliance VISA
API VISA VXIGPIB
VISAVISA VISA
LabVIEW VISA GPIBVXI I/O
LabVIEW Functions»All Functions»Instrument I/O»GPIB VI
10
© National Instruments Corporation 10-13 LabVIEW
VISALabVIEW
VISA I/O
VI
�• Resource�—�• Session�— VISA
LabVIEW VISAVISA
�• Instrument Descriptor�—(GPIB, VXI, ASRL)
VISA INSTR Event
MAX alias(Mac OS) visaconf.ini VISA (UNIX) visaconf
Instrument I/O AssistantVI VISA VISA
Write VISA ReadVISA Write
VISA Read
ASRL[board][::INSTR]
GPIB GPIB[board]::primary address[::secondary address][::INSTR]
VXI MXIbus VXI[board]::VXI logical address[::INSTR]
GPIB-VXI GPIB-VXI[board][::GPIB-VXI primary address]::VXI logical address[::INSTR]
10
LabVIEW 10-14 ni.com
VI VISA NI Instrument Simulator1. Instrument Simulator GPIB
2. VI
3.
a. VISA Open Functions»All Functions»Instrument I/O»VISA»VISA Advanced
VISA VISA resource name Create»Control
b. VISA Write Functions»All Functions»Instrument I/O»VISA
10
© National Instruments Corporation 10-15 LabVIEW
write bufferCreate»Control
c. VISA Read Functions»All Functions»Instrument I/O»VISA
byte countCreate»Control read buffer
Create»Indicatord. VISA Close Functions»All
Functions»Instrument I/O»VISA»VISA Advanced
e. Simple Error Handler VI Functions»All Functions»Time & Dialog VI
4. My VISA Write & Read.vi VI C:\Exercises\LabVIEW Basics I
5. VISA resource name devsimbyte count 200 write
buffer *IDN? VI6. VI
7. VI
10
LabVIEW 10-16 ni.com
VILabVIEW
LabVIEW GPIB VXI PXI
I/O
LabVIEW LabVIEW CDNational Instruments ni.com/idnetLabVIEW
\labview\instr.libLabVIEW Functions»All Functions»
Instrument I/O»Instrument Drivers VI
Getting Started ExampleMAX GPIB VISA Resource Name
10
© National Instruments Corporation 10-17 LabVIEW
IEEE 488.2
VI VILabVIEW I/O
I/O DAQ TCP/IPI/O I/O
VI�• Initialize�— VI
�• Configuration�—
�• Action/Status�— VI Action VIStatus VI
action VI Acquire Single ShotQuery Transfer Pending status VI
�• Data�—
Getting Started
Initialize Application Example Close
Configuration Action/Status Data Utility
10
LabVIEW 10-18 ni.com
�• Utility�—
�• Close�—
National Instruments
LabVIEW VI VI
VI VI
VI
VI
resource name instrument descriptor
Interface Type[board index]::Address::INSTR
GPIB::2::INSTR2 GPIB
VISA Controls»All Controls»I/ODAQ VISA
VISA
MAX10-1 VISA devsim NI Instrument Simulator
VISAdevsim
GPIB::2::INSTR
VI VISA(session number) VISA
10
© National Instruments Corporation 10-19 LabVIEW
VI VISAClose VI
devsim VIVI
10
LabVIEW 10-20 ni.com
VI NI Instrument Simulator DC
VIVI
1. File»New Template»Frameworks»Single Loop Application Single Loop Application VI
2.
a. VISA resource name control Controls»All Controls»I/O
b. x
10
© National Instruments Corporation 10-21 LabVIEW
3.
a. Add Shift Register
b. NI DEVSIM Initialize VI Functions»Input»Instrument Drivers»NI Device SimulatorVI LabVIEW NI Instrument Simulator�– ID Query
Create»Constant OperatingFALSE
�– Resetc. NI DEVSIM Multimeter Configuration VI
Functions»Input»Instrument Drivers»NI Device Simulator»Configuration VI NI Instrument Simulator
0.0 10.0 V DCd. NI DEVSIM Measure DC Voltage VI
Functions»Input»Instrument Drivers»NI Device Simulator»Data VI NI Instrument Simulator
e. NI DEVSIM Close VI Functions»Input»Instrument Drivers»NI Device Simulator VILabVIEW NI Instrument Simulator
f. Max & Min Functions»All Functions»Comparison
10
LabVIEW 10-22 ni.com
g. Simple Error Handler VI Functions»All Functions»Time & Dialog VI
h. Unbundle by Name Functions»All Functions»Cluster status
i. Or Functions»Arithmetic & Comparison»Express Boolean While Loop STOPWhile Loop
j. wait for the Time Delay Express VI 1k.
VISA I/O
4. Voltage Monitor.vi VI C:\Exercises\LabVIEW Basics I
5. NI Instrument Simulator6. VI LabVIEW GPIB
LED Listen Talk
7. VI
10
© National Instruments Corporation 10-23 LabVIEW
�• baud rate�•�• (parity bit)�• stop bit
m
RS-232 MARK SPACE
1 RS-232 2 RS-232 3
76.6F
13
2
Idle
Space
Mark
Bit Time
Character Frame
StartBit
DataBits
ParityBit
StopBits
Idle
10
LabVIEW 10-24 ni.com
MARK SPACERS-232
Signal > +3 V = 0Signal < �–3 V = 1
+12 V �–12 V +3 V �–3 V
start bit(MARK) (SPACE)
9,6000.104 ms
1.146 ms
least significant bit LSB) most significant bit MSB)
1 0 11011016D ASCII m
(parity bit)1 0
(parity) 11
0
1 1.5 2(MARK)
(SPACE)
9,6009,600/11 = 872
10
© National Instruments Corporation 10-25 LabVIEW
RS-232 Electronic Industries Association (EIA)Data Terminal Equipment DTE)
Data Communications Equipment DCE)RS-232
RS-232C
IBM RS-232
RS-449 RS-422 RS-423 EIA RS-232RS-449 1975 RS-232
RS-449 RS-422 RS-423RS-232 single-ended transmission RS-422
differential transmission RS-232C1 RS-422
RS-422
RS-422 RS-423RS-423 15 RS-232
DCE DTEDCE TA adapter plotter DTE
RS-232 D-Type 25 D-Type 9PC
9 25 D-Type
TxD
RxD
3
2
10
LabVIEW 10-26 ni.com
DB-9 RS-232
DB-9 3 2 2 3
DB-25 RS-232RS-232
RTS
CTS
DSR
DCD
DTR
7
8
6
1
4
Com 5 �— �—
RI 9
10
© National Instruments Corporation 10-27 LabVIEW
Functions»All Functions»Instrument I/O»Serial VI
VISA GPIB VISA WriteVISA Read
GPIBVISA Configure Serial Port VI
VISA Configure Serial Port VI VISA resource nametimeout baud rate,
data bits, parity flow control error in error out VI
*IDN? COM2VISA Configure Serial Port VI COM2
9,600 8XON/XOFF VISA Write
VISA Read 200 Simple Error Handler VI
TxD
RxD
2
3
RTS
CTS
DSR
DCD
DTR
4
5
6
8
20
Com 7 �— �—
10
LabVIEW 10-28 ni.com
Functions»All Functions»Instrument I/O»Serial VIVISA LPT
MAX LPT1 ASRL10::INSTR VISA
10
© National Instruments Corporation 10-29 LabVIEW
Instrument I/O Assistant NI Instrument Simulator VI
1. NI Instrument Simulator
�• = 9,600�• = 8�• = �• = 1�• =
Handshaking
XON/XOFF XON XOFF
RS-232 RTS CTS
2. NI Instrument Simulator
3. NI Instrument Simulator Power Ready Listen LED
10
LabVIEW 10-30 ni.com
4. VI
a. Instrument I/O Express VI Functions»Input Instrument I/O Assistant
Express VI(1) Select an instrument COM1
COM2 NI Instrument Simulator(2) Add Step Write
*IDN? \n as the Termination character(3) Add Step Read and Parse(4) Add Step Read and Parse
Instrument Simulator termination character*IDN?
(5) Run Run this step Run
(6) Read and Parse(7) Auto parse
(8) Token name Token String Length
(9) Read and Parse(10) Auto parse NI Instrument Simulator
10
© National Instruments Corporation 10-31 LabVIEW
(11) Token name Token String
(12) OKb. String Create»
Indicatorc. String Length
Create»Indicator
LabVIEW Simple Error Handler VI error out
5. VI 6. Serial Communication.vi VI
C:\Exercises\LabVIEW Basics I
7. VI
10
LabVIEW 10-32 ni.com
ASCIIASCIIASCII
1,024 0 255ASCII 4
34,096 (4 1,024)
ASCIIASCII
Extract Numbers VI C:\Exercises\LabVIEW Basics I ASCII
VI
1,024 (1 1,024)
1
String To Byte Array Functions»All Functions»String»String/Array/Path Conversion
Header(6 bytes)
Data Point (up to 4 bytes each) Trailer(2 bytes)
CURVE {12,28,63,...1024 points in total...,}CR L
Header(7 bytes)
Data Point(1 byte each)
Trailer(3 bytes)
CURVE % {MSB}{LSB} {ÅŤå...1024 bytes in total...} {Chk} CRCount
(4 bytes)
10
© National Instruments Corporation 10-33 LabVIEW
2Type Cast Functions»All Functions»Advanced»Data Manipulation LabVIEW Basics II: Development Course Manual
GPIB1,024 2
2,0484 DATA 2
Type Cast16
Swap Bytes Functions»All Functions»Advanced»Data Manipulation 8
8 GPIB 8
Swap Bytes
Numeric ArrayBinary WaveformString (withoutheader or trailer)
String Waveform
4-byte header 2-byte trailer (carriage return) (line feed)
2 bytes representing the first data point
Memory
DATA«HB1»«LB1» «HB2»«LB2»...«HB1024»«LB1024»«CR»«LF»
from instrument«LF»«CR»«LB1024»«HB1024»...«LB2»«HB2»«LB1»«HB1»ATAD
GPIB 0246
AA
LB1LB2
DT
HB1HB2
20502052
LB1024
LFHB1024
CR
10
LabVIEW 10-34 ni.com
Swap Bytes
Memory0246
AA
LB1LB2
DT
HB1HB2
20502052
LB1024
LFHB1024
CR
Memory0246
DT
HB1HB2
AA
LB1LB2
20502052
HB1024
CRLB1024
LF
10
© National Instruments Corporation 10-35 LabVIEW
ASCII 128ASCII
CURVE {12,28,63,...128 points in total...,}CR LF
128 1
CURVE % {Bin Count MSB}{Bin Count LSB}{åå¤Å...128 bytes in total...} {Checksum} CR LF
VI VINI Instrument Simulator
1. NI Instrument SimulatorGPIB
GPIB 2
2. NI Instrument Simulator Power Ready LEDNI Instrument Simulator GPIB
3. Waveform Example VI C:\Exercises\LabVIEW Basics I
10
LabVIEW 10-36 ni.com
Data Format ASCII Data Source GPIB NI Instrument Simulator
4.
10
© National Instruments Corporation 10-37 LabVIEW
String Subset Functions»All Functions»String128
String to Byte Array Functions»All Functions»String»String/Array/Path Conversion
String Length Functions»All Functions»String
Extract Numbers VI Exercises ASCII
VISA Write VISA Read Functions»All Functions»Instrument I/O»VISA NI Instrument Simulator
ASCII 1Simple Error Handler VI Functions»All Functions»Time & Dialog
5. VITRUEFALSE ASCII
6. Data Format ASCII VI ASCIIVI
7. Data Format Binary VIVI
ASCIIASCII
8. VI
10
LabVIEW 10-38 ni.com
�• LabVIEW
�• MAX GPIB
�• LabVIEW
�• LabVIEW LabVIEW CDNI ni.com
�• VI�• Instrument I/O Assistant VI
VXI GPIB RS-232�•
10
© National Instruments Corporation 10-39 LabVIEW
10-7 10-4 Voltage Monitor VIvoltage.txt
File»Save As Voltage Data to File.viVI C:\Exercises\LabVIEW Basics I
10
LabVIEW 10-40 ni.com
© National Instruments Corporation 11-1 LabVIEW
VI LabVIEW
A.
B. VI subVI
C.
D. VI VI
E.
11
LabVIEW 11-2 ni.com
VIVI VI
File»VI Properties VI VI VI
Properties VI VI PropertiesLabVIEW Basics II: Development Course Manual VI
VI Properties Category
�• General�— VIVI
VI
�• Documentation�— VI2-2
�• Security�— VI
�• Window Appearance�—
�• Window Size�—
�• Execution�— VIVI subVI
�• Editor Options�— VI
Create»Control or Create»Indicator LabVIEW
VI Properties Category Window Appearance VI
VILabVIEW
VI VI
VI VIVI VI VI
11
© National Instruments Corporation 11-3 LabVIEW
VI Same as VI Name Window title
�• Top-level Application Window�—
�• Dialog�—VIVI LabVIEW
(UNIX)
Dialog
<Enter> <Return> LabVIEW
�• Default�— LabVIEW
�• Custom�—
�• Customize�— Customize Window Appearance
VI Properties Category Window Size VI
�• Minimum Panel Size�—Window Appearance
�• Size Front Panel to the width and height of the entire screen�—VI
VI
�• Maintain proportions of window for different monitor resolutions�— VI VI
1,024 768 VI800 600
�• Scale all objects on Front Panel as the window resizes�—
11
LabVIEW 11-4 ni.com
VI VI subVI
LabVIEW subVI subVIsubVI subVI
SubVI Node Setup subVI subVIVI Properties
subVI subVIsubVI SubVI Node Setup
SubVI Node Setup Show Front Panel when calledClose afterwards if originally closedsubVI
�• Open Front Panel when loaded�— subVI VI
�• Show Front Panel when called�— subVI
�• Close afterwards if originally closed�— Show Front Panel when called subVI subVI
�• Suspend when called�— subVIOperate»Suspend when called
subVI subVIsubVI File»VI Properties CategoryWindow Appearance Customize Show Front Panel When Called Close Afterwards if Originally Closed
11
© National Instruments Corporation 11-5 LabVIEW
VI 0.510 subVI
1. VI
�•Visible Items»Digital Display
�• # of data values 32 (I32)
2.
a. 2-2 Thermometer VIVI
b. Wait Until Next ms MultipleFunctions»All Functions»Time & Dialog
Create»Constant 500For Loop 500 ms
11
LabVIEW 11-6 ni.com
c. Multiply Functions»Arithmetic & Comparison»Express Numeric
0.50 x VI
d. Pop-up Graph VI C:\Exercises\LabVIEW Basics I VI XY
e.
3. Use Pop-up Graph.vi VI C:\Exercises\LabVIEW Basics I
4. subVI
a. Pop-up Graph subVI
b. File»VI Propertiesc. Category Window Appearanced. Customize
e. OK subVIsubVI
5. Use Pop-up Graph VI VI 10Pop-up Graph VIDONE VI
6. Pop-up Graph subVI Dialog7. subVI
8. Use Pop-up Graph VI Pop-up Graph subVI
9. VI
11
© National Instruments Corporation 11-7 LabVIEW
11
LabVIEW 11-8 ni.com
VI <Tab>
LabVIEW<Enter>
Advanced»Key Navigation Key Navigation .
Advanced»Key Navigation
Key AssignmentCurrent Assignments
VI <Tab>Skip this control when tabbing
11
© National Instruments Corporation 11-9 LabVIEW
1. Temperature System VI C:\Exercises\LabVIEW Basics I
Latch When Pressed
VI
While Loop VI
STOP Latch When Released
VI
2. Advanced»Key Navigation Key Navigation
3. Key Assignment4. 2 3
11
LabVIEW 11-10 ni.com
5.
Display Temp VI 500 ms
Display and Log Temp VI 500 ms
Display Logged Temp VI
6. subVI
a. subVI SubVI Node Setup
b. Show Front Panel when called Close afterwards if originally closed
c. OK SubVI Node Setup
d. a c subVI
7. VI VI
8. <Enter>subVI Temperature System VI <Enter>
9. VI
10. Temperature System VI VI
a. File»VI Propertiesb. Category Executionc. Run When Opened
11
© National Instruments Corporation 11-11 LabVIEW
11. VI
a. Category Window Appearanceb. Customizec. Show Menu Bar Show Toolbar When Running
d. OK12. VI
13. Temperature System VI VI
14. VI
11
LabVIEW 11-12 ni.com
VI VIRun When Opened
VI LabVIEW VILabVIEW VI
LabVIEW Quit LabVIEW Functions»All Functions»Application Control VI
LabVIEWLabVIEW
VI VI File»Save with Options
Development Distribution VIvi.lib VI
VI VI
Remove diagrams VIVI VI
VI
VI VI11-3 VI
11
© National Instruments Corporation 11-13 LabVIEW
VI VILabVIEW
1. VI Edit Me VIC:\Exercises\LabVIEW Basics I
VIVI
2. Start 10 VI LabVIEW
3. LabVIEW VI
4. VI subVI5 13
VI subVI subVIsubVI Add
VI subVIVI Run
VIsubVI
5. VI
6. Edit Me VI Edit Me VI
Edit Me VI
7. Operate»Change to Edit ModeVI
8. Unlock VI File»VI Properties Category Security VI
11
LabVIEW 11-14 ni.com
9. Quit LabVIEW
10. Edit Me VI VI
11. Edit Me VI
12. VI
13. Edit Me VI
11
© National Instruments Corporation 11-15 LabVIEW
Controls Functions VIVIVI
VI Controls Functionslabview\user.lib LabVIEW
Functions»Express User Libraries Controls»Express User Controls VI (.llb)labview\user.lib (.mnu)labview\user.lib
LabVIEW LabVIEW
Functions»All Functions»Instrument I/Olabview\instr.lib
Functions
Controls Functions VIVI
Controls FunctionsVI custom palette view LabVIEW ExpressAdvanced Tools»Advanced»Edit Palette Views
LabVIEW User Manual LabVIEW Help
11
LabVIEW 11-16 ni.com
�• File»VI Properties VIVI
VI Properties
�• subVI subVIsubVI SubVI Node Setup
SubVI Node Setup Show Front Panel when called Close afterwards if originally closed
�• subVI subVIFile»VI Properties Category Window Appearance Customize Show Front Panel When Called Close Afterwards if Originally Closed
�•Advanced»Key Navigation
�• VI VI File»Save with Options VI
�• VI VI
�– subVI VIsubVI
�– VI subVI VI
�• VI Controls Functionsuser.lib
�• Tools»Advanced»Edit Palette Views
�• Format
11
© National Instruments Corporation 11-17 LabVIEW
11
LabVIEW 11-18 ni.com
© National Instruments Corporation A-1 LabVIEW
LabVIEW
LabVIEW
LabVIEWNational Instruments NIni.com
National InstrumentsKnowledgeBase
National InstrumentsNI Developer Zone ni.com/zone
NI Developer ZoneAlliance Program
National Instruments Alliance Program
National InstrumentsAlliance Program
National Instruments LabVIEWNational Instruments ni.com/training
National Instruments
LabVIEW A-2 ni.com
LabVIEW Technical Resource LabVIEW
LabVIEW VILabVIEW Technical
Resource LTR publishing (214) 706-0587www.ltrpub.com
LabVIEW National Instruments LabVIEW
LabVIEW
Info-labview LabVIEWLabVIEW
info-labview [email protected]
info-labview [email protected]
ftpftp://ftp.pica.army.mil/pub/labview/
VI
© National Instruments Corporation A-3 LabVIEW
ASCII
00 000 0 NUL 20 040 32 SP
01 001 1 SOH 21 041 33 !
02 002 2 STX 22 042 34 "
03 003 3 ETX 23 043 35 #
04 004 4 EOT 24 044 36 $
05 005 5 ENQ 25 045 37 %
06 006 6 ACK 26 046 38 &
07 007 7 BEL 27 047 39 '
08 010 8 BS 28 050 40 (
09 011 9 HT 29 051 41 )
0A 012 10 LF 2A 052 42 *
0B 013 11 VT 2B 053 43 +
0C 014 12 FF 2C 054 44 ,
0D 015 13 CR 2D 055 45 -
0E 016 14 SO 2E 056 46 .
0F 017 15 SI 2F 057 47 /
10 020 16 DLE 30 060 48 0
11 021 17 DC1 31 061 49 1
12 022 18 DC2 32 062 50 2
13 023 19 DC3 33 063 51 3
14 024 20 DC4 34 064 52 4
15 025 21 NAK 35 065 53 5
16 026 22 SYN 36 066 54 6
17 027 23 ETB 37 067 55 7
LabVIEW A-4 ni.com
18 030 24 CAN 38 070 56 8
19 031 25 EM 39 071 57 9
1A 032 26 SUB 3A 072 58 :
1B 033 27 ESC 3B 073 59 ;
1C 034 28 FS 3C 074 60 <
1D 035 29 GS 3D 075 61 =
1E 036 30 RS 3E 076 62 >
1F 037 31 US 3F 077 63 ?
40 100 64 @ 60 140 96 `
41 101 65 A 61 141 97 a
42 102 66 B 62 142 98 b
43 103 67 C 63 143 99 c
44 104 68 D 64 144 100 d
45 105 69 E 65 145 101 e
46 106 70 F 66 146 102 f
47 107 71 G 67 147 103 g
48 110 72 H 68 150 104 h
49 111 73 I 69 151 105 i
4A 112 74 J 6A 152 106 j
4B 113 75 K 6B 153 107 k
4C 114 76 L 6C 154 108 l
4D 115 77 M 6D 155 109 m
4E 116 78 N 6E 156 110 n
4F 117 79 O 6F 157 111 o
50 120 80 P 70 160 112 p
51 121 81 Q 71 161 113 q
52 122 82 R 72 162 114 r
© National Instruments Corporation A-5 LabVIEW
53 123 83 S 73 163 115 s
54 124 84 T 74 164 116 t
55 125 85 U 75 165 117 u
56 126 86 V 76 166 118 v
57 127 87 W 77 167 119 w
58 130 88 X 78 170 120 x
59 131 89 Y 79 171 121 y
5A 132 90 Z 7A 172 122 z
5B 133 91 [ 7B 173 123 {
5C 134 92 \ 7C 174 124 |
5D 135 93 ] 7D 175 125 }
5E 136 94 ^ 7E 176 126 ~
5F 137 95 _ 7F 177 127 DEL
LabVIEW A-6 ni.com
1.�• LabVIEW Basics I: Introduction Course Manual
�• LabVIEW Professional Development System 7.0�• DAQ Board ID 1�• DAQ Signal Accessory DAQ DAQ Signal
Accessory�• GPIB�• NI Instrument Simulator GPIB NI
Instrument Simulator GPIB NI Instrument Simulator
�•2. Student Guide Installing the Course Software
readme.txt
3. LabVIEW Start»Programs»Station Tests»LV Station Test LV Station Test VI VI
4. MAX DAQ GPIB5. NI DEVSIM NI Instrument
Simulator GPIB
National Instruments
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________________
_____________________________________________________________________
________________________________________________________________________________________
________________________________________________________________________________________
____________________________________________________________________________________
________________________________________________________________________________________
____________________________________________________________________________________________
____________________________________________________________________________________
( ___ )____________________________________ Fax ( ___ ) ____________________________________
Customer Education Customer EducationNational Instruments Corporation National Instruments Corporation11500 North Mopac Expressway 512 683 6837Austin, Texas 78759-3504
_________________________________________________________________________________________ ______________________________________________________________________________________________________________________________________ ____________________________________
_________________________________________________________________________________________ _____________________________________________ ____________________________________
__________
_____________________________________________________________________________________________ _______________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________
_____________________________________________________________________________________________ ___________________________________________________________
_____________________________________________________________________________________________ ___________________________________________________________
_____________________________________________________________________________________________ _____________________________________________________________________
_____________________________________________________________________________________________ _____________________________________________________
_____________________________________________________________________________________________ ___________________________________________________
_____________________________________________________________________________________________NI NI
______________________________________________________________________________________