LabVIEW" Core 1
Exercises
NATIONAL,
nicom/training INSTRUMENTS:Other National Instruments Training Courses
‘National Instruments offers several training courses for LabVIEW user.
‘These courses continue the traning you received here and expand ito other
seas Visitni .com/tzaining to purchase course materials orsign up for
insrgctoe-ted, hands-on courses at locations around the world,
National Instruments Certification
‘Earning an NI certification acknowledges yeur expense in working with
Ni predicts and technologies, The messurerin! and automation indus
‘your employer, clients. and peers recognize your NI eetification credential
‘asa symbol ofthe skills and knowledge you have gained through
experience. Vist ni .com/traintng for mor information about the
Neetification program,
LabVIEW Resources
“This section describes how you ean receive more information regarding
LabVIEW.
LabVIEW Publications
annexe oe
LabVIEW Books
“Many hooks have been writen about Lab VIEW programming
applications. The National Instruments Website contains ist oF all
the LabVIEW books and links to places to purchase these books.
Visithetp://zone.ni.com/devaone/cda/tut /p/1a/'389formore
informationAdditional Information and Resources
This appendix contains addtional informatien about National Instruments
technical suppeet options and LabVIEW resources
National Instruments Technical Support Options
Visit the following sections ofthe award-wirning National Instruments
|Web site at ni. con for technical support and professional services:
+ Support—Technical suppor at né cam/support includes the
following resouees:
— Self-Help Technical Resources—For answers and solutions,
Visits com, eupport for software drivers and updates,
searchable KnowledgeBase, reduc manuals, step-by-step
troubleshooting wizard, thousands of example programs, tuterials,
application notes, istroment drivers, and so on. Registered
user also receive access othe NI Discussion Forums at
‘ni com/forune. NI Applications Engineers make sure every
‘question submitted online receives ar answer.
= Standard Service Program Membership—This program ents,
‘members to ditect access to NI Applications Engineers via phone
‘and email for one-o-one technical sopport, a well as exclusive
tsccess to eLearning trtining modules atm‘ -con/ eLearning.
Nlotfers complementary membership for full year afer purchase,
after which you may renew to contine your benefits
For information about other technica. support options in your
sea, vist ni .con/ services of contact your local office at
+ System Integration —Ir you have time constrains, limited in-house
{echnical resources, or other project chal enges, National Instruments
Alliance Partner members ean help. The NI Alliance Parner joins
system integrators, consultants, and hardware vendors to provide
comprehensive service and expertise fo customers. The program ensures
‘ualified, specialized assistance for application and system
‘evelopment. To eam more, call your local NI office or visit,
icon/a
You also can visit the Worldwide Offices section of ni com/niglobal
to aceess the branch office Web sites, which provide up-to-date contact
information, support phone numbers, email addresses, and current eventsAa Mr tae
NotesNotes
asta sat a8, Run the VI and experiment with the vali
Frequency is won
Figure 42. lasing VI Fant
G1 Setthe Waveform Type to Sine
Set the Sampling Rate Hz to 10 MSI (megasamples per second)
Adjust the Frequency of the Original i the lowest
requency, and moving up unl the Fequency reported on the top
‘charts no longer correct. Notice how the Sampled plot bec
more distoned as you increase the Frequency of the Original Signal
Alter you have passed the Nyquis frequency (3 MHL inthis case),
the frequency recorded is no longer eorect. Ths isan example of|
9, ‘Try other values fr the contro using a sine wave
10. Serthe Waveform Type to Square. Moy the controls tsee how shape
recovery is affected by the sampling frequency and the Frequency ofthe
Signal
11. Stop and close the VI when you are finished
End of Exercise A-1soon Marana hse
Using the Resolution VI, determine the ede width of an input signal
that varies between 20.8 V using a DAQdevice with resolution of|
16s. Assume that gun is eiciently applied
Code Width:
Determine the code width of an input signal that varies between 210 V
Using & DAQ device with a resolution of bits, The devie input ange
Isset10 210 V,
Code Width:
Ifthe device input range is +1 V. and the resolution is 12 bits, what is the
largest input signal you can read without cutting off te input signal?
Input Signal Range:
Stop and close the VI when you ae fisted.
Open atiasing.vi inthe
\tabVIEW Core 1\
Measurement Fundanentals dicctry.
“This VI simulates the acquisition of waveform at a specific sampling
frequency. As you adjust the sampling frequency and the frequency of
the acquired waveform, you ean observe the Nyquist Theorem in effet.
‘This VI contains the following controls:
+ Original Signal
= Frequency—This input specifies he frequency of the signal
‘being acquired, You can increase or decrease this frequency
by turing the knob,
= Sampled Waveform—The input allows you to choose between
‘sine wave or a square wave, Use the sine wave input to
‘experiment with the Nyquist Theorem, and the square wave (0
‘understind how the sampling frecuency affects shape recovery.
+ Sampled Signat
= Sampling Rate (H2)—TRis input speifis the rate at which the
DAQ device takes a sample ofthe acquired signal. According to
the Nyquist Theorem, this rate should be at least tice the
Frequency ofthe sampled signal2. Rum the VI and experiment with the vals
i
ea
eacs
iuion VI Font Panel
'D. Click the Run button to run the VL
Leave the default stings for the consol
The red plot demonstrates the at
demonstrates the output of the ADC. Notize thatthe white plo isa poor
representation of the signal. You can see xe code width of 25 V shown
‘on the graph representing only 8 discrete levels
input sinewave, The white plot
Change the Resolution (ADC).
Notice that the signal representation quality increases as you increase
the ADC resolution
1 Set the resolution to 3 bits
Change the D
sce Input Range.
[Notice that when the range isto large, tke resolution is nt efficiently
divided among te signal range. When the input range i foo small, part
‘ofthe signal is cut of
Experiment further with different contol values until you
understand the importance ofeach input
1k is important to ensure that the input signal range is as close tothe deviceMeasurement Fundamentals
Exercise A-1 Concepts: Measurement Fundamentals
Goal
Understand how resolution, voltage range, gin and sisi affect a
measured signal
Description
1. Open Resolution.vi in the \LabVIEW Core 1\
Mossurenent Fundanentals directory.
“This VI simulates the acquisition of wsne wave and the digitization that
‘occurs with an analog to digital convertor (ADC). This VI contains the
following controls and indicators:
+ Input Signal Voltage—This input specifies the range of the signal
‘being acquired. The default vale of he controls #1. vole. This
‘means tht the range of the signal is? V—voltge between the
highest point of the signal andthe lowest point ofthe signal
+ Resolution (ADC)—This input specifies the resolution of he ADC
‘ofthe data acquisition device used toacquire the signal. The default,
value ofthe control is 3 bits,
+ Device Input Range—This input incorporates the input range of the
[ADC and the gain applied o the sign. The default value ofthe
contol is 32 Vole. This peak to peak voltage is equivalent to 2 V.
Because the input range ofthe ADC is #10 V, this means that there
isa gain of 10 applied tothe signal
+ Code Width—This output calculates the code width using the
‘current values ofthe controls, where Cis code width, D is device
input range, and is it of resolution:69]
5
Adda Release Semaphore VI to the Deposit Handler loop othe
right ofthe Sequence structure
Adda second Release Semaphore VI the Withdrawal Handler
Joop, tothe right of the Sequence strecture.
|G. Wire the Release Semaphore Visas shown in Figure 9:9
Adda Release Semaphore Reference VI to the right ofthe
While Loops.
Wire the Release Semaphore Refereece VI as shown in Figure 9-9.
[Notice that the Release Semaphore Reference VI requies only the
reference tothe semaphore
Save the VL
Repeat the step detailed inthe Identify Race Condition section to test
the modiiation wo this VI
Close the VI when you at finished,
End of Exercise 9-3Remove Race Condition
Remove the race condition by protecting theertcal section ofeode using a
semaphore. Inthe VI, the ertcal sections of coe are those enclosed by a
Sequence structure.
|. Save the Bank VIaszank with semaphores. inthe
\LabVIEW Core 1\Bank directory.
2. Use semaphores to protect the eitial sections of code, as shown in
Figure 99,
Figure 8. Bank wi Semaphore
Add an Obtain Semaphore Reference VIto the left ofthe Whi
Loops.
Wire the Obtain Semaphore Reference VI as shown in Figure 9.9
Add an Aequire Semaphore VI tothe Deposit Handler loop, the
left of the Sequence stracture.
|B Adda second Acquire Semaphore VI (o the Withdrawal Handler
Joxp tothe lft of the Sequence structure
{D. Wire the Acquire Semaphore VIsas shown in Figure 9.9,Exercise 9-3
Description
Concept: Bank VI
Eliminate ace condition ina VI.
‘You must identify and fix a problem with the server software in a hank,
‘The hank server hundles requests from many sources and must process
the requests quickly. In order to increase its eiceney, the server uses,
two parallel loops—one to handle deposits tothe account and another to
handle withdrawals. The problem with te sever is that some deposit or
‘withdrawal equests are lost, thereby resultirg in incorrect balances.
Identity Race Condition
1. Open Bank. in the \LabvrEW Core 1\Bank
directo.
Run the VI
3. Perform a deposit, a withdrawl, and a sine
familiarize yourself with the program.
4A. Sette Deposit Amount o 20 and the Withdrawal Amount 1 20.
'S. Open the block diagram of the Bank VI while is stil sunning
6. Amange the block diagram ofthe Bank VI so that you ean se it wile
‘operating the user interface,
1. Enable execution highlighting onthe blosk diagram by clicking
Highlight Execution,
8, Click the Simultaneous Transactions bation and watch the code as it
cexecttes, The hance should increase by 10.
[Notice that either the deposit or the withdrawal is fst, eausing the
balance to increase by 20 or decrease by 10.
9, Stop the VI
‘You tracked the problem down toa race condition in a section of code
handling deposits and withdrawals fra single account. Although you ean
see the issue with execution highlighting ensoled, during regular operation,
the issue would occu sporaTest
Challenge
1. Ran the Generate Data VI
Run the Read Data VI
3. Modify the value of the Time Delay (ms) contol
‘The Time Delay (ms) contol determines how often the shared variable
is ead. What happens if you set the Time Delay to ero? When
accessing global data you may read the value more than once before
itis updated toa new valve, or you may miss a new vale altogether,
depending on the value of the Time Del
4. Stop and close the Vis and the projet when you ate finished,
(Create functional global variable to handle he Stop data and use i inthe
Generate Data VI and the Read Data VI osha the stop button between the
two Vis,
End of Exercise 9-28. White the value ofthe Stop control tthe Stop shared variable.
|B Switch othe Project Explorer window.
Select the Stop shared variable and cag itinsie the While Loop of
te Read Data.vi block diagram
|. Right-click the Stop shared variable and select Access Made» Write
from the shorteut men.
|. Wire the Stop contol tothe Stop shure variable
9, Use the shared variable eror clusters to ensure the ard of operations
Refer to Figure 98 for assistance wiring this block diagram,
Figure ©-8. ead Data lock Diagram vith Shared Varbles
10, Save the VI
11. Close the block: diagram,
12. Save the projet,
2 macr nes cect os coe Eslesion usta
‘Ada vertical pointer side and wenameit ime Delay (m2)
1D. Change the range ofthe slide by entering 200 inthe top value
show,
|G. Right-click the slide and select Representations {32 from the
shorteut menu
Adda waveform chart and rename Date char’,
|. Change the x-seale and y-seale ranges and labels ofthe chart to the
values shown in Figure 9-6
|B. Adda stop button and hide the label
(Open the block diagram,
‘Create the Blok diagram shown in Figure 9. Labels are shown to
assist you.
oes nse
aaa Bf
Figure 9-7. Read Data lock Diagram wio Shares Variables
‘Read the data fom the Dats shared variable and display it onthe
‘waveform char.
Switch tothe Project Explorer window.
{Select the Data shared variable and dag inside the While Loop of
the Read Data VI block diagram,
Wire the output ofthe Data shared variable to the Data Chart
indicator.od variable and select Create»
GF Right-click the input ofthe Stop sha
(Constant from the shortcut menu to steate a False constant
Use the Operating tool to chang the constant to Fae if necessary
11, Use the shared variable erorelustrs to ensue the
Reet to Figure 95 for assistance wirn
rer of operations.
his block diagram,
|
| eggs
13, Close the block dia
Read Data VI
1. Open a blank VI
2. Save the Vlas Read
Create the
am, but leave the front pane! open
‘ont panel shown in Figure 96.
7
fo
CAI(6. Create the Block diagram shown in Figue 9-4. No implementation
instretions are piven. Labels are shown to assist you
Figure 0-4, Generate Data Block Diayram witout Variables
7. Save the VI
Write the data generated tothe Data shard variable
|B Select the Data shared variable from the Project Explorer window
and drag it inside the While Loop of he Generate Data VI block
sdigram,
|. Righttickthe shared variable and sect Access Mode>Writefrom
the shortcut men.
2. Wire the Sin(x output of the Sine Function to the Data shared
‘arable
9. Read the Stop shared variable to stop the While Loop.
Switch tothe Project Explorer window:
|G Select the Stop shared variable and dag it inside the While Loop of
leGenerate Data..vi block diagam.
|B Wire the Stop shared variable to the conditional terminal
10. tnitaize the Stop shared variable.
|B Switch tothe Project Explorer window.
Select the Stop shared variable and dag itt the left ofthe While
Loop of the Generace Data. block diagram.
Right-click he Stop shared variable and select Access Modes Write
from the shortcut men.4, Save the library.
|B. Rightelick the library and select Save from the shortcut menu
Save the library as Global Data. viibin the \
LABVIEW Core 1\Global Data cretory
‘3. Create the Data shred variable.
Switch to the Project Explorer window.
Right-click Global Data vib and select NewoVariable from the
shortcut ment
Give the new vail the following reopens
= Name: oa8a
~ Variable Type:Single process
~ Data Type: Double
Glick OK to close the Shared Variable Popenies dslg box.
Generate Data VI
1. Opena blank VI
2, Save the Vias Genezace Data.vi in he \LabVIEW
Core 1\Global Data directory
3, Add «numeric indicator tothe front patel window.
44, Name the Numerie Indicator Dat.
5. Switch to the block diagram of the VIExercise 9-2
Goal
Scenario
Implementation
Global Data Project
(Create a project containing multiple Vs tha share data using &
Single-process shared variable
‘Create a VI that generate a sine wave. Create a second VI that displays the
sine wave and allows the user to modify the ime between each acquisition
‘ofthe sine wave data, Use one stop button to top both Vis.
‘Two Vis and 1wo pieces of global data are necessary to implement the VI
‘+ Firs Vi: generate sin, write sine 19 Dats shared variable, read Stop
shared variable o stop loop
++ Second VI: read Data shared variable, display on chart, write Stop
‘button to Stop shared variable
+ Fist shared variable; Stop (Boolean datatype)
‘+ Second shared variable: Data (Numeric datatype)
‘Open an empty project.
Save the project as Global. Data. Lvpros inthe \
RSbVIEN Core 1\Global Data decor:
3. Create the Stop shared variable
_Rightetiek on My Computer and select New Variable
2. Give the variable he follwing properties.
~ Name: stop
= Variable Type: Single-process
~ Daa Type: Boolean
Click OK toclose he Shared Variable Properties dialog box. Notice
that # new brary is ereated in the Prject Explorer window to old
the variableTest
1, Run the VI
[G. Name the log fle when prompted.
|G Enter vale in the Upper Limit contro that is less than the value
in the Lower Limit contol. Does the VI behave as expected?
2, Stop the VI when you are finished
5. Close the VE andthe project,
End of Exercise 9-1
i tame canoe “ nen ca2. Expand the Bundle By Name function 1o to elements,
Select T Upper Limit inthe first element and 7 Lower Limit inthe
second element
a Adda False constant to the outer Case structure
|B Wire the case as shown in Figure 9:2
6. [the Upper Limit sequal or greater than the Lower Limit, pass the
‘ales ofthe controls to he temperature cluster, as shown in Figure 9-3,
Figure 98. Completed Range Check State—Fase
Switch tothe Fale case ofthe interior Case structure
Wire the Upper Limit and Lower Limit dat through the case
7. Save the VI.
8. Save the Project.aod ony es
44, Set the Range Check state to ranstion tothe Analysis sate,
1D Inthe Range Check case, wire the Next State enum othe
"Next State ouput tunnel
Change the Next State enum Analysis
5, Ifthe Upper Limit is less than the Lower Limit, use local variable to
‘write the Upper Limit value tothe Lower Limit control, as shown in
Figure 9.2.
Figure 82, Completed Range Crck Stato—True
> Add a Less? function to the Range Check sate
ol Add a Case structure to the right ofthe Less? function
Wire the Upper Limit and Lower Limit contol to the
‘Less? function and the Case structure as shown in Figure 9-2,
G Rightctck the Lower Limit contol and sleet CreatesLeal
‘Varlable fom the shorteut menu.
Move the local variable inside the Tive case ofthe Case structure
a Add a Bundle By Name function to-he right of the Case structure
Wire the Temperature Data clsterto the input cluster input ofthe
Bundle By Name function.3. Read the upper and lower limit controls in the Range Check sate,
instead of the Acquistion state s shonin Figure 9-1
Figure 8-1. Competed Acquistion tate
1D. On the block diagram ofthe Weather Station UI VI, select he
‘Acquisition casein the sate machine Case structure
| nse the Acquistion case, change the Next State enum to Range
‘Cheek.
1D. Make a copy ofthe Next State enumby pressing and
dragging a copy ouside the While Leop.
Move the Upper Limit and Lower Limit numeri controls ouside
the While Loop
Resize the Bundle by Name function to one element, a shown in
igure 9-1
°
Select the Range Check cas in the sate machine Case structure
1D. Move the Upper Limit and Lower Limit numeric cotels and the
[Next State enum into the Range Chesk state|B. Insert an item and modify to match Table 9-1 Be careful not ro ald
an emp listing
Table 8-4, States Erumertes Control
tem [ Digital Display
‘Acquisiion| oO
Range Check 1
Analysis z
Data Log Z
“Time Check 4
| Save and close the contol
the weather station Ur.vi isnot open, open it by
\duble-clcking the listing inthe Projet Explorer window.
Open the block diagram.
A. Riahttick the state machine Case structure and select Add Case
for Every Value from the shortcut menu, Because the enumerated
‘control has a new value, anew case appears in the Case structure.
su rans Cogan os anew cm aesans usta
Now State Definitions for Option 2
‘The following table describes the new state definitions 1 implement.
State Description Neat State
‘Acquisition | Acquire data from the | Range Check
temperature sensor 00
‘channel AIO and read
front pane! controls
Range Check | Read front panel controls | Analysis
and set the lower limit
equal to the upper limit if
‘upper limitless than the
lower init
Analysis Determine warning eve. | Data Log ifa warning
joveurs, Time Cheek i
ho warning occurs
Data Log ‘Log the data in a “Time Check
{ab-delimited ASCH fle
“Time Check | Check whether time is | Aequistion itime bas
sreaterthan or equal 9 | elapsed, Time Check if
S seconds time has not elapsed
Implementation
1. Ithevieather station. 1ypro3 isnotalieady open, open from the
-\LebVIEW Core 1\Variables directory.
Note 1¢ you do not have a data acquisition device and a DAQ Signal Accessory
available, use the files located inthe \LabYZEW Core 2\
No Hardware Required\variables directory.
2. Add the Range Check state the state machine.
2. From the Project Explorer window, open the Weather Station
states.ct1 by double-clicking the lting.Thisis he type-defined
‘enumeraied control that defines the sates forthe sate machine.
1D. Rightclick the control and select Bait Items from the shortcutDesign Options
You have thre diferent design options for odifying this projet.
‘Option Description Benefi/Drawbacks
| Inserra Case structure in| Poor desig: the acquisition
the Acquistion sate to | sat has another tsk added,
reset the controls before a | rather than focusing oaly on
Focal variable writes the | aqui
values to the cluster.
2 | Hasertanew state in the | Aniity to contol when the
state machine that checks | state occurs.
thecontrolsandresets them
it necessary.
3 | Modify the Determine | Fasy 1o implement because
‘WarmingssubVIto esetthe | functionality is alteady
contrls. peataly in place. However, if
‘current functionality is used,
‘oe st of data always i ost
wren reseting the lower lim
central.
‘This exercise implements Option 2 asa solution‘State Deseription Next State
Data Log | Log the dataina “Time Check
tab-delimited ASCH file
‘Time Check [Check whether time is | Acquisition if time has
‘greater than a equal to
seconds
lapsed, Time Cheek it
time has not elapsed
‘Changing the value of the lower temperature limit contol should happen
alter the use has entered the value but before the value determines the
Warning level. Therefore, make the modifications 10 the Vii the
Acquistion or Analysis state, or place a new state between the two,
‘of the Acquisition and Analysis states:
Before determining which option to se, ike a closer look at the content
Open the teacher Station projec located inthe
\LabVIEW Core 1\Wariables directory
1 OpenWoather station ur.vi
|G Review the contents ofthe Acquis
om and Analysis state, which
correspond to the Acquistion and Aralysis cases of the CaseUsing Variables
Exercise 9-1
Goal
Scenario
Local Variable VI
Use a local variable to write to and read fom a contol
‘You have @ LabVIEW Project that implemerts a temperature weather
station. The weather station acquires a temperature every half a second,
tnalyzes each temperature to determine i th temperature is (09 high or
too low, then alerts the user if there is danger ofa heat stroke or freze.
‘The VI logs the data if a warning occurs.
“Two front pane! controls determine the seipinis—the temperature upper
limit and the temperature lower limit. However, nothing prevents the user
from seting lowe limit that is higher than the upper limit
‘Use a local variable tose the lower Fimitequa tothe upper limi ifthe user
sets lower limit that i higher than the upper limit
“The Vis in this project have already been written. Your only task ito
rodify the Vis 0 that che lower limit is se equal to the upper limit when
State Definitions
The following table describes the states intestate machine.
State | _Deseription __ Nest State
‘Acquisiion | Settime w zero, acquire | Analysis
ata fromthe temperature
sensor, and read front panel
controls
‘Analysis | Determine warning level | Data Log ifa warming
‘occurs, Time Check if no
‘warming occursNotes1
soe GOs as nts
(Complete the Stop state shown in Figure 85.
Test
3
End of Exercise
fon sms cope
Figue 65. stop Sate
1D. Passa true constant to the conditiorl terminal; the state machine
sould op only from this tate,
Save the VI when you have finished.
‘Switch to the front pane! window.
Run the VI Experiment with the VI to hesue it works as expected. If it
does not, compare your block diagram to Figures 8.2 through 8-5,
‘Save and close the VI when you are finishedles conan sey heme ane
'5. Complete the Process | state shown in Figure B-3
Figure 6-3. Process 1 Sate
D. Use a One Button Dialog function 1 simulate the Process I code.
|. Wirea raise constant tothe conditional terminal the state machine
should not stop when exiting the Process I state
6. Complete te Process 2 state shown in Figure 8-4
Figure 6-4, Process 2Stt8
|B Use a One Button Dialog function tc simulate the Process? cove
© Wirea ase constanttothe conditional terminal; the state machine
should not slop when esting the Progess 2 sate|G. Wire the enum to the ease selector terminal of the Case structure
using & shift register on the While Loop.
Right-click the Casestructure and sect Add Case for Every Value
{automaticaly ada eae fr each tem in the enum.
2. Copy the enum to se within dhe Case structure, The copy is also
linked w the ype-defined enum,
Switch wo the Tle case ofthe Case stucture, and wire a Falee
constant othe conditional terminal: the sate machine should not
sop when exiting the Tle state
2 Inthe fe state, you convert the clustr to an aray so thatthe aay
‘canbe searched for any button clicked. The Search 1D Atray
fonction returns the index ofthe bution clicked. Because the Ile
Ste does not havea button associated with i this index must be
incremented by one,
Add an Index Array function tothe idle cas,
|B. Add an Array Constant to the Ile ease and move the copy ofthe
‘enum into the ara.
|. Expand the Array’to display four toms. Select different state foe
‘each item inthe following order as stown in Figure 8-2.
~ lle
= Process 1
= Process 2
= Swp
Ikis very imporant thatthe order of he cluster matches te order of
the items inthe enumerated constant.
[Complete the wiring for the Idle case as shown in Figure 8:2.Select OK to ext the Enum Properties dialog box
Relabel the enum contol State Exam.
a
a
Right-click the State Enum and ste AdvancedsCustomize
Selec Type Def rom the Control Type pulldown men.
©. Righcelick the Enum and select Representations U32
a
Save the control as State Enum. ctl in the \
LabVIEd Core 1\state Machine directory.
‘Close the Control Eitor window.
Click Yes when asked i you would lke to replace the contol
Switch to the block diagram.
qoco
Right-click the State Enam and select Change to Constant. The
‘enumerate conto! no longer appears on the Font panel window
Inthe following steps, you crete the block diagram shown in Figure 8-2
This block diagram contains four states—Tdle, Process 1, Process 2, and
Stop.
Figure 82. Ide site
44 Ceate the block diagram shown in Figure 8:2
|B. Place a Case structure inside « While Loop onthe block diagram
as shown in Figure 8:2socom ees aes
Change the Boolean text to Run Process 2
|B. Make acopy ofthe Process 1 button, and place the copy within the
cluster shell.
1D. Rename the copied button Process 2
Change the Boolean ext onthe copied bution to Run: Peacese 2
Right ctck each button and select Visible temssLabel to hide the
labels.
|B. Adda stop button to the cluster sel
Right-click the Stop buton and seles Visible HemssLabel to hide
the label
|G. Modify the Boolean text on the bulons using the Text Settings on
the tool
Suggested tex settings: 24 point bole Application Font
|G. Enlarge and arrange the buttons within the luster using the resizing
100 andthe following toolbar butions: Align Objects, Distribute
‘Objects, and Resize Objects
|B. Rightlick the border of the cluster and select Autosizing»Size 10
Fit.
|B. Rightelick the border of the cluster and select Visible Items»Label
thie the label
3. Create the type-defined enum to contol the state machine
|B. Ada an enum tothe font pane! window.
D. Righclick the enum and select Bit ems. Modify the lis as
follows:
ems Digital Display
Tale 0
Process 1 1
Process 2 2
stop 32. Stale Tanstons (Continued)
State ‘Action Next State
Process | ExecuteProcess2 | Idle State
code
Siop | Stopthe site | Stop State
sachine
Implementation
Inthe following steps, you will eeate the front panel window shown in
Figure 81.
‘State Machine Vi Fen Panel Window
1. Create a new project containing a blank VI
Select Empty Project from the Geaing Stated window
Select File»Save Project.
Name the project state machine. Ivprod inthe \
LabVIEW Core 1\State Machine directory
Select File»New VI
1 Swvethe new Vias State Machine. in the \,
LabVIEW Core 2\State Machine directory.
2. Create u menu cluster containing buttons or running process 1, rennin
process 2, and stopping the VI
Place a cluster shell onthe Front pan window:
Relabel the cluster Mens
| 2. Add a Cancel button tothe cluster stl
'D. Relabel the Cancel button Process 1.Common Design Techniques and
Patterns
Exercise 8-1 State Machine VI
Goal
Create a VI
5 implements a state machine using a type-deined enum,
Scenario
You must design a template fora user inerfice state machine, The state
‘machine must allow the usero activate Process | of Process in any order.
The state machine must also allow for expanson, because processes may be
added inthe future,
Design
Inputs and Outputs
Table #4. Inputs and Dtpus
Type Name Properties
ance! Buon Doolean Text Process 1
Cancel Buton|
Boolean Text Process 2
‘Stop Button ‘step =
State Transitions
Table £2, State Tanstions
State | __Action Next State
Tile | Polluserinterface | No button clicked: Tale state
| forselestion | Process Iclicked: Process: 1 5:
Process 2clcked: Process 2 5
Stop clicked: Stop Stace
| Process 1 | Execute Process | | Idle State
cutelesen? demny Mes anans
NotesNotes
Smee cect ” aor con4. Create controls and indicators foreach tem in the subVI
D Rightick the Current Temp input and select CreatesControl
from the shortcut men,
Right-click the Max Temp input anc select CreatesControl from
the shortout men.
. Righttick the Min Temp input and select CreatesControl from
the shorteut men.
© Righelick the Warning Text output and select CreatesIndicator
fom the shortcut ment
|G Right-click the Warning? output andseleet CreatesIndicator from
the shortcut menu,
‘Swite tothe fron pane!
Enter test values in Current Temp, Max Temp, and Min Temp.
Ran the VI
‘After you have finished testing, close the fst VI. You donot nee to save
the test VI
End of Exercise 7-1aoe? doo Me sone
Ber Eeror inthe constant
Confirm that you have completed the Bror case as shown in
Figure 7-4,
Figure 7-4, Error Case of Determine Warnings Vi
1 an errr enter the VI, the VI ouputs Ero: in Warning Test, and Thue in
Warning? and pases the error ou of the VI. If an eror doesnot enter the
Vi the VI operates as orginally designed,
10, Save and close the VE
Test
Use a blank VI to test the subVI
1, Open a blank VI
2. Open the block diagram.
53, Place the Determine Warnings subVT on te block diagram ofthe
lank VI by selecting the Select VI option on the Functions palette and
navigating to the \LabViEN Core 1\Deternine
Warnings directory,Lemon? tomy Mor Ate
9, Set the VI to execute if no error occurs, and not execute ian error
2. Surroune the block diagram code with a Case structure as showin
Figure 7-3. Leave the Waring Text and Warning? indictors outside
ofthe Case structure
‘Figure 7-3. No Error Case of Detunine Warnings VI
|G. Wire the error in contro othe case selector terminal
|. Contitm that the block diagram is inthe No Brror esse itis not,
‘witch tothe ease containing the code right-lick the Case
Structure and select Make this Case No Error from the shortut
|G. Wire the error cluster through the Case structure tothe error out
indiator as shown in Figure 7-3.
Switch othe Error case,
|. Wire the error cluster through the cate to the error out tunnel
Right-click the Warning? tunel and select Create»Constant from
the shorteut men.
Use the Operating tool 1 change the constant to Teue.
Right-click the Warning Text tunnel and select Create»Constant
from the shorteut menure 7-2. Sample Waring con
6 lk OK when you anise io cls te on Eto window
@ tT Dovblecck he sektion oho select existing apc. Pres thecelete>hey
Toe he rahi: Then, double ck te rectangle 1 sutoratsly ree
Ponder fori n
Q th Double cik ie Tet ol to modity fons. Yu can select Small Fonts to choose
fons sll than 9 pos in sie
@ To select ite Giyphs ab and iter he glyphs bythe keyword waxning. Then dag
waning sip oto yourieon
7, Save the VL
8, Swite tothe block diagram.son? owen Mer ape
3. Select a connector ane pattern forthe VI
Rightcick the connector pane in ke upper-right comer ofthe
‘window, select Patterns from the shortcut menu, and choose the
pattern shown at left.
44. Connect te inputs and outputs the connector as shown in Figure 7-1
[Tcennectons 2 ComenrPane
4. Connector Pane Gonecton for Beternine Warnings VI
1D. Using the wiring tool, click the uppec-efl terminal ofthe connector
pane,
1D Click the coresponding front pane control, Current Temp,
Notice that the connector pane terminal fils in with a color to match the
‘datatype of the contol connected tit
| Click the next terminal inthe connector pane.
D. Click the corresponding front panel contol, Max Temp,
Continue wiring the connector pane until all controls and indicators
are wired, and the Context Help window matches that shown in
Figure 7-1
5. Create an icon.
{D Right lick the icon and select Edit Icon, The Icon Editor window
opens.
|B. Use the tools inthe Ieon Editor windew to create an icon. Make the
eon as imple or as complex as you want, however, it should he
representative ofthe function ofthe VI. Figure 7-2 shows a simple
‘example of an ion for this VLDeveloping Modular Applications
Exercise 7-1
Scenario
Design
Implementation
Determine Warnings VI
‘Create the icon and connector pane for VIs0 that you can use the VL asa
subV
You have created a VI that determines a waning string based on the inputs
given, Create an icon and a connector pane 0 that you can use this VL asa
SubVL
‘The subV consis the following inputs and outputs:
Table 74. Detarmine Warnings Sut! Inputs and Outpets
[ Inputs Outputs
[caren Temp Warning Text |
|
Max Temp Warning?
Min Temp
Use the standard connector pane (o assure rom for future expansion. Add
‘ror clusters othe VI so tha the code runs there sno erro, bt doesnot
run if there i an error
1. Open the Determine Warnings VI in the \
iabVIEd Core 1\Deternine Warnings directory: You crested the
Determine Warnings VIin Exercise 4-1 and mosified it in Exercise 46
2. Add an emtor input cluster and an error output cluster othe VI
Add an Bevor
‘3D.etl to the font sane
Add an Error Out 3D.etl othe front panelsen sop siea6 sry ses
16, Explore the block diagram ofthe VL
To familiarize youself with he VF's fuetionality explore the block
iagram using the Context Help window.
Double-click the Read Waveform VI
2 Goto the block diagram ofthe Read Waveform VI. Notice that it
uses VISA functions to commonieate with the instrument.
17, Close the Vis and the NI Example Finder when you are finished
Do not save changes.
End of Exercise 6-4
Snes capo os anew coef caesore many es
Use Example Programs
1, Select Help»Find Examples to tart the NI Example Finder
2. Confirm that you are browsing according 0 task
3, Navigate to Hardware Input and OutpatsInstrument Drivers»
LabVIEW Plug and Play i the ask structure
4. Double-click National Instruments Instrument Simulator Acquire
‘Single Measurement(DMD.vi to open the example program, This VI
reads single measurement from the Insrument Simulator
5, Verify thatthe PWR and RDY LEDs are lt onthe NI Instrument
‘Simulator. This VI ean communicate with the instrument through stil
or GPIB,
{6 Select she communication type onthe VISA Resource Name conto
© fyouare using serial, selet the resource (COM or COM) thatthe
serial cable is connected to.
2 Ifyou ae using GPIB, select the dewsim VISA alias. You specified
the VISA alias for this GPIB instrument as devsimin Exercise 1-2.
7, Run the VL
8, Explore the block diagram ofthe VI. Dont save changes
9. Close he Vt
10, Return to the NI Example Find.
1
Double-click National Instruments Instrument Simulator Acquire
Waveform(Seope).vi to open the next example program This VI reads
Single waveform from the Instrument Simulator.
12, Select the same VISA Resource Name ycu selected in step 6
13, Run the VI
14, Choose a different Waveform Function.
15, Run the VI again,Exercise 6-4 Concept: NI Devsim VI
Goat
Description
ason6 sry ses
Install an instrument driver and explore the example programs that
‘accompany the instrument dive.
Install the instrument driver for the NI Instrument Simulator. After
installation, explore the Vis that the instrument driver provides andthe
‘example programs that are added tothe NI Example Finde.
Figure 6-6. Instrument Simulator
Install Instrument Driver
1. Exit LabVIEW,
[Navigate tothe \LabVTEY Core 1\instrument
‘river directory. This folder contains the LabVIEW Plug and Play
{instrument drivers forthe Instrument Simulator.
3. Rightlick the zip folder and follow the wizard to extract all the
files othe \Natioral inetrunents\
LabVIEW 2010\inste 1b directory.
Explore Instrument Driver
1. Stat LabVIEW,
2, Opens blank VI
3. 8
to the block diagram,
44. Navigate tothe National Instruments Instrument Simulator category
ofthe Functions palete
5. Explore the palette using the Context Help window to familiarize
yourself with the functionality.5. Set edge to Rising
6. Savethe VI
7. Run the VI Press and release the Digital Trigger button onthe
DDAQ Signal Accesscey or turn the Quadrature Encoder knob on the
[BNC-2120 counterclockwise then clockwise to begin the acquisition,
End of Exercise 6-3Delete the tsk wire and error wire connecting the DAQmax Timing
Vi andthe DAQms Stat Task V
Place a DAQms Trigger VILon the block diagram between the
DAQms Timing VI and DAQmx Stat Task VL
Click the DAQax Trigger VI pull-dewn menu and select Start»
Digital Edge
Right-click the souree input ofthe DAQms Trigger VI and selec
Create»Contral
Right-click the edge input of the DAQms Trigger VI and sles
Create»Controt
‘Connect the wire as shown in Figure 6-4
= =|
7 | za
Fire 6-5, Trigger Al Acquistion I Front Pane
are using the DAQ Signal
Dev/PFIO
are using the BNC
Aces
to Devi1D. Press to open the Context Help window. Hover over each
ofthe DAQm functions to learn about each function. Read the steps
Iisted inthe comment to understand th functionality ofthe example
rogram,
|B Glick the pulldown menu ofthe DAQms Create Channel VI and
notice that its set to Amalog Input»Voltage
6, Setthe default values and settings on the front pane
Set Physical Change! 19 Deval
Set Minimum Value to 1.
Set Maximum Value to +1,
|G. Enable autoscalng of the y-axis ofthe waveform graph by’
right-ticking the Waveform Graph and selecting ¥ Seale»
‘AutaScale ¥,
7. Run the VI. The VI should begin acquiring data continuously. Use the
Frequency Adjust knob and the Frequency Range switch to change the
frequency ofthe function generator on th: DAQ Signal Accessory oF
BNC-2120 o change the acquired signal,
‘Add Triggering tothe Example Program
1. Save the Vias cExereises>\LabVIEW Core 1\Triggerea
analog Input\trigger AI acquisition.vi.
2. Modify the block diagram as shown in Figure 6-4 to add wiggcring
Functionality.Exercise 6-3
Goal
Scenario
Implementation
FZ Note The UP/DN terminal on the BNC-
Using DAQmx
Explore a DAQms example program that continuously acquires data, and
‘modify it to wait ona digital tigger.
Explore a DAQms example program that coxtinuously aequies a voltage
signal on channel analog input I (AI1) ofthe DAQ device. Modify the VI
tousea digital trigger. The VI begins measuring when a digital tigger is
pressed and released. The VI stops measuring when the user lis the stop
baton,
External Connections
1. Ifyou are using the DAQ Signal Accessory, connect the sine Function
generator to channet AI with a wire
2. Ifyou are using the BNC-2120, connec the Sine/Triangle output om the
function generator to channel AI I with aBNC cable, and make sure the
ssvteh on the function generatrissetto the sine wave. Also, ensue that
there isa wite connecting the UPIDN serw terminal the PFL 1 serew
terminal in the Timing 10 section
20 outputs high o low signal indicating
the rotation dretion of the Quadrature Encoder knob. When you ote the Quadrature
Encoder knob clockwise, the UP/DN terminal outputs high signal. When you rotate the
(Quadrature Encoder knob counterclockwise the UP/DN terminal outputs low signal
Open and run a DAGmx example
1. In LabVIEW, select Help»Find Exampks to start the NI Example
Finder.
‘Confirm that you are browsing acconing to task
3, Navigale to Hardware Input and OutpstsDAQms Analog
Measurements»Voltge in the task structure
4, Double-click Cont AcqSGraph Voltage-Int Clk.vi to open the
‘example program. This VI demonstrates how to acquire a continuous
mount of data from a DAQ device
5. Explore the block diagram.
Goto the block diagram.9.
Stop the loop if an error occurs ori the user turns of the Power switch,
1D. Delete the wire connecting the Power Boolean contro othe
‘conditional terminal
Right-click the conditional terminal and sclect Stop If True.
Add a Compound Arithmetic functon next the conditional
terminal,
= Right-ick the Compound Arithmetic function and select
‘Change ModesOR.
= Rightclick the lower left input termi
‘Arithmetic function and select Invert,
3 ofthe Compound
~ Wire the Power control othe lover left input terminal ofthe
‘Compound Arithmetic funtion,
2. Add an Unbundle By Name functio 1 the While Loop.
| Wire the conditional terminal as shown in Figure 6-3.
Close the ile and handle any eros that may have occured
Add a Close File function wo the righ ofthe While Loop.
Add a Simple Error Handler VI tothe right ofthe Close
Function,
Finish wiring the block diagram as sown in Figure 6-3
Swe the VL
Test the VL
© Run the Vi
Give the ext file a ame and loca
Turn he Power switch to Of after the VI has been unig for afew
samples.
2. Navigate tothe text file created and explore it
Close the VI and textile when you have finished,
End of Exercise 6-2esa Agog sre
Inthe steps below, you modify the block diagram similar to that shown in
Figure 6-3,
Figure 6-3. Temperature Log W Block Diagram
2, Resize the While Loop to add room forte file MO functions.
3, Create fle or replace an existing file fr the data lo,
Add an Open/Create/Reptace File function othe left ofthe
ft While Loop.
|G Rightclick the operation input of the Open/Create/Replace File
funeton, and select Create»Constant
Select replace oF ereate inthe enumerated constant that appears.
44. Write the temperature data to
cach piece of data,
le, adding an End of Line constant 0
|G. Adda Number to Fractional String funtion inside the While
Loop.
‘Ada an End of Line constant inside the While Loop.
‘Ade a Coneatenate Strings function inside the While Loop.
cog
‘Add a Write o Text File function itside the While Loop.
|G. Wire the inputs ofthe Write to Text File function as shown in
Figure 6-3,Exercise 6-2 Temperature Log VI
Goal
Modify a VIto create an ASCII ile using dik streaming.
Description
‘You have been given a VI tht pls the cureat temperature andthe average
‘ofthe last three temperatures. Modify the VIto log the curent temperature
toan ASCH file
Implementation
1. Open the VI you create in Exercise 45. Ifyou have hardware, follow
‘the insrctions inthe Hardware Installed columa, Otherwise, follow
‘the instructions inthe No Hardware Insalled column,
Hardware Installed No Hardware Install
‘Open Temperature multiplot.viin | Open Temperature muleiploe.viin
the \LabVIEv core 1\ | the «Exercises» \LabVIEN Core 1\
‘Temperature miltiplee directory No Hardware Sequired\ Temperature
maltiplot directory.
Select File»Save As and rename the VI Select File»Save As and rename the VI
as Temperature Log.vi inthe as Temperature Log.vi inthe
‘kxerciges>\LabVIEW Core 1\ ‘SBxereises>\LabVIEW Core 1\
Temperature Log directory. No Hardware Required\tenperature
og directoryThe Writ To Spread! File VI format 2D ary into a pense
Fe] tingand wrest sing a le Te sng bs fling format,
isc anamow idee sah andapargap sabe Dean
Thorne chance.
sox ce
=CJ-Lh
‘he Number To Fastin Sting finn cmon aay of ere
EB] Vabertoan anny of stings tnt leds,
'5. Close the VI Do not save changes
BZ Note This example stores only three arays in te file. Toinclude more arrays, increase
‘the number of inputs to the Build Array function
6. Open the wave. txt fil sing a word processor, spreadsheet
application, or text editor and view is coatens.
12. Open a word processor, spreadsheet epplicaton, or text eto,
such as Notepad or WordPad,
2. Open wave. tact. The sine waveform data appear in the
Fist column, the random waveform data appear in the
second column, and the cosine waveform data appear inthe
third column,
7. Exitthe word processor or spreadsheet application and return 10
LabVIEW,
End of Exercise 6-13. When the Choose fle to write dialog hos appears, save the fle
aswenve. txt i the \LaiVIEW Core 1\
spreadsheet Example directory and lick the OK button.
Later, you will examine this file.
4. Display and examine the block diagram for this VL
e-— ar
=" = mo gC
Figure 6-2. Spreadsheet Example VI Block Diagram
“The Sine Patera VI retums a numeric array of 128 elements containing a
sine pater, The constant 900 in the second instanceof the Sine Pain
Vi. specifies the pase ofthe sine pater which generates the cosine pattem.
‘The Uniform White Noise VI returns a numeric aay of 128 elements
containing a nose pattern
‘The Build Array function builds the following 2D array from the Sine array,
noise array, and cosine aay.
Sine Array
Noise Acray
Cosine Array
‘The Transpose 2D Array function rearrangesthe elements ofthe 2D array
so-element (4,5] becomes clement (3, £), 1 follows.
snc6
Managing Resources
Exercise 6-1
Goal
Description
Concept: Spreadsheet Example VI
fe 2D aray intext file soa spreadsheet application can access the fe
16 explore how o display numeri data in 2 table
‘Complete the following steps to examine VI that saves numeric arays to
file in foemat you can access with a spreadsheet,
ct Example VI located in the <
Jadshect Exanp=directory. The following
Figure 6-1. Spreasneet Example I Front Pane
2. Run the VI.
“The VI generates a 2D array of 128 rows» 3 columns. The fist column
contains data for a sine waveform the second column contains data for 8
noise waveform, andthe third column contains dala for a eoxine waveform,
The VI pte each column ina graph and disolay the data in a ableean aay on
Notesions sing oe
[Close the Control Faitor window.
D. Notice that resizing the type de conto in the Control Editar did not
‘update the size ofthe Type Def Numeric contol onthe VI front
panel, Instances of atype def control will only upite when the data
type ofthe type definition changes
'8. Add ancter instanceof the custom contol tothe from pane! window
‘and disconnect it from the type definition.
Choose Select a Control from the Controls palette
© Select the Type Def munaric.ctl from the \
LabVIEW Core 1\type Definition directory.
Click OK.
{Right-click the new contro! and sees Disconneet from Type Def.
from the shortcut menu
Glick OK.
{Right-click the contol agin and notice that you can now change the
Representation because the numeric sno longer linked 1 the type
definition
9. Close the VI when you are finished. You do not need to save the VI
End of Exercise 5-3D Close the Control Faitor window:
1D. Click Yes when asked if you would Bke to replace the original
conta
Explore the type defined custom numeri
D Rightclick the Type Def Numeric contro! and select Properties
from the shortcut menu. Notice that more items ate available,
such as Data Entry and Display Format,
Click Cancel io exit the Properties dialog box.
Right-click the Type Def Numerie contol again. Notice that,
[Representation is dimmed on the storeut menu because the type
‘efnition defines the datatype. Also notice that you can choose
‘whether to auto-update with the type definition.
Edit te type def contol
D. Rightclick the Type Def Numerie control and select Open Type
Def. from the shorten emt,
. Righ-click the Type Def Numerie contol and select
[Representation»DBL. from the shortcut ment inthe Control Editor
window,
Select FilesSave,
Close the Contol Editor window.
Select Help»Show Context Help to cpen the Context Help window.
ooog
Hover your mouse over the Type Def Numerie contol on the VI
and notice that it changed from a U32 numerie datatype toa DEL.
meric datatype.
Right-click the Type Def Numeric control and select Open Type
Dee. rom the shortcut mens,
Change the physical appearance ofthe numeri contol by resizing
itn the Control Editor window.
Select File»Save.4
eons ye
Edit the stit type def conto
Rightick the Strict Type Def Numeric control and select Open
‘Type Def. fom te shortcut ment,
Right-click the numeric contol and select Representation»DBL
from the shortcut menu in the Conte Editor window:
Select FilesSave
Close the Contr Eitor window
‘Slee Help»Show Context Help o open the Context Help window.
coog
Hover your mouse over the contol on the VI and notice that it
‘changed from a U32 numeri data type toa DBL. numeric datatype.
a
Right-click the Stit Type Def Numeric contol and sleet Open
‘Type Def. from the shorteut menu
{Change the physical appearance of tHe numeric contol by resizing
‘tin the Control Editor window.
© Select FilesSave,
D. Close the Control Eater window:
{Notice that etting the strict type def control updates the size ofthe
‘numeric control on the VI oat pane
5. Create custom control with a type éefisition stats,
1 Addanother numeric eontrolio the Font panel window and rename
itastype Def Muneric,
|G Right-click the contol and select Advanced»Customize from the
shortcut menu to open the Control Eater.
|G Select ype Def. from the Control Type pulldown menu,
Right-click the mumeric contol and select Representation
‘Unsigned Long from the shortut menu,
Select FilesSave.
Name the control type Def mtunoric.ct1 inthe \
LabVIRM Core 1\Type Definition directoryExercise 5-3
Goal
Concept: Type Definition
Explore the differences between a type defnton and strict type definition.
Description
1
(Open a blank VI
Create eustom contro with a strict type definition status
Add a numeric control othe front ane window and rename its
Strict Type Def Muneric.
F. Right-cick the contol and select AdvancedsCustomize from the
shortcut menu to open the Control Editor
Select Striet Type Det rom the Control Type pull-down menu,
© Rightelick the numeric control and select Representation»
Unsigned Long from the shorteut menu,
Select FilesSave,
Name the control strict type Def ttunsric.ct1 inthe
‘sExercigee>\LabVIEW Core 1\type Definition directory,
2 Close the Control Editor window.
Click Yes when asked if you would Lke to replace the orginal
contol.
Explore the strictly defined custom numeric.
©. Righi-elick the Striet Type Def Numeric control and select
Properties from the shorteut menu. Noses that he only options
available are Appearance, Documentation, and Key Navigation.
All other properties ae defined hy the sre ype definition,
F.Click Cancel exit the Propertics dig box.
Right-click the Striet Type Def Numerie control again. Notice that,
representation is not avalable onthe shortcut men, Also noice that
‘you can open the type definition or dSconneet from the type
Sefton.esos try
20, Enter diferent values in Cluster and notice how values entered in
(Cluster affect the Modified Cluster and Small Cluster indicators. s this
the behavior you expected?
21, Click the Stop botton when you ae done
22, Change the cluster onder of Modified Caster Run the VI. How did the
‘changed order affect the behavior?
28, Close the VI, Do not save changes
End of Exercise 5-2sae tn
16.
1,
18.
19.
Wire the Numeric output of the Untundle By Name Function othe
input ofthe Increment funetion, This Function adds one to the value
‘of Numer,
B_Ada a Not function othe block diagram,
Wire the Boolean 1 output ofthe Unbundle By Name function othe
‘input of the Not funtion This function retums the logical opposite
‘ofthe value of Boolean,
[Add a Bundle by Name function tothe block diagram.
‘Wire Cluster tothe input cluster inp.
oog
Resize this function to have two inp terminals,
o
Select Numeric in the first node and Boolean I in the second node.
a label mame i no ertect, use the Operating tool 0 select the
|D. Wire the output ofthe Sncrement Function 19 Numer.
Wire the output ofthe Not function to Boolean 1.
|O Wire the outpu ofthe Bundle By Name function tothe Modified
Cluster indicator
Ada wait function to provide the processor with time to complete other
asks.
{D_Add a Wait Und! Next ms Multiple function tothe block diagram,
| Rightclck the millisecond multiple terminal of the Wait Uns
Next ms Multiple furetion,
| Select Create»Constant from the shortcut menu
Enter 100 inthe constant.
Complete the block diagram and wire the objects a shown in
Figure 59,
Save the VL
Display the front panel,
Run the VLim ©
Inthe Following steps build the block digrem shown in Figure 5-9.
Figure 5-9, Cute Expriment Blak Diagram
11. Adda While Loop ftom the Structures atete tothe block disgram.
12. Disassemble Cluster.
Adan Unbundle function tothe bck diagram.
|G Wire Cluster to the input ofthe Unbndle Function to resize the
function automatically
13, Assemble Small Custer.
© Adda Bundle function othe block diagram.
{© Wire he Bundle function as shown in Figure 5:9.
14, Assemble Modified Cluster.
G.Add.an Unbundle by Name functos othe Bock diagram.
Wire the Cluster tothe Unbunle by Name funtion,
Resize the Unbundle by Name funeion to huve so output
terminals
. Sotoct Numeric inthe fist noe, und Boolean 1 in the second node
Ta label name is not cormst use the Operating tol to seeet the
Add an Increment function tothe block diagram.laser paige
10, Verify the cluser order of Cluster, Modified Cluster, and Small
Cluster,
Right-click the houndary of Cluster and select Reorder Controls
Jn Cluster from the shorteut men
2 Confirm the cluster order shown in gure 5-8
2. Click the Confirm button on the oolsa tose the cluster order and
exit the cluster onde edit mode.
1D. Righe-click the boundary of Modified Cluster and select Reorder
‘Controls in Cluster from the shortest men
| Confirm the cluster orders shown in Figure 5-8. Modified Cluster
sould have the same cliste order as Cluster.
|B Click the Confirm button on the wothar ose the cluster order and
exit the cluster onder edit mode,
|B. Right-click the boundary of Small Custer and select Reorder
‘Controls in Cluster from the shorcit men
Click the Confirm button on the toolbar to Sethe cluster order and
eit the cluster order edit mode
2 Contirm the cluster orders shown in Figure 5.8.
Figure 5-8, Custer gers1. Create acluster named Cluster, containing 8 numeric, to togsle
switches, and slide
Add a eluster shell wo the eon paneh
‘Add 4 numerie contro othe cluster.
a
D.Ade two vertical toga switehes tothe cluster.
a
Rename the Boolean toggle switches to Boolean 1 and
|G. Add a horizontal il side to the clus.
8. Create Modified Cluster, containing the same contents as Cluster,
but indicators instead of cones
Create «copy of Cluster.
. Relabel the copy Hodi fied Cluster
Right-click the shell of Modified Caster, and select Change to
Indicator from the shorteut men.
9. Create Small Cluster, containing a Boolean indicator and numeric
indicator.
Create a copy of Modified Cluster.
Rolabel the copy small. cluster,
itch
Delete the second toggles
Delete the horizontal fil slide indiator.
Right-click Small Cluster and select Autosizing»Size to Fit
Rolabel the numeric indicator to 624e vatue
oecaca
Resize the cluster as needed.aren an
Exercise 5-2 Concept: Clusters
Goal
‘Create clusters onthe front panel window, reorder clusters, and use the
luster functions to assemble and disassemble clusters,
Description
In this exerise follow the instructions o experiment with clusters, luster
‘ote, and cls fnetons. The VI you creat has no practical app
buts useful for understanding cluster concepts
1. Opena blank VI.
2. Save the VIas cluster Experiment. vi in the \
LabVIEW Core 1\clusters directory.
‘In the following step, you create a front pans similar to Figure 5-7
Figure §-7. Cluster Experiment VI Front Pane
3, Add stop button to the front pane window.
44 Ada mumerie indicator tothe font pars window
5. Add round LED tothe frat pane
6. Renane the LED Boolean 2|G. Enter inthe constant to retrieve the second column because the
index begins at zero.
D Rightclick the subarray cutput of the Index Array function an
select Createstndieator.
Name the indicator Second Columns
6, Savethe VL
1. Suite tothe front panel
8, Enter values for Rows and Columns.
9, Run the VL
10. Close the VL
End of Exercise 5-1Inthe following steps, you build a block diagram similar to that shown in
Figure 5,
Figure 66. ArayInvesigaion Par $V lock Diagram
44. Retrieve the third row of data from Array using the Index Array
function
Add an Index Array function tothe block diagram.
|D. Wire Array to the array input ofthe Index Array function,
Q Th The Index Array function accepts an n-dimensional array. Afler you wire the input
aztay tthe Index Array unctin, he input and output txmial names change © match
thedlmension of the aray’‘wied. Therefore, wie the int aay to the Index Array
funetion before wiring any eer erminal
Right-click the index(row) input of tie Index Array function and
seleet Create»Constant from the shortcut menu.
|G Enter 2 inthe constant o retrieve the third row, Remember thatthe
index begins a ero.
. Rightetick the subarray output of te Index Array function and
select CreatesTndicator Irom te sort menu:
QName the indicator tira Rex
5. Retrieve the second column of data fom the Array sing the Indes
Array function.
el {Ada another Index Array function tthe block diagram.
|B. Wire Array to the array input ofthe Index Array function.
© Rightelick he disabled index(col input ofthe Index Array
function and select Create»Constant5. Rightelick the border of the remaining For Loop and select Remove
For Loop from the shortcut menu. Your Hoek diagram should resemble
Figure 55.
Figure 5-5. Atay Investigation Par 2V Block Diagram
6, Savethe VI
7. Switeh to the foot panel
8. Enter values for Rows and Columns.
8. Run the VL
Notice thatthe VI behaves the same as the solution for Pat 1, This is
beeuse mathematical functions ate polymorphic. Fo example, because the
input of the Multiply function isa two-dimensional array. andthe y inpot
{Scalar the Multiply function multiplies each element inthe amy by the
sear, and outputs an array ofthe same dimension asthe x input
Part 3: Implementation
“Modify Array Investigation VIso thatthe VI ereates anew aay that
‘contains the contents of the third row, and arother new array that contains
the contents ofthe second eoluma,
1, Open array Investigation.vi lected inthe \
LabVIEW Core i\anipulating Arrays directory
Swethe Vas Array Investigation part 3.vi
3. Open the block diagram ofthe VILaser mig Os
(6. Multiply each element ofthe aay by HO.
{D.Add a Multiply function co the interior For Loop.
2. Wire the indexed input tne! to the xinputof the Multiply function
Right-click the y input and sleet Create»Constant from the
shortcut ment.
Enter 100 in the constant,
7. Roun each element tothe nearest whole number
Add a Round To Nearest function tthe sight of the Multiply
function.
Wire the output of the Mulkiply Function tothe input ofthe Round
‘To Nearest fonction.
8. Crestoa2D aray onthe output ofthe ForLoops toreereate the modified
aray.
| Wire the output ofthe Round To Nearest function to the outer For
Loop. This creates an auto-indexed output tunnel on both For Loops.
9, Wire the output anay tothe Intensity Graph indicator.
10. Switch to he fom pone
11, Save the VL.
12. Enter values for Rows nd Columns
13, Run the VI
Part 2: Implementation
Modify Part Ito accomplish the same goals without using the nested
For Loops
1. Openasray Investigation Part =.vi ifitisnotsill open
2, Savethe Vas Array Investigation Part 2.vi
3. Open the block diagram.
4, Right-click the border ofthe interior For oop, containing the Mutiply
function and the Round to Nearest function, and select Remove For
Loop.Papa
rs a ed
Tat te oe me [oan fas oe
|
4, Open the block dis
Figure 5-4, Ara Investigation Par 1 Vi Block Diagram
5. erate the Array
Adda For Loop tothe right ofthe exis
Adda second Far Loop inside the fest For Loop,
Wire he Array terminal othe interior For Loop border: This creates
a autos indexed input tunnel on both Foe Loopssand iyo
‘This exercise is divided into three pars, You are given he scenario for each
pa fit. Refer the end of this exercise for detailed implementation
instructions for each par
Part 1: Iterate, Modity, and Graph Array
“Modify the Aray Investigation VIsothat afer the ary is created, the aera
is indexed into For Loops where you mulipl each element ofthe array by
10 and coerce each element tothe nearest whole umber. Graph the
resulting 2D arayto an intensity graph
Part 2: Simplified iterate, Modify, anc Graph Array
“Modify the Atray Investigation VI othe soliton from Part | to accomplish
the sume goals without using the nested For oops.
Part 3: Create Subset Arrays
“Modify the Array Investigation VI so that the VI creates anew array’ that
‘contains the contents ofthe third row, and anober new array that contains
the contents of the second column,
Part 1: Implementation
‘Modify the Array Investigation VI so that after the arayiserested, the aay
is indexed into For Loops where you multiply each clement ofthe aay by
100 and coerce each element tothe nearest whole number Graph the
resulting 2D aray onan intensity graph
1, Openarray tavestigation. vi locaed in the \
EabVIEY Core 1\Manipulating Arrays directory
Save the Vlas array Tnveetigation Part 1.vl.
3, Add an intensity graph tothe from panel ofthe VI and autoscae the
X and Y axes, as shown in Figure $-3.Te verify that auoscaling is
teniled for the axes, right-click the intensity graph and select X Seale»
‘AutoSeale X and Y Seale» utoScale Vand ensure these items are
checked.Relating Data
Exercise 5-1 Concept: Manipulating Arrays
Goal
“Manipulate arrays using various LabVIEW functions.
Description
You ate given a VI and asked to enhance it for a variety of purposes. For
cach part of this exereise, begin with the Arcay Invest igation.vi
loca inthe \LaLVIEH Cove 1\Manipulatiog
-xrrays directory. The ron panel of this Vis shown in Figure 5-1
Figure 5-1. Array Investigation Vi Front Panel
Figure 5-2 shows the block diagram ofthis VL
Figure 5-2. Array Investigation VI Block Diagramtrast gong
Notesson inna
Figure 4-30. False se for When a Wind Waring is Generated
‘5. Save the VI
Test
1. Test the following values to be sure your VI works as expected.
Table 4-7. Weather Test Values
‘Name Test ‘Test? Test Toit | Tots ‘Tet
Curent Temp [20 ” 10 30, 0 20
Max Temp — [25 35 35 5 3 35
Min Temp [15 15 5 1S 8 1s
arent Wind | 25 Fy = 3 S
Speed
Max Wind [30 0 3 » 30 »
Speed
Waring Text | NoWaming | Heastoke | Frese Heasiote | Freeze and | High Wind
Warning — | Warning | and High | eh Wins | Waring
Wind Warning
Waring
Worning? —_| Fase Tne Te Tue Tew “Te
2. Close and save the VI when you ae finished,
End of Exercise 4-9re 427. Tue Cases for When Tempsature and Wind Wamings
‘Are Not Genecatad
Figure 4.29, False Cases for When Wind and Temperture Warnings Are Generated
are Copan ane ce Eelueiea yg sue B0—| UEUEEG “ge-p amyBvoo
soe gay
‘A portion ofthis VE us already been built for you. The font panel ofthe VI
is shown in Figure 4-25. This ront panel reeves values from the user
forthe curren temperature, the maximum temperature, the minimum
{emperatue, the current wind speed, and the maximum wind speed and
displays to the user the warning string and the warning LED. The Weather
Staton project i this course does not use ths VI
Figure 4.25. Determine More Warings Front Panel
1, Openthe Determine More arnings.vi inthe \
TSbVIEN Core I\Determine Hore Warnings directory.
(Create a block diagram similar to Figure 4-26
2 Open the block diagram.
13. Use Figures 4-26 through 4-30 to assis ou in building the block.
diagram code.
4. You we the following block diagram obpts inthis exercise:
Case sac
Empty String constant
Space constant
2 qual? fonction.
F Concatenate Strings Feneton.
fa sna ogra oo ave esseease amma 2
‘The modified fowchar shown in Figure 4-2 determines the High Wind
‘Warning in addition tothe warnings already determined
Figure 4.26, Determine More Waning Vi Flowcnart
Vi Architecture
‘There ae many ways to write this VI Tn thisexerise, you use Case
‘rctures to determine what string to pass, and the Concatenate Strings
function to merge strings together.aor opemtga
Flowchart
‘The flovichart shown in Figure 4-23 is used forthe Determine Warnings VI
‘This VI doos not ake wind data. Modify this flowchart 1o determine the
High Wind Waming os wel.
\
LABVIEW Core 1\Daternine Warnings Chal Lange directory.
[you need assistance, open the solution VI. Te solution i located inthe
\ZabViEN Core l\Exercise 4-8 diectory
End of Exercise 4-8econ rntgs
Exercise 4-8 Self-Study: Determine Warnings VI (Challenge)
Goal
‘Modify an existing VI to use the Formula Ned or a Case structure to make
1 software decision,
Scenario
In the Determine Warnings V1 from Exercise
function to passa string based on a decision. Revise this block diagram t0|
use Case structures to complete the same purpose.
Design
Inputs and Outputs
Table 4-5. Determine Warnings Viinputs and Outputs
‘Type Name Properties
Numeric Controt | current temp | Double-precision,
- floating-point
Numeric Controt | Max Temp Double-precision,
Aoating-point
Numeric Control | win temp Double-precision,
floating-point
String Indicator | warning Text | Four potential values:
Heatstroke Warning,
No Warning, Freeze
‘Waring, or Upper
LimiteLower Limit
‘Round LED warning? =Test
A
Caution Do nor ron tis VI cont
running this VI could result in an endless lop.
1. Display the fet panel
2. Entera positive number inthe Number contr
3. Runthe VL
44. Enter a negative number in the Number contol
ously, Under certain circumstances, continuously
5. Run the VL
If Number is positive, the VI executes the Tre ease and returns
the square root of Number If Number isnegative the VI executes
the False case, retns -99998, and displays a dialog box with
the mesuge Ezror-.-Megative umber.
6. Close the VI
End of Exercise 4-7mon penis
Right-click the numeric constant ard select Representations
DBL.
Enter -99999 in the numeric constant
‘Wire the numeric constant to te right edge of the Case structure,
Wire the new tunnel to the Square Root Value indicator
cece
‘Add a One Button Dialog function t the False case. Tis function
displays a dialog hox that comains a message you specify
o
Righiclick the message input of the One Button Dialog Function
and select Create»Constant from the shortcut ment,
G Bmtersrror...megative mumber inthe constant
2. Finish wiring the False case as shown in Figure 4-20,
6, If Number is greater than or equal to 0, ealculae the square rot of the
‘umber.
Select the True case ofthe Case srt,
Place a Square Root function inthe True ease. This function returns
io the square root of Number
2. Wire the funetion as shown in Figure 4-21.
Figure 4-21. Teve Case of Sware Rot VI
7. Save the VIas square Root vi in the cixercises>\LabVIEHt
Core 1\Square Root directory.Implementation
(Open blank VI and build he front panel shown in Figure 4-19.
Paes
Figure 4-19. Square Root Font Pane!
‘Adda numeric control othe front pand window.
Name the numeric contol tunber.
{Ad «numeric indicator othe fron pane window
©. Rename the numeric indicator square Root Value
id the block diagram show i Figure 4-20.
o
Figure 4-20, Square Root VI 3leck Diagram
Determine whether Numbers greater than cr equal 7210, Because you
‘cannot cae the square rot of @ negative number
Add a Greater or Equal to 0? function othe right of the Number
contol. Tis function tums Prue if Number is greater than oF
equal 100,
|G Wire Number tothe input ofthe Greater or Equal wo 0° function
tNumber is less than O, display a dialog box that informs the user ofthe
Ada the Case structure tothe block diagram.
ick the deerement or increment huson to select the False case.
Ada numeric constant tothe Pals caseExercise 4-7 Self-Study: Square Root VI
Goal
(Create a VI that uses a Case structure to make a software decision
Scenario
Create a VI that calculates the square rot ofa number thease enters
I the numbers negative, display the follow ng message to the user:
Error. .tlegative Munber
Design
Inputs and Outputs
Table 4-4. Inputs and Dutpus
‘Tye Name [ Properties
TInpu Manber Double precision, floating
point: default value of 25)
ating
‘Output ‘Square Root Value Double preci
point
Flowchart
Figure 4-18, Square Root I owchartem gone
Test
1. Switeh tothe front pane ofthe VI
2. Resize the Warning Test indicator to length o secommodate the new
string
[3 ‘Test the VL by entering values from Table 43 for Current Temp,
‘Max Temp, and Min Temp, and running the V1 foreach st of data.
“Tule 4-3 shows the expected Warning Tex and Watning? Boolean
‘value for each set of dala
Table 43, Testing Valves for Determine Warings Vi
Current Temp | Max Temp | Min Temp Warning Text Warning?
30 30 10 |Hesestroke Warning | True
a 30 10 | Mo Warning False
0 30 10 | Freeze warning ‘Tie
25 20 30 | Upper Limie < tower | True
Line
4, Save and close the VL
End of Exercise 4-6ane moans 8
5. IfMin Temp is less than Max Temp, execute the code that determines
the warning string and indicator.
While the True case is visible right-click the border ofthe Case
structure, and select Make This Case False from the shorteut menu.
‘When you create a Case structure around existing code, the code is
sutomatealy placed inthe True ease
(6. If Min Temp is greater than Max Temp, rete a custom string for
the Warning Text indicalor and set the Warning? indicator to Prue,
as shown in Figure 417,
ee
Figure 417, Determine Warnings Block Diagram
Select the True case
Right-click the string ouput tunnel
Select Create»Constant
Enterpper binit < Lower Lainie inthe constant
Righielick the Warning? ouypu tunnel
ccocaog
Select Create-Constant,
Use the Operating tool to change the constant to a Prue constant
1. Save the VLsoe gon
2. Creat space onthe Hock diagram oa he Case soc
‘The Max Temp and Min Temp contol and ihe Waring Text and
‘Warnng? inca soul be oui ft new Cesc,
teeaue to cseo te Cae snctreus tee inet snd
cons
2 Selet the Min Temp and Max Teap conto termi
@ te Toseleetmore han on tem pres th key wl you sls the tems.
|G. While the terminals are stil selected, use the lft artow key onthe
keyboard to move the controls tothe et,
@ Ww Press and bot te Adda Greater? function othe boot divgram
@ Wire the Min Temp outpt to the x iput of the Greater? fection
Wire the Max Temp output othe input ofthe Greater? Function.
o
[Adda Case structure around the block diagram code, except forthe
‘clude terminals,
a
‘Wire the output of the Greater function wo the case selector ofthe
Case structure,‘The criginal block diagram forthe Determice Warnings VI appears in
Figure 4-15. This VI must have a Case structure added o execute the code
if the maximum temperature is greater thin or equal t the mnimam
temperature. Otherwise the code wll not execute. Instead, anew string is
‘generated and the Warning? indicator is set True.
Figure 415, Detemie Warring: Vi Black Diagram
Implementation
‘Complete the following steps to modify the Mock diagram similar to that
shown in Figure 4-16. This VI is part ofthe temperature weather sation
project.
igure 4-16. Determine Warnings Vi Black Diagram
1, Open the Determine Wamings VI in the <2xexeiaea>\
LADVIEN Core 1\Deterine iarnings directory, You created
the Determine Warnings VI in Exercise 41
Open the block diagram.Exercise 4-6
Scenario
es oem
Determine Warnings VI
Modify VI tose a Case tracts to make software decision,
‘You created VI where a user inputs a temperature, a maximum
‘temperature, and a minimum temperature. A warning string generates
‘depending on the relationship of the given iputs. However, a situation
‘bd occur that causes the VI 10 work inconecty. The wer could enter &
‘maximum temperature thats fess than the minimum remperatre, Modify
the VI to generate a diferent string to alert the user tothe enor: Upper
Limit < Lower Limit, Set the Warning” indicator to True to indicate
the err
“Modify the owchart created forthe original Determine Warnings VI as
shown in Figure 4-14.
a oo
Ganon one 5H g| Nowe
Sr alse
-
wen tar
Figure 414, Moat Determne Warnings Rowchartsen igen
Test
1, Run the VI. Use the tos inthe seule legend andthe graph palette to
examin the data. a it generates.
(Change the Power switch tothe OFT postion 1 sop the VI
3. Close the VI when you are finished,
End of Exercise 4-5Inthe following steps, modify the front panel similar tothe one shown in
Figure 413,
hee oe
Figure 4-18, Temperature Mutt Vi Front Panel
4. Open the front panel
5. Show both pls inthe plo legend ofthe waveform chart
© Use the Positioning tol to resize the plot legend to two objects
‘sing the top middle resizing node
© Rename the op plot Running ave
Rename the bottom plot Curent. Temp
Change the plot type of Current Temp Use the Operating Wolo
select te plot inthe plot legend and choose the plas you wan
1 isthe same asthe order of the items
Q Tw Theonderof the pots listed nthe pot
‘ed ote Bundle faction on the bce diagram
6, ‘Show the see legend and graph palette ofthe waveform char.
Right-click the Temperature History waveform chart and select
Visible Items»Seale Legend from tke shortet menu,
Right-click the Temperature History waveform chart und select
Visible ItemseGraplh Palette from the shortcut mon
Seve the VLInthe following steps, you modify the bloc diagram so that it resembles
Figure 4-12. Modity the block diagram first then madi te font panel
ra a engenaeioy
Figure 412, Temperature Mutipt Vi Block Diagram
2. Open the block diagram.
3. Pass the current temperature and the average temperature tothe
“Temperature History chant terminal.
[Delete the wire connecting the Dita function othe Temperature
History char terminal
D.Adé a Bundle function between the Divide Function and the
“Temperature History chan indiatoe. I necessary enlarge the While
Loop to make space,
2. Wire the ouput ofthe Divide Funetioe to the top input ofthe Bundle
function.
Wire the Temperature output of the Thermometer subVI inside the
While Loop to the botiom input ofthe Bundle Function. The
‘Temperature outputs the curenterrperature.
Wire the ouput ofthe Bundle function othe Temperature History
chart indicator.Implementation
ane ag 0
ag
a Gas
Figure 4-11. Avrane Tempratr i Block Diagram
1. Open the Average Temperature VI youcreated in Exercise 44. you
have hardware, follow te instructions inthe Hardware Installed
column, Otherwise, follow the insrctions in the No Hardware
Installed colom,
Hardware Installed
[No Hardware Installed
‘Open Average Temperature VIin the
‘efxerciges>\LabVIEW Core 2\
Average Tenperature directory.
‘Open Average Temperature VI inthe
‘cExerciges> \LabVIEW Core 1\
No Hardvere Requized\average
Temperature directory.
‘Seleot Flle»Save As and rename the VI
‘Temperature Muitiplot.vi in the
\LAabVIEN Core 1),
‘Temperature Muitiplet directory.
‘Select FilesSave As and rename the VI
Temperature Yultiplot vi inthe
‘key while you click the Thermometer VI and drag
itoutside the While Loop to create copy of the UbVI.
‘The Thermometer VI retuns one temperature measurement from
the temperature sensor and initializes the lft shift registers before
the loop starts.
2 Place a Compound Arithmetic function onthe block diagram.
~ Configare this function to return the sum of the eurent
temperature andthe four previous temperature readings
~ Use the Positioning tol to resize-he Compound Arithmetic
function 1 have five eft terminals
D Place a Divide function on the block diagram. This function returns
the average ofthe last five temperatur: readings.
|B. Wire the functions together as shown in Figure 49,Implementation
1. ‘Test the VI Ifyou have hardware, follow the instructions in the
Hardvare Installed colima, Otherwise, follow te instructions in
the No Hardware Installed column.
Hardware Installed [No Hardware Installed
‘Open the Temperature Monitor Vin the
‘eBxercises® \LabVIEW Core 1\
Average Tenperature directory
‘Open Temperature Monitor (Demo) Vin
the \LabvIEW core 1\
No Hardware 2equired\average
‘renperacure directory.
Select FilesSave As and selec Copy>
‘Substitute copy for original. Click Continue
and name the Viaverage
‘Tenperature.vi inthe ata
Figure 8 Auto Mach VI Block Dagram
10. Generate a random number integer between 0 and 1000.
a Add» Random Number (0-1) function to the block diagram,
‘The Random Number (0-1) function generates a random number
between O and I
> Adda Multiply function othe block diagram. The Multiply
function molipies the random number by the y input to produce
‘random number between O and y
Q Wirethe oipot ofthe Random Number function tothe xinput of the
‘Maliply Function.
|B. Rightelick they input ofthe Mukiply function, select Create»
‘Constant from the shortcut menu, ener 1900, and press the
- key o create a numeric consant
i Add a Round To Nearest function tthe block diagram. This
function rounds the random number tn the nearest integer
2 Wire the output ofthe Multiply function tothe input ofthe Roun
‘To Nearest function.
O. Wire the output of the Round To Nearest function to the Current
‘Number indicator.Set the Maximum value to .000 and select Coeree from the
Response to value outside limits pull-down menu,
Sette Increment value 102 and select Coeree to Nearest from the
Response to value outside limits pull-down menu.
1D. Select he Display Format tab,
Select Floating Point and change Precision Type ftom Signifiant
‘igs to Digits of precision,
Enter o in the Digits textbox and click the OK button
66, Create the Curent Number ourput
Add numeric indicator to the from panel window.
1D. Label the indicator current. Mamber.
2. Sette digits of precision fr the Current Number output 00,
. Righ-click the Current Number indicator and select Display
Format frm the shortcut men. The Display Format page ofthe
[Numeric Properties dialog box appears
Select Floating Point and change Precision Type wo Digits of
precision,
{Enter 0 inthe Digits text box and click the OK baton.
8. Create the # of iterations ouput
Place a numeric indicator onthe front panel
Label the indicator # of Lterations
9. Setthe representation for he # of iterations output to along integer.
1 Righttick the #of iterations indir,
G_Slect Representations132 fom the shoneut menusor gangs
Implementation
Complete the following steps to build the fent panel shown in Figure 4-5.
Figure 45. Auto Watch ViFront Pane
1, Open a blank VI.
2. Save the Vias Auto Match.vi in the Gxereisas>\
LABVIRN Core 1\auto Match directory.
‘3. Crete the Namber to Match input
A. Add a numeric contro othe front panel window:
Gl Label the control umber to Maen.
4. Sethe default value forthe Number to Nach control.
Set ihe Number to Match conto 05.
|B Rightetick the Number to Mateh ccntol and select Data
Operations» Make Current Value Default.
5, Setthe properties forthe Number to Match contro so that the data range
Js from 00 1000, he inerement value is 1, and the digits of precision
#80,
|G Right-click dhe Number to Match conto! and select Data Entry
from the shortcut menu, The Data Enty page ofthe Numeric,
Properties dialog box appears
2. Disable the Use Default Limits checkhox.
| Ser the Minimum value o 0 and selest Coeree from the Response
to value outside limits pull-down mena.Flowchart
sory 0
"ano — Shae oe) Re
ogtecee
ae
Figure 4-4. Auto Match lowchart,Exercise 4-2 Auto Match VI
Use a While Loop and an iteration terminal and pas data through a tunnel
Scenario
(Create a VI that continuously generates random numbers between 0 and
1000 until it generates a rurmber that matchesa number selected by the usr.
Determine how many random numbers the VI generated before the
‘matching number.
Table 42, Inputs and utpus
Type Name Properties
Input Nanber co Maren | Double-precision,
Aoating- point between O and
1€00, coerce to nearest whole
umber, default value = 50
Oupat [current wunber | Double-precision,
Aeating-point
Ouiput—[#of reerations | Inepersoe aoe
Wire the No Warning string constant tothe y input ofthe
‘Not Equal? funeton.
Wire the outpat of the Not Equal? funtion to the Warning?
indicat.
15, Document the code usin the following suggestions onthe front pane.
|. Create tip strips for each control andindieator stating the purpose
‘and units ofthe object. To acess tip stip, right-click an object, and
Select Description and
2. Document the VI Properties, giving general description of the VI,
alist of inputs and outputs, your am a the date the VI was
created. To access the VI Properties dialog bo, select File»
VI Properties.
2 Document the block diagram algorithm with fee label.
16, Save the VI
Test
1, Test the VI by entering a value for Current Temp, Max Temp, and
‘Min Temp, and running the VI for each st.
“Table 41 shows the expected Waring Tet string and
‘Warning? Boolean value foreach set of input values.
Table 4-1. Testing Valves for Determine Warnings Vi
Current Temp [ Max Temp | MinTemp | WarningText | Warning?
30 30 10 Tre
25 30 10 Fake
10 30 10 Tre
“What happens if you input 8 Max Temp value that is less than the Min
“Temp? What would you expect to happea? You Tea to handle issues
like this one in Exercise 4-6.
2. Save and close the VL
End of Exercise 4-1Laser oot 8
f&
[D. Ada a string constant tothe block diagram tothe upp lef ofthe
Select function.
© Enter eatseroke warning inthe string constant
A Wire the Heatstroke Warning string to thet inpt ofthe Select
function.
|B. Hold down the key and click and drag the Heatstroke
‘Warning string constant othe lowe! left ofthe Select function to
create a copy ofthe constant
1D. Enternio Warning in the second sing constant
Wire the No Warning string to the input of the Select funetion.
Ifthe Current Temp is equal to o ess than the Min Temp, generate
Freeze Marning string, olherwise use the string generated in te IL.
2. Create a copy ofthe Seleet function nd place it wo the right of the
Less Or Equal? function.
{D. Wire the outpt of the Less Or Equal? function othe s input ofthe
Select function.
Create acopy ofthe string constant and place it tothe upper let of
the Select funtion,
Emer Freeze warning in the string constant
Wire the Freeze Warming string othe input of the Selec function.
O. Wire the output of the previous Selec: function tothe Fiat of the
now Selec function
Display the generated text
2. Wire the outpu of the second Select function tothe Warning Text
indicator.
‘Generate the output tothe Waring? Booean inicator by determining
ifthe value of Warning Text is equal fo Mo Warning.
Add a Not Equal? fonction tothe lef ofthe Washing? Boolean
indicator
|. Wire the output ofthe second Select function tothe x input of the
Not Equal? funetion,ne igo 0
‘Complete the following instructions to crete a block diagram similar to
Figure 43.
Figure 4-3. Determine Warnings VI Block Diagram
9, Compare current Temp and Max Texp.
Add « Greater Or Equal? function othe block diagram.
|. Wire the Current Temp conto to hex input of the Greater Or
Equal? funetion
|. Wire the Man Temp control tothe yinput of the Greater Or Equal?
function.
10, Compare Curent Temp and in Texp.
Addl Less Or Equal? function wo the block diagram.
Wire the Current Temp contol othe xinputof the Less Or Equal?
funtion
|G Wire the Min Temp contol tothe yinpu of the Less Or Equal?
function.
11 the Curent Temp is equal to or greater than the Max Temp, generate
aueatatroke Warning sirng, otherwise generale ano Warning
string.
Adda Select function to he block diagram tothe right ofthe Greater
(Or Equal? function.
|G. Wire the outpar of the Greater Or Equal? function tothe input of
the Select function,rae 8
8
(Create @ numeric control forthe maximum temperature
Hold down the key and click and drag the Current Temp,
ume conto 1p creates copy ofthe contol
2. Change the label ex ofthe now numeric contol to wax ‘Temp.
Create @ numeric control forthe minimum temperatre
Hold down the key and click and drag the Max Temp
rhumerie conto 0 creates copy ofthe contol
Change the label text ofthe new numeric contol to wim Temp.
Creat a string indicator forthe warning ex
Add string indicator to the front pane! window
Chang te label txt of the sing indicstorto Warning ex
(Create a Round LED or other Boolean indicator forthe warning
Boolean,
Add a Round LED 1o the front panel window.
©. Change the label text ofthe Boolean indicator to Warning?
‘Switch to the block digram,
Tip_If you do not want to view terminals as icons on te block diagram, select Tools»
Options, then select Block Diagram from the Category lt. Remove the checkmark
‘rom the Place front panel terminals as ieons ites.soe tng
Implementation
‘Complete the following steps to create a front pane similar to Figure 4-2.
‘The user enters the current temperature, maximum temperature, nd
‘minima temperature, Then the Font panel display the warning string and
‘the warming Boolean LED. This Vis par of te temperature weather station
project studied throughout the course.
1, Open a blank VI and ereate the following from panel
Figure 4-2. Oetrmine Warnings VI Fron Panel
2 Save the new VI
Select FilesSave,
© Save the Vias petermine Warnings. in the \
EARVIEY Core 1\Determine Warnings directory.
3. Create a numeric conto fr the current temperature
Add a numeric control 1 the font panel window.
O. Change the label ofthe numeric contol to current. Temp,
|B Right-click the control, select Representation, and confirm that the
representation type is set to double precision.
@ to TisswbvT old be wed for Fabre, Kelvin oray er tenperaue see
tonal inpas ue he ame sn, Tents nse Wadd see uns
tote besi .
| ih oe
jie {| Ls
eat | iImplementing a VI
Exercise 4-1 Determine Warnings VI
‘You must ereate a portion ofa larger project. The lead developer gives you
the inputs ofthe VI. the algorithm, and the expected outputs. Create and
Goal
‘Create and document a simple VL
Scenario
‘documenta VI based on the given design,
Design
Inputs and Outputs
Type Name Properties
Numeric control | Carrent Tene | Double-precision,
a floating-point
Numericconiol | Max Temp Dauble precision
Aoating-point
Numeric contol (im Teme Double-precision,
foatng-point
‘Taree potential values:
Heatstroke Waring,
No Warning, and
Freeze Waning
Round LED indicator | Warning?eon 3 rasa an Opp
Notesusin anette
NotesDisplay the Debug Exercise (Main) VI block diagram by clicking it
AA green glyph appears on the subVIiconon the Debug Exercise
(Main) VI block diagram, indicating that the subVI is running,
{Display the Debug Exercise (Sub) V: block diagram by clicking i
Click the Step Out button tice to finish sngle-stepping through the
‘subVI block diagram, The Debug Exercise (Main) Viblock diagram
|B Click the Step Out buton to stop single-stepring
11, Use a probe to check imermediate values on a wire as a VI rus.
From he Tok te. st he Pae alo
2] i.
{D. Use the Probe tool wo click any wire. The Probe Watch Window
appears.
“The Probe Watch Window displays al probes in ll Viscurrently in
memory. This window sors the probes in the order you crete them
And ist he probes under the VI they belong to
Single-sep through the VI again. The Probe Watch Window
Aispays data passed along the wie
12, Place breakpoints on the block diagram (> pause execution at that
location,
|B. Use the Breakpoint too! w click nodes or wits. Place a breakpoint
‘on the block diagram to pause execution uf all nodes on the Block
diagram execute,
Click the Run button to run the VI. When you reach breakpoint
during execution, the VI pauses andthe Pause button on the toolbar
appears te.
Ww |G Click the Continue button to continue running tothe next,
breakpoint or until the VI finishes urning.
A. Use the Breakpoint ool to click the Weakpoins you set and
remove them.
15. Click the Highlight Execution bution to ssale execution highlighting
14, Select FllesCtoseo cose te VI and allapen windows
End of Exercise 3-2ean oa
{D. Click the Help button to display a topic in the LabVIEW Help that,
series the error in detail and icles step-by-step instructions
for comecting the eror.
Click the Show Error bution or double-click the err description 10
highlight the aca onthe block diagram that contains the erro,
1D. Use the Eror list window to fix each error.
Select FilesSave to sve the VI.
Display the ont panel hy licking itor by selecting Window»Show
Front Panel,
(Click the Run button
Select WindowsShow Block Diagram io display the block diagram.
Animate the flow of data through the bleck diagram.
D.Click the Highlight Execution button on the toolbar to enable
execution highlighting,
Click the Step Into bution to start single-sepping. Execution
highlighting Shows the flow of data en the Block diagram from
‘ne node to another using bubbles tht move along the wires
"Nodes blink to indicate they ae ready 1 execute.
Click he Step Over button after eachnode to step through the entre
block diagram, Each time you click the Step Over button the
‘current node executes and pauses atthe next node
| Data appear onthe front panel as you step through the VI The VI
‘generates «random number and muhiplesit by 10.0. The subVI
‘adds 100 0 an calculates the square rot of the result,
|G. When blinking border surrounds theentire block diagram, click the
‘Step Out button to sop single-stepping through the Debug Exereise
(Main) VI
Single-step through the VI and its subVL
Click the Step Into bution o start single-stepping,
| When the Debug Exercise (Su) VI blinks, click the Step Into
‘utton. Notice the Run buton onthe subVIenone Dna te
2. Display and examine the block diagram of Debug Exercise (Main) VI
Select Window»Show Block Diagram to display the block diagram
shown in Figure 3-2.
aniontber mea Resi
Figure 3-2. Debug Exercise (Maly) Block Diagram
~The Random Number (0-1) function produces random number
between Dand 1
= The Multiply function moliplies the random aumber by 10.0.
The numeric constants the number multiplied with the random
number
~The Debug Exercise (Sub) VI, located inthe \
LabVIEW Core 1\pebugging\Supporting Files
rectory, adds 100.0 and calculates the square root ofthe value
3. Cleanup the messy section ofthe block diagram to make the Block
iagram more readable
Click and drag your mouse cursortoseletthe Debug Exercise (Sub)
Vand the function, constant, and inceator tothe right of the VI
Click the Clean Up Seleetion butonon the toolbar,
4, Find and fix each error
|B Click the broken Rum button to display the Error list window, which
list all the errors
Select an error description inthe Ero ist window. The Details
‘ection describes the eror and in sore cases recommends how to
correct the erreee as Dos
Exercise 3-2 Concept: Debugging
Goal
Use the debugging tots built into LabVIEW,
Description
‘Complete the following steps to load a broken VI and correct the eros.
Use single-stepping and execution highlighting to step through the VI
1. Open and examine the Debug Exercise (Main) VL
Select FilesOpen,
Open Debug Exercise (Hain) vi inthe \
LabVIEW Core 1\Debugging directory
“The front panel showin in Figure 3-1 appears.
ogee =a
Be oops Seer Te Teo
feouiee Le
8-1. Debug Exercise (Main Front Pane
a |G Notice dhe Run button on the toolbar appears broken indicating that
the VI is broken and cannot run,sen erty tgp
2. Place your mouse cursor over the Simulated frequency conto
{D.Notice that the to! tp that appears matches the text youtyped inthe
Tip field of the Description and Tip dialog box.
D Click the Stop bution,
LabVIEW Help
6, Use the LabVIEW Help to learn more information about the Filter
Express VI
1. Select WindowsShow Block Diagram i open the block diagram
ofthe Express Filter Vi
Right-click the Filter Express VI and seloet Help from the shortcut,
‘menu. Thisopens the LabVIEW Helptopic for the Filter Express VI
BB wee Tosco the LabVIEW Hep fortis, you can aio slat te Detaled Help
Takin he Conte Help window while th Fie Expres VI ected orci he
Question ma inthe Conon Help window:
D.Explore the topic. For example, what isthe purpose of the
Cato Frequency (Hz) dialog box opion?
Close the LabVIEW Help window.
7. Close the Expres Filter VI when you finish, Do not save changes.
End of Exercise 3-1a
tase Matson an ube
‘Anchor the Context Help window so that you can move your mouse
‘without the contents ofthe window changing. Toe Context Help window
should show information about the Simulate Signal Express VI
|G Move your mouseover the Simulate Signal Express VI
|G Toanchor the context help window, select the Leck button inthe
lower left corner ofthe window.
@ tw Ate conten ofthe window change tefoe you lak the window, vid passing
eurmouse over oe jects nthe wa othe Context lp window, Move te window
tert the object of meres 1 ew Cones lp for ate
|G Move your mouse over another objet. Notice the contents ofthe
window do not change while the Lock button is selected.
|G Deselect the Lack button o resume normal operation ofthe window
Modify the Description and Tip associated with the Simulated
frequency contralto change the content shown inthe Context Help
window.
Select Window»Show Front Panel 0 open the front panel of
the VL
“Move your mouse over the Simulated frequency coat
ao
Read the contents of the Context Help window.
Right-click the Simulated frequency contol
Select Description and Tip from the shortcut menu,
coo
Replace the text inthe "Simulated frequency” Deseription box
withthe ext: This 2 the deseription of the control.
C
Replace the text inthe "Simulated frequency”
lexi This is the tip for the control.
ip box with the
lick the OK bation.
‘Move your mouse over the Simulated frequency contr.
co
[Notice thatthe contents of the Context Help window changed t0
‘match te ext you typed inthe Deseiption field ofthe Description
and Tip dialog box.
© Ron the Visor faa oa
Enter express in the Enter keyword) field to find Vis that
contain Express Vs
|. Double-lick the Express result that appears inthe Double-click
keywords) fel
. Thiskeywordisassoeated with manyexample Vis as demonstrated
by the number of Vis returmed. You can selet any one ofthese VIs
and read the description in the Lnformation text box.
|. Doubte-tick Express Filter 10 open it
Context Help Window
3. Use the Context Help window co learn about the Express Vis used in
the Express Filter VI
Open the block diagram by selecting WindowsShow Block
Diagram,
|B. Open the Context Help window by selecting Help»Show Context
Help,
|. Move the Contest Help window toa convenient area where the
window does not hide part ofthe block diagram.
Place your mouse cursor over the Simaate Signal Express VI. The
‘Context Help window content changes show information about
the object that your mouse is over.
Move your mouse over another Expres VI. Node the Context Help
‘window content changes correspondirg othe location ofthe mouse
|B. Move your mouse over one ofthe Tore Measurements Express VI
Examine the configuration details inthe Context Help window. This
ives you the information about how the Express VI is configured,
© Double-click the Tone Measurements Express VI to opea the
configuration dialog box. Notice that-he selections inthe
«configuration dialog box match the information inthe Context Help
‘window.
|D. Glick the OK bution to close the configuration dilog box.Troubleshooting and Debugging Vis
Exercise 3-1 Concept: Using Help
Goal
‘Become familiar with using the Context Help window, the LabVIEW Hep,
tnd the NI Example Findet.
Description
This exercise consists ofa series of tasks designed to help you become
familie with the LabVIEW Help tools.
NI Example Finder
1. You have a DAQ device in your computer, and you wantto learn how (0
communicate wit it using LabVIEW. Use the NI Example Finder to
finda Vi that communicates with a DAQ devi
Open LabVIEW
_Sclost Helps Find Examples to open the NI Example Finder
Confirm tat he Task option i selected on the Browse tah
DDovbleclick the Hardware Inpat and Output folder
Select DAQm» Analog Measurements»Voltage
ooaoca
Select Aeq®Graph Voltage-Int Clk. Notice thata description of
the VI is povided in he Information ex box so tha You can verity
‘hat this VI meets your needs
1 Double-lick Aeq&Graph Voltage-Int CIk.v 0 open the VI
Chose the VI after you finish exploreg it
‘You want to learn more abou using Express VIs tite signals. Use the
NI Example Finder to Find an appropriate VL
The NI Example Finder should stil be open from the previous step
not, open the NI Example Finder.
Click the Seareh tab in the NI Example Findersso 2 soa ase
Noteseso? pg ane
Notes
i met ren oa ave ce eeTest
1. Switch to the front panel window ofthe I
Set the graph properties to beable to view the sine wave,
© Right-cick the waveform graph and select X SealerAutoseale X10
disable autoscaling,
|G Righttck the waveform graph and sleet Visible ems»
X Scrollbar to enable the X scale.
{2 Use the labeling too to change the las number on the X Seale of the
waveform graph © 1
3. Save the VL
4. Runthe Vi
|G Click the Rum button on the fron par! tool.
‘The graph indicator should display’ a sine wave and the Average Value
indicator should display «umber around zero. If the VI doesnot run as
expected, review the implementation steps.
5, Close he VI.
End of Exercise 2-5sor? App
|B. Glick the mouse button to star the wie
Place the mouse cursor over the Sigma input ofthe Statistics
Express VI and click the mouse button to end the wire
12, Wire the data the graph indicator
1 Place the mouse cursor over the data output wire ofthe DAQ
Assistant (or te Sine ousp ofthe Simulate Signal Express VI)
at the location where the cursor chanzes to the Wiring tol
[D. Click the mouse bution to star the wie
Place the mouse cursor over the Waveform Graph indicator and
click the mouse button to end the wi
13, Wire the Arithmetie Mean output of the Statsties Express VIt0 the
Average Value numeric indicator
Place the mouse cunor over the Arithmetic Mean cutput of the
Slatisties Express VI at the location where the cursor changes to the
Wiring oo.
{D. Click the mouse button to star the we.
1D. Place the mouse cursor over the Average Value numeric indicator
and click the mouse buon end the wire
14, Wite the data output othe Signals inputof the Write Measurement File
Express VI
1 Place the mouse cursor over the data outpt wire ofthe DAQ
‘Assistant or the Sine output ofthe Simulate Signal Express VI)
atthe location where the cursor chanzes to the Wiring tol
Click the mouse baton to star the wie
F. Place the mouse cursor over the Signals input ofthe Write
“Measurement File Express VI and click the mouse bution tend the
BZ Wate Future exercises do not detail the directions for wiring between objects.
15, Save the VI19. Determine the average value ofthe data acquired by using the Statistics
Express VL
the Function plete is not already open, select View»Functions
Palette from the LabVIEW menu
[© Collapse the Input palewe by selecting Express onthe Functions
pale.
1D Select the Signal Analysis pale
1D. Select the Statisties Express VI and ald the Statistics Express Ito
the block diagram tothe right ofthe DAQ Assistant.
Wit forthe Sais Express VI disdog box 1 pen
{2 Enable the Arithmetie mean checktox.
1 Gck the OK buon,
10. Log the generated sine data toa LabVIEW Measurement Fie
Sele Express onthe Functions pate
Select he Output category
Select Write to Measurement File.
a
|Add the Write to Measurement Fil Express VI othe block
diagram below the Statistics Express VI
| Wait forthe Write to Measurement File Express VI dialog box to
open,
Leave all settings as default,
D Glick the O button,
Bots For execs donot el he restos fer ting pce fons or
foe spake as spacer can bee rau gal aed tans
fictots and consi
1H Wie the dat from the DAQ Assistant (or Simulate Signal Express VI)
to the Statistics Express VL
Place the mouse cursor over the daa ousput of the DAQ Assistant
(the Sine ouspu of the Simulate Signal Express VI atthe location
‘where the cursor changes tothe Wiring toosoe? mono VEN
18. Acquire sine wave for 0.1 seconds. Ifyou have hardware installed,
follow the instructions inthe Hardware Installed columa to acquire the
data using the DAQ Assistant If you do nt have hardware insalled,
follow the instructions inthe No Hardware Installed column to
simulate the acquis
tion using the Simulate Signal Express VI
Hardware Installed [No Hardware Installed
1. Onthe Functions plete, selet the 1. On the Functions palette, sleet the
Express category Express caezory
2. Select Input from the Express category. | 2. Select Input from the Express category
3, Seleetthe DAQ Assistant from the Input | 3. Selec Simulate Signal from the Input
category category.
4 Place the DAQ Assistant on the Block | 4. Place the Simulate Signal Express VI on|
iagram. the block aigram,
‘5, Wait forthe DAQ Assistant dialog box | 5, Walt for the Simulate Signal dialog box
vo open toopen,
6, Select Acquire Signals»Analog Input» | 6. Select Sine for the signal type
Voltage forthe measurement type,
7, Select ail (analog input channel 1 for | 7. Set the signa frequency 0 100.
the physical channel
‘8 Click the Finish buon. ‘8 To the Timing section, set the Samples
per second (Hz) t0 1000,
9, Inthe Timing Settings section, select | 9. Inthe Timing section, deselect
1N Samples as the Acquisition Mode. Automatic for the Number of samples.
10, In the Timing Seuings section enter 100. | 10. tn the Timing section, set the Number
in Samples To Read. cof samples to 100.
11, Bnter 2000 in Rate (Hz). 11, Select the Simulate acquisition timing
selection
12, Clik the OK button, 12, Click the OK button.
g
Tip Reading 100 samples a
tc of 1,000 He retrieves 0.1 seconds worth of data.1D Select the Numeric Indicators category from within the Express
category
2 Select the Numeric Indicator.
|. Place the indicator on the font pane
Enter average value in the late of the numeric indicator.
Tn the following steps, you build a block diagram similar tothe one i
Figure 2-10,
Figure 210, Acquire, Analyze, and Present Block Diagram
77. Open the block diagram of the VI
Select Window»Show Block Diagram,
FZ Nlote The terminals coresponding o the new front panel window objects appear on the
block diagram,Inthe folow
Swe the Vias Simple ARP. vi,
Select FilesSave.
Navigate wo the
Name the VI sim
8 Click OK.
steps, you wil build a front panel window similar tothe one
in Figure 2-9,
Figure 2-9, Acquire, Analy and Present Font Pane Window
Adda wavelorm graph to the fron panel window to dsplay'the acquired
ata,
1 ViewsControls
Ir the Controls plete isnot already open se
Palette from the LabVIEW mens,
On the Controls pate, select the Express ca
Select the Graph Indicators category fom within the Express
Sclet the Waveform Graph
Add the graph tothe front panel window
Aad « numeri indicator tothe front panel window to display the
average vale
Collapse the Graph Indicators categeny by selecting Express onthe
Controls pletesno? Atv
0 Sigs
ooo
HE :
ee0n9eses0009
pecesccen
—
Figure 28. Connection ore BNC-2120
2 Open LabVIEW,
3. Opens blank VI.Implementation
ason? apy
Prepare your hardware to generate a sine wave, Ifyou ae no using
hardware, skip o step 2.
Find the DAQ Signal Accessory or BNC-2120 and visually confirm
that itis connected tothe DAQ devie in your computer.
Using a wire of BNC cable, connect ne Analog In Channel | to the
‘Sine Function Generator, % shown is Figure 2-7 or Figure 2-8
Sette Frequency Range (Selection) switch andthe Frequency
Adjust kool to their lowest levels.
“waa
2 Be
OM
l=
f
2
=
i
3
}
i
e ott Font
E 999
nD a)
Ube Sen NRE |
Figure 2-7. Connection forthe DAD Sigal AccessoryProgram Architecture—Quiz Answers
1
Acquire: Use the DAQ Assistant to aequre the sine wave from the data
scquisition device.
Analyze: Use the Statistics Express VIo determine the average value
‘ofthe sine wave. Because this signal is eclical, you could also use the
Cycle Average option in the Amplitude and Level Measurements
[Express VI to determine the average vale of the sine wave.
Present: Use the Write to Measurement File Express VI log the data
tnd use the Waveform Graph to display the data on the front pane
‘window.lemon? en a
3, Present: Citcle the Express Vis andor indicators that ae best suited to
\,
LABVIEW Core 1\Dataflow directory
BB tate ttyouar opening he exe rom win LabVIEW, let ATFs fom
the Fes or ype op down men,
2, Follow the instructions given. This simulstion demonstrates dataflow.
End of Exercise 2-49, Wire the Number of Measurements ternina othe count terminal of
the For Loop using the Wiring 100
|G. Move the cursor othe Number of Measurements terminal
2 |B. Move the cursor tothe right ofthe te-minal, stopping when the
‘cursor changes toa wiring spool, as shown atl
Click to star the wite
1D. Move the cursor tothe count (N) ferrinal of the For Loop,
a
©. Glick the coun terminal to end the wie.
a 10. Click the Run burton to run the VL
“The time required to excout this VI is equivalent to Number of|
“Measurements times Delay (See), When the VI s finished executing
the daa is displayed on the Temperature Graph.
11. Try moving other objects, deleting wires and rewiring them, and wiring
‘objects and wires together until you are comforable with using these
took.
12, Selet File»Close o close the VI and click the Don't save ~ A button.
You do not need to save the VI
End of Exercise 2-3seo? rogue
5. Change the value ofthe pointer on the horizontal pointer slide using the
Operating tool
|. Move the cursor to the pointer on the slide,
th 2. When the cursor changes to the Operating tool icon, shown at eh,
ress the mouse button and dag tothe value you wat
Sethe value 1 2
6. Try changing the value of objects, resizirg objects, and renaming
‘objects until you ee comfortable with using these tools
Figure 2-5 shows an example ofthe block diagram as it appears after your
‘modifications, You move the Number of Measurements terminal and wire
‘the terminal wo the count terminal oF the For -009.
Figure 2-5. Using Temperature V Block Diagram
7. Open the block digrain.
|S. Move the Number of Measurements tenninal using the Positioning
100.
Move the cursor tothe Number of Measurements ternal
{B_ Move the cursor the terminal unl he cursor changes oan aro
& asshown ate
|. Click and drag the terminal othe nev location as show in|
Figure 2,2. Expand the waveform graph horizontally using the Positioning too.
Move the cursor othe lft edge of the Waveform Graph,
Move the cursor tothe middle lft revizing node ntl the cursor
changes toa double arrow, as shown in Figure 2-4
a oor
=
as
Figure 2-4, Resize Wavelomn Graph
rag the repositioning point until he
yu want
faveform Graph isthe si
3. Rename the numeric controltoxusbar of Measurements using the
Labeling Tool
Move the cursor tothe txt
Double click the word ux
a
Fer the text amber of Mes
a
‘Complete the etry by clicking the Enter Text button on the tool,
‘orclicking outside the contol
Tange the value of the Number of Measurements contol 1020 using
the Labeling too
Move the cursor tothe interior ofthe numeric contr
When the eursor changes tothe
click the mouse button.
being tool icon, as shown ate,
Ener the text 20,
Complete the entry by pressing the ey on the numeric
‘eypad, clicking the Enter Text baton on the toolbar, or clicking
‘outside the contoExercise 2-3
Goal
Description
Concept: Selecting a Tool
Become familiar wit
uiomati tool selection in LabVIEW.
Du
block diagram, These asks
g this exercise, you complete
kin apatally built front pane and
1. Open
Open LabVIEW
Select FilesOpen.
Navigate to the <2x
© Select vei
Temp vi and elick OK.
Figun sample of the front pare sit appeats after your
modifications. You increase te sizeof the waveform graph, rename
numeric conto, change the value ofthe nuinerie contol, nd move the
pointer onthe horizontal pointer slide,
fame
a
Par
Figure 23. Using TempectureVI Font Perelleo? Aa ne
|G. Hover your mouseover the first result in the Paete section,
Random Number (0-1), This gives vou tree options
= Drop—allows you to place this fanction immediately on the
block diagram
= Find—locstes the function in the fanetons plete
= Help—which rings up the help opie fr this aneton
“Tey clicking each ofthese options
6, Practice accessing similar function.
Pace an Ad function onthe Book agra.
Right-click the Add function and nace that a Numeric palo is
available,
'D. Praetce placing functions from the Numeric palete on the block
sfiagram.
End of Exercise 2-2sno? Avago
Exercise 2-2
Goal
Description
Concept: Navigating Palettes
[Leam to find eontols and functions
1. Open a blank Vi and see
window:
w»Controls Palette onthe front panel
2. Explore the Contos palette.
D. Glick the Search buton.
DD Type string control
1 Click a search result and drag it tothe font panel window to place
the object.
3. Open the block diagram and seleet ViewsFunetions Palette,
4. Explore the Functions palete
D. Phace the DAQ Assistant VI in the Favorites Category.
= Loca
the DAQ Assistant VI
= On the Measurement /O»NI-DAQmnx subpalete, right-click
the DAQ Assistant VIand select Add Ttem to Favorites from
the shortcut men.
~ Notice thatthe Favorites category on the Functions palete now
contains the DAQ Assistant VI
5. Practice using the global search feature
Type Random inthe Search arin theuppe right hand comer of the
block diagram,
Bate Te hota search automat os for matches nthe LabVIEW Help and
Pena ax ou ae ppg you pet cEale wl ao sen folio atl
‘lado your eyeran? tpang ne
|G Foreach input, compare the given outputs tothe outputs iste in
‘Table 2-1. Ifthe VI works correctly hey should match,
Tavle2-1. Testing Vales for Seconds Breakdown
Input Output
O seconds O hours, Ominues. 0 seconds
‘0 seconds O hours, minute, 0 seconds
"3600 seconds hour O minutes, 0 seconds
3665 seconds T hour, Tint, 5 seconds
End of Exercise 2-1sso? Apap ve
‘To verify that you identi all tems corral, see Figures 2-1 and 2-2.
Figure 2-1. Front Pare! tems
Ee)
igre 22, Blok Dagrm heme
‘5. Test the VI sing the vals given in Table 2-1,
2 Enter the input value inthe Total Time fn Seconds contr
Click the Rum but.Navigating LabVIEW
Exercise 2-1
Goal
Description
Concept: Exploring a VI
Iventity the pans of an existing VI
You received VI from an employee that takes the seconds unt a
plane arrives alan airport and converts the time into a combination of
hhoutsiminutesseconds, You rst evaluate this VI to se fit works as
expected and can display the remaining time until the plane ative
1. Open seconds Breakdown.vi inthe czxer:
abs sxplering A VI directory
2 On the front panel, identify the following items:
Contr
© Indicator
Run button
Icon
ooo
Connector Pane
“To view the front panel and block disgram atthe same time,
select Window Tile Up and Down or WindowsTile Left and Right.
4, Onthe block diagram, identify the Following items
o
Como!
Indicator
Constant
ocoa
Free Labeloe Sag pr ae
Notes[==] Coe)
Figure 1-8. Communication with te GPIB instrument
Enter exsumevouracs: 0c? in Send String and click the Query
button. The NI Instrument Simulator eturns a simulated voltage
Click the Query buton again to rtum a different valve.
Click the Exit button when done.
5. Seta VISA alias of deveim forthe NI Instrument Simulator so you can
use the alias instead of having to remembor the primary address.
| While metrument 0s selected in MAX, select the VISA,
Properties ia.
|. Emer daveimin the VISA Alias on My System ld. You use this
alas later inthe course.
6, Select FilesExit to exit MAX,
11. Click Yes when prompted to save the instrument
End of Exercise 1-2
on nme Cogn os Lanne con oerson) Seep pr ae
‘Launch MAX by either double-clicking the ican on the desktop or by
selecting Tools» Measurement & Automation Explorer in LabVIEW.
3. View the settings for the GPIB interface,
|B Expand the Devices and Interfaces section o display the installed
intertaces. Ia GPIB interface is listed, the NI-AS8.2 software is
correctly loaded onthe computer
Select the GPIB interface.
[2 Examine but do not change the settings forthe GPIB interface
4. Communicate with the GPIB instrument
|B. Make sure the GPIB interface is sil selected inthe Devices and
Interfaces section.
{D.Click the Scan for Instruments buon onthe toolbar
1D. Expand the GPIB interface that is selected in the Devices and
Interfaces section. One instrument nemed Znetzumes 0 appears.
1 Glick mnstrument 0 to display infermation about iin the right
pane of MAX. Notice the NI Instrument Simulator has a GPIB
Primary address (PAD)
|D Click the Communicate with Instrument bution on the toolbar
‘An interactive window appears, You can use itt query. write,
and read from that instrument.
Enver +200 in Send String and clic the Query button
‘The instrument returns is make and model number in String
Received as shown in Figure 18. Youcan use this window to debug.
instrument problems of verify that specific commands work as
described inthe instrument documentation,(asor? iy tp eam
Click Next
2 Giick Update
|B Glick Back to return and configure the Serial settings.
Select Change Serial Settings and click Next,
|G Matc the serials setings tothe settings shown in Figure 1-7.
in nme pein
17. Nl instrument Simulzor Ward Settings
Click Next
(lick Update
Click OK,
coco
Power off the NI Instrument Simulator using the power switch onthe
front ofthe uni
a
Set the configuration switch on the rar panel 1o NORM.
o
Power onthe NHostrument Simulator using the power switeh onthe
front ofthe uni
(D. Verify that both the PWR and RDY LEDS are itsno som pra oun
Exercise 1-2 Concept: GPIB Configuration with MAX i="
Goal
mulaor and use MAX to examine
terface senings, detect insrumests, and communicate with an
Lear to configure the NI Instrument
the GPIB
Des
1. Configure the NI instrument Simulator
Power off the NI Instrument Simulator
Set the coatiguation switch onthe rear panel CEG, shown in
Figure 1-6
7
Figure 1-6. nsrument Simulator
©. Poweron the NTasrument Simulatorusing the power swite on the
front ofthe unit
Verify thatthe PWR LED is it and the RDY LED is lashing
a
Launch the NLstrument Simulsior Wizard from Start»
Programs-National Instruments»Iastrument Simulator
Wirard
Click Next,
Click Next.
Select GPIB Interface snd cick Next.
Select Change GPUB Settings and clck Newt
Select Single Instrument Mode and click Next.
‘Set GPIB Primary Address to 3
ccocooa
Set GPIB Secondary Address to 0 {eisai0
Right-click the Seales section and seect Create New from the
shortcut men
Select NEDAQmn Seale.
Click Next
Select Linear
Name the sale Temperature
lick Fi
coaoaa
‘Change the Scaling Parameter Slopeto 100.
Enter Ce1ssus inthe Sealed bon,
co
(Click the Save button on th tootbar‘o save the sale. You use this
scale in ater exercises
(Close MAX by selecting FilexExit
End of Exercise 1-1Figure 1-4, Digital VO Ure Direction
you have ardware installed, lick the Counter HO tab to
Find Instrument
Drivers directs you to drop dow the Tools menu, select the
Instrumentation item, and finally select the Find Instrument Drivers
psi.
‘This ion denotes ati, which alerts you to advisory information.
‘This icon denotes a note, which alerts you to important information
This ion denotes a caution, which advises you of precautions to take 10
avoid injury, data loss o system crash,
‘This ion indicates that an exercise requires plug-in GPIB interface oF
DAQ device
Bold text denotes items that you must select or click i the software, such as
‘menu items and dialog box options. Bold textalso denotes section of dialog
boxes and hardware labels
Tali text denotes variables, emphasis, a ross-reference, ofan introduction
‘okey concept, Iie ex also denotes text tat sa placeholder fr a word
‘or value that you must supply.
‘Teatinthis font denotes text or characters that you ener from the keyboard,
sections of code, programming examples, and syntax examples. This font
also is used fr the proper names of disk drives paths, directories, programs,
subprograms, subroutines, devie names, functions, operations, variables,
Slenames, and extensions
Bold text i this font denotes the messages and responses that the computer
automatically prints to the sereen. This font aso emphasizes lines of code
‘that are diferent from the ether examples.E. Course Goals
‘This course prepares you to do the following
+ Understand front panels lock diagrams, icons, and connector panes
+ Use the programming structures and dats types that exist in LabVIEW
‘+ Use various editing and debugeing techniques
+ Create and save Vis so you can use them 3s subVIS
+ Display and log data
+ Create applications that use plug-in DAQ devices
+ Create applications that use serial port and GPIB insteuments
This course does nor describe the following:
+ Bvery builtin VI unetion, or object reer the LabVIEW Help for
more information about LabVIEW features not described inthis course
+ Analog-o-igital (A/D) theory
+ Operation ofthe serial port,
+ Operation ofthe GPIB bus
+ Developing an instrument diver
+ Developing a complete application for any student in the class refer to
the NI Example Finder, avaiable by selecting Help» Find Examples,
for example Vis you can use and incorporate into Vis you create
© ttm Cg . eth coe woeNU Insteument Simulator Wizard installed from the NI Instrument
Simulator software CD
D. LabVIEW Core I course CD, which isis the following folders:
Directory
Description
Foldet for saving Vis created during the course
and for completing cerain couse exercises; also
Includes subVIs necessary for some exerises and
ip file (Xx Instrument simalator.zip)
Containing the LabVIEW instrument driver for the
NU nsrument Simulator
Solutions
Contains the solutions i all the course exercises
D. Installing the Course Software
Complete the following steps to install the course software.
1, Insert the course CD in your computer. Tae LabVIEW Core 1 Course
Setup dialog box appears
2 Click Install the course materials,
3. Follow the onscreen instructions to complete installation ad setup,
Exercise files are located in the \LabVIEW Core 1\ folder
BB Wate Folder namesinangletrakes,sshas Exercises, referers nthe rot
directory of your computerC. What You Need to Get Started
Suggested Reading
Course Materials
“The suggested reading materials ensure thatall stents have a minimum
knowledge of key theories und concepts related tothe LabVIEW Core 1
course To get the mos out o his couse, complet al the suggested reading
‘materi
“To access each ofthe following suggested reading materials refer to
‘AL .com/ nto and enter the Info Code thal coresponds to cach topic:
LabVIEW Core I- The Software Develorment Method
(nfo Code: softer)
D Invroduetion to Data Acquisition (Info Code: DxQ)
GPIB Instrument Control Tutorial (nfo Code: 6Pz8)
Serial Communication Overview (Info Code: Serial)
Before you begin this course, ensure you hae all he following items:
Windows XP or
installed on your computer
|G. Malifunetion DAQ device configured a: Dev: using Measurement &
‘Automation Explorer (MAX)
DAG Signal Accessory or BNC-2120, wires, and cable
© GPIB merce
NI Instrument Simulator and power suply
{2 LabVIEW Full or Professional Developrent System 2011 of ater
2 DAQMS9.35 or later
OF Ne##8.228.1 or liter
© NIVISA 5.1 or lace
A serial cable
2 AGPIB cableB. Course Description
‘The LabVIEW Core J course teaches you programming concepts,
techniques, features, Vis, and funetions you ean use 0 create test
and measurement data acquisition, instrument conto, datalogging
‘measurement analysis, and report generator applications. This course
assumes that you are familiar with Windows and that you have experience
Writing algorithms inthe form of flowchart or block diagrams. The course
and exercise manuals ate divided ino lessor, described as follows,
Inthe course manual, each lesson consists othe following
‘+ Am introduction that describes the purpose ofthe lesson and what
you will learn
+ A description of the topics in the lesson
‘+A summary quiz that tests and reinforces important concepts and
skills taught in the lesson
Inthe exercise manual, each lesson consists af the following
+ Asetof exereises to reinforce those topes
‘+ Some lessons include optional and challenge exercise sections or
set of additional exereises to complete ime permits
BZ Note Forcourse and exercise manual updates and corrections, refer toni .con/into
and enter he Info Cade core
Several exercises use one ofthe following National Instruments hardware
products:
+ A plug-in multifunction data aquisition (DAQ) device connected 10
‘4 DAQ Signal Accessory or BNC-2120 ccntaning temperature sensor,
function generator, and LEDs
+ A GPIB interface connected to an NI Insiumeat Simulator
If you do not have this hardware, you still ean complete dhe exercises.
Alternate instuctions are provided for completing the exercises without
hardware. Exereises that explicitly require hardware ate indicated with
Aan ico, shown at left You also can substitute ther hardware fr those
previously mentioned, For example, you can use a GPIB instrument place
ofthe NI Instrument Simulator, or ancther National Instruments DAQ
device connected to signal source, scat funetion generatorStudent Guide
“Thank you for purchasing the LabVIEW Core I course kt. You can begin
developing un application soon after you complete the exercises in this
‘munual, This exereise manual andthe accompanying course man and
software are used in the three-day hands-on LabVIEW Core I course.
‘You can apply the full purchase ofthis cours kit toward the corresponding
course repitation fe if you register within 90 days of purchasing the kit
Visitni con /training for online couse schedules, syllabi taining
centers, and lass registration
ation
‘The LabVIEW Core I cours is par of series of courses designed to build
your proficieney with LabVIEW and help yu prepare forthe NI Certified
[LabVIEW Associate Developer exam. The following illustration shows the
‘urses that re part ofthe LabVIEW taining series. Referto
ni. com/ trading for mote information sboat NI Certification
| ‘anvieW Gare “anviEW Core ‘Managing Stare
Sees a
Terma] | mepattee
— ra
vine
a
ENR Late oct to eeeLesson
Relating Data
Exercise 5-1 Concept: Manipulating Arays
Exercise 52 Concept: Closers
Exercise $3 Concept Type Definition
Lesson 6
‘Managing Resources
Exercise 6-1 Concept: Spreadsheet Example VI
Exercise 62 Temperature Log VI
Exercise 6-3 Using DAQMA.
Exercise 64 Concept: NI Devsini VI
Lesson 7
Developing Modular Applications
Exercise 7-1. Determine Warnings VI
Lesson 8
Common Design Techniques and Patterns
Exercise 1 State Machine VI :
Lesson 9
Using Variables
Exercise 9-1 Local Variable VI soso
Exercise 9.2 Global Data Project :
Exercise 9-3 Concept: Bank VI :
Appendix A
Measurement Fundamentals
Exercise A-l. Concepts: Measurement Fundamentals.
Appendix B
Additional Information and Resources
ot
os
67
ell
mA
#1
94
9.40
9.17Contents
‘Student Guide
‘A. Ni Centiication,
B, Course Deseription
©. What You Need to Get Staned
1D. Installing the Course Software
E, Course Goals.
F. Course Conventions
Lesson 1
Setting Up Your Hardware
[Exercise I-l Concept: Measurement & Automation Explorer (MAX),
Exercise 1-2 Concept: GPIB Configuration with MAX.
Lesson 2
Navigating LabVIEW
Exercise 2-1 Concept: Exploring a VL
Exercise 22 Concept: Navigating Palewes..
Exercise 23 Concept: Selecting a Too!
Exercise 24 Concept: Dataflow
Exercise 25 Simple AAP VL
Lesson 3
Troubleshooting and Debugging Vis
Exerese 3-1 Concept Using Help -
Exercise 32 Concept: Debugging.
Lesson 4
Implementing a VI
Exercise 4-1 Determine Warnings VI
Exercise 42 Auto Match VI
Exereise 43 Concept: While Loops versus For Loops
Exercise 44 Average Temperature VI -
Exercise 45 Temperature Multplot VI -
Exercise 445 Determine Warnings VI
Exervise 4.7 Self-Study: Square Root VI
Exercie 48 Self Study: Determine Wamings VI (Challenge)
Exercite 49 Self-Study: Determine More Warnings VI.
41
48
15
418
432
4:36
438Worldwide etnies Senora Pras nrmaton
Words Oat
Volta cop/nigisbal ace te barchalce Nese, hich roid 0-4 ont ifr. spent te
ata nstmens Grate Hearts
SIO Na) Mopac Expresinay Ashi Teas H759.350 USA Te 126830100
erat nisin be Ai fon Resp, To me Na eetLabVIEW™ Core 1
Exercises
Course Software Version 2011
‘August 2011 Edition
Part Number 3252916-01
copra
(2 on9-2011 tan roars Cpr, Migs sen
nr cosh ss pbicaon may at eee anid any tm, crn or ean nh
rater, steng wn rat eet stn. ans, nung wtp arn coset
torrets Cora,
‘eo! srumant peste secu popany ot chars and kur st te same Maar pec
‘Spree anata inactropry as Where stray be eo eed ver teal gi
‘Ae, you ay tare oy era mae at ou ray erode Soraaer ine ws cary ape
Nowa ora rast,
For emporns vain US] Ores es, CU, MOS, Snga nt STLsom eae enya spans wo Fora
Isms ote conon nd extant ne Seco tgnte-ehn he Costner soon.
Ares. Tsproau nates otal vas ley hace Stared se iw. aoche.004)
Capi 189 The ete ature Frazee lees ste.
"GU Capo 5-200 nora user ches arto sn aur A sss
HORS, NCSA HFS rent ona Fora) Sate ay ad Us
Capo a8, 98 700,20, 200 Bas a ss he nary tos. is seve
6 Cori © 204-206 Mute Won ard Sis Sota. ABR Roses
‘Seay The soa nde Sin sear ep Rogue Wave Stare ein Osa,
apn 185700 Cuong se.
Tia cop 29-200 Bors Fm
Tense
{DE on tuna cam hea ners prop, a ge ae agent
Inari arpeson rater ma ineomter st cones Mansa Ves
erect al tesa Peo Programa ere ee net rm Me erat sae
toapewy pas oer ership wat Rao tes
toe
Foros ong ttre etna pods te spp es: Melates cur stu
fhepacence excl en yas mei re tna ntumens xt Noera capac