3. Review Question 1
If I add a new element to an enum that is saved in
a *.ctl file, how would the file need to be saved in
order to update all of instances
a) Custom control
b) Strict Type Definition
c) Type Definition
4. Review Question 1
If I add a new element to an enum that is saved in
a *.ctl file, how would the file need to be saved in
order to update all of instances
a) Custom control
b) Strict Type Definition
c) Type Definition
5. Review Question 2
True or False?
A sequence structure can be aborted in the middle
of the sequence.
6. Review Question 2
True or False?
A sequence structure can be aborted in the middle
of the sequence.
FALSE
7. Review Question 3
•
If you have a Wait Until Next Millisecond Multiple in a
while loop with a 20 wired to it and the other code
within the loop take 25ms to execute, how long will one
iteration of the loop take?
a) 25 ms
b) 40 ms
c) 45 ms
d) unknown
7
8. Review Question 3
•
If you have a Wait Until Next Millisecond Multiple in a
while loop with a 20 wired to it and the other code
within the loop take 25ms to execute, how long will one
iteration of the loop take?
a) 25 ms
b) 40 ms
c) 45 ms
d) unknown
8
11. Review Question 5
Which block diagram objects compose a state machine?
a) While loop
b) Enum
c) Sequence structure
d) Case structure
e) Shift register
f) Numeric constants
11
12. Review Question 5
Which block diagram objects compose a state machine?
a) While loop
b) Enum (optional, although often used)
c) Sequence structure
d) Case structure
e) Shift register
f) Numeric constants
12
14. Documentation: Description and Tip Strips
• Descriptions- appear in the
Context Help window when you
move the cursor over the object
• VIs: VI Properties» Description
• Controls, indicators, and constants:
Properties » Description
• Tip Strips
• Brief description of the object to
display when you move the cursor
over a front panel object while a VI
runs. (controls, indicators, and
constants)
14
15. Documentation- Labels and Captions
•
Labels (including free labels) are available on the
front panel and block diagram
•
Captions are only available on the front panel – use
when you want to be more descriptive and…
• don’t want to take as much space on the block diagram
• programmatically use the label and don’t want to break
your VI
•
To create a free label:
• Double-click and begin typing
• Place a free label form the Functions palette
•
Be descriptive!
For example,
• Does “Temp” mean temporary or temperature?
• What are the units of “Temp”?
15
16. Documentation- Block Diagram
Use block diagram comments to:
• Describe algorithms
• Explain the data contents of wires
• LabVIEW 2010 and later: right-click
on wire select Visible»Label
• LabVIEW 2009 and earlier: use a
free label to label wires
• Using Unbundle/Bundle By Name
creates self-documenting code
16
18. Timing Functions
• Control or measure the frequency at which a loop executes
• Provide the processor with time to complete other tasks,
such as processing the user interface
• Uses the operating system millisecond clock
19. Wait Function
• Waits the specified number of milliseconds.
• If 0 is wired to it, the current thread is forced to yield
control of the CPU
• Uses the operating system millisecond clock
20. Wait Function- example cases
• Loop would go to next iteration
after 10 ms or more depending
on amount of time the subVI
takes.
• If subVI takes >10 ms, loop
goes as soon as subVI is done
• If subVI takes <10 ms , loop
goes at 10 ms mark.
• Loop would go on to
next iteration after
10 ms, because the
only thing that
happens in each
iteration is wait 10
ms
Moment next loop
iteration can begin
10 ms
20 ms
30 ms
Wait
Other code
(running in
parallel with
Wait VI)
21. Wait Until Next Millisecond Multiple Function
• Waits until a multiple of the millisecond value wired in
• Provide the processor with time to complete other
tasks, such as processing the user interface
• Uses the operating system millisecond clock
22. Wait Until Next Millisecond Multiple Function
• Loop would go to next iteration
after 10 , 20, 30, or a greater
multiple of 10 ms depending on
amount of time the subVI takes.
• If subVI takes <10 ms , loop
goes at 10 ms mark.
• If subVI takes 16 ms, then
the loop goes at 20 ms.
• Loop would go on to
next iteration after
10 ms, because the
only thing that
happens in each
iteration is wait 10
ms and 10ms is the
first multiple of 10
• If subVI takes 22 ms, then
the subVI goes at 30 ms.
Wait
10 ms
20 ms
30 ms
Other code
(subVI)
23. Comparison of Timing Functions
Red represents
times when Wait
functions are NOT
restricting
Moment next loop
iteration can begin
Other code
(running in
parallel with
waits)
10 ms
20 ms
30 ms
CaptionFront panel objects also can have captions. You can use captions instead of labels to localize a VI without breaking the VI. Unlike a label, a caption does not affect the name of the object, and you can use it as a more descriptive object label. The caption appears only in the front panel window.If you assign the object to a connector pane terminal, the caption appears in a tip strip when you use the Wiring tool to move the cursor over the terminal on the block diagram. The caption also appears next to the terminal in the Context Help window if you move the cursor over the connector pane or VI icon.
Descriptions of VIs and controls, indicators, and constants appear in the Context Help Window when your cursor hovers over them. A VI description is added by editing the VI Properties: Description field. You can get to VI Properties through the File» VI Properties or by right-clicking on the VI icon and selecting VI Properties (in the upper-right corner; not a subVI icon). A VI Properties window will appear like top image in this slide. Select Documentation from the drop-down menu and enter your description.A description for a control, indicator, or constant is created by right-clicking on the object and selecting Properties from the short-cut menu. Click on the Documentation tab and enter the description. The tip strip field is available here as well. Tip strips are short messages to help a user by popping up when the cursor is over the object and the VI is running. Here is LabVIEW Help’s information on Descriptions and Tip Strips:Description—Contains a description of the object. Descriptions for controls, indicators, and constants appear in the Context Help window when you move the cursor over the object. You can enter a description for a VI or function located on the Functions palette but you can only view the description in this dialog box. The description will not appear in the Context Help window. You can format the text in the description to appear bold in the Context Help window. If you want to display a carriage return in the Context Help window, you must separate paragraphs with two carriage returns. Tip—Brief description of the object to display when you move the cursor over a front panel object while a VI runs. The Tip text box is available only for controls, indicators, or constants. You cannot enter tip information for VIs or functions.
Front panel objects also can have captions. You can use captions instead of labels to localize a VI without breaking the VI. Unlike a label, a caption does not affect the name of the object, and you can use it as a more descriptive object label. The caption appears only in the front panel window.If you assign the object to a connector pane terminal, the caption appears in a tip strip when you use the Wiring tool to move the cursor over the terminal on the block diagram. The caption also appears next to the terminal in the Context Help window if you move the cursor over the connector pane or VI icon.Right-click the object and select Visible Items»Caption from the shortcut menu to show or hide the caption. Note When the text of the caption changes, LabVIEW does not need to recompile the VI or its callers. You also can use the Text property to change the text of a caption programmatically or use the Caption property to reference the caption.Note You must first create the caption before you use the Text or Caption property, or LabVIEW returns an error. LabVIEW creates the caption the first time you set the caption to visible.
Use the following guidelines when commenting your VIs:Comments: Use to document algorithms that you use and add reference information Label structures to specify the main functionality Label long wires to identify their use/contents Label constants to specify the nature of the constant Do not show labels on functions and subVIs - a developer can find information about a function or subVI by using the Context Help window
There are many reasons to use the timing functions. The Wait and Wait Until Next Millisecond Multiple functions are used for two main reasons: to control loop frequency (how quickly you go to the next loop iteration) and to provide “down time” for the processor allowing it to go complete other (possibly non-LabVIEW) tasks, such as updating the front panel or run a virus scan. The Elapsed Time Express VI is used to check how much time is passed. The Tick Count and Get Date/Time In Seconds functions can be used to determine how much time has passed, as well, by taking the difference of two measurements. (Note that the Tick Count has a maximum value 4,294, 967, 295 because it is limited by the data type, U32. Once the maximum is reached, it begins again at zero: also known as rolling over. Therefore, if you want to measure a longer time, use the Get Date/Time in Seconds.)The timing functions use the Operating System’s ms clockThe wait and wait until next ms multiple functions are discussed in the following slides in more detail.
The wait simply waits the number of ms wired into it. When in a loop, it often has nothing forcing its execution (other than the constant wired to it) relative to the other code within the loop. Therefore, the Wait function will operate in parallel with the other code in the loop. If the other code takes a shorter amount of time to execute, the wait will continue until it has met the value wired to it before allowing the next loop iteration. If the wait takes a shorter time, then the next loop iteration will begin directly after the other code in the loop finishes. This is shown in the next slide.
The wait simply waits the number of ms wired into it. When in a loop, it often has nothing forcing its execution (other than the constant wired to it) relative to the other code within the loop. Therefore, the Wait function will operate in parallel with the other code in the loop. If the other code takes a shorter amount of time to execute, the wait will continue until it has met the value wired to it before allowing the next loop iteration. If the wait takes a shorter time, then the next loop iteration will begin directly after the other code in the loop finishes. The green shapes show the point at which the next loop iteration would begin if the other code (blue line) took 16 ms: right at 16 ms for the wait function because the value wired into the wait is less than the time the other code took to execute
The wait until next ms multiple sets up “opportunities” when the code is allowed to continue. For example, consider a situation where there is a loops with a wait until next ms multiple inside the loop along with other code and there is a 10 (ms) wired into the wait until next ms multiple function. If the other code in the loop finishes after 8ms, then the wait until next ms multiple will wait an additional 2ms (total of 10ms) before the next loop iteration is allowed to execute because the first opportunity is at 10ms (first multiple of 10; 10x1). If the other code take 13ms to complete, then the next loop iteration cannot begin until the 20 ms mark (second multiple of 10ms; 10x2). If 15 were wired into the wait until next ms multiple instead of 10, then the times when the next loop iteration could happen would be at the 15, 30, 45, 60….. ms marks; (multiples of 15)
There are two main reasons to use the timing functions: to control loop frequency (how quickly you go to the next loop iteration) and to provide “down time” for the processor allowing it to go complete other (possibly non-LabVIEW) tasks, such as updating the front panel or check for email. The timing functions use the Operating System’s ms clockThe wait simply waits the number of ms wired into it. When in a loop, it often has nothing forcing its execution (other than the constant wired to it) relative to the other code within the loop. Therefore, the Wait function will operate in parallel with the other code in the loop. If the other code takes a shorter amount of time to execute, the wait will continue until it has met the value wired to it before allowing the next loop iteration. If the wait takes a shorter time, then the next loop iteration will begin directly after the other code in the loop finishes. The wait until next ms multiple sets up time markers when the code is allowed to continue. For example, consider a situation where there is a loops with a wait until next ms multiple inside the loop along with other code and there is a 10 (ms) wired into the wait until next ms multiple function. If the other code in the loop finishes after 8ms, then the wait until next ms multiple will wait an additional 2ms (total of 10ms) before the next loop iteration is allowed to execute. If the other code take 13ms to complete, then the next loop iteration cannot begin until the 20 ms mark (an interval of 10ms). If 15 were wired into the wait until next ms multiple instead of 10, then the times when the next loop iteration could happen would be at the 15, 30, 45, 60….. ms marks.The green shapes show the point at which the next loop iteration would begin if the other code (blue line) took 16 ms: right at 16 ms for the wait function (because the value wired into the wait is less than the time the other code took to execute) and 20 ms for the wait until next ms multiple function (because the loop can only go to the next iteration at multiples of 10ms)
This slide is to visualize the different behavior from the Wait and the Wait Until Next Millisecond Multiple functions. Assumptions: The “other code,” such as a subVI, is running in parallel with either Wait or Wait Until Next Millisecond Multiple, which are within a loop. (The concept holds for other structures, like a case structure, but is easiest to understand and most often used within a loop)Definitions: green star: the point at which the next loop iteration would begin Blue solid line: time when the “other code” is executing. Black solid line (horizontal): time when Wait is executingRed: times when Wait functions are NOT restricting If the other code (blue line) took 16 ms….…a loop with the Wait functions would go to the next iteration right at 16 ms because the value wired into the wait is less than the time the other code took to execute. [the blue line finishes within the red area for the Wait]… a loop with Wait Until Next Millisecond Multiple function would go to the next iteration at 20 ms because the loop can only go to the next iteration at multiples of 10ms and 20 is the next multiple of 10. [the blue line finishes between red dots for the Wait Until Next Millisecond Multiple and the loop can’t go until the next red dot, so the loop waits an additional 4ms until the 20 ms mark]