Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Workshop
6 of 7
1
Today's Topics
Review of Workshop 5
Debugging
You must create a descriptive icon for a subVI and wire the connector pane
You must create a descriptive icon for a subVI and wire the connector pane FALSE
Review Question 2
On a subVI, which terminal setting causes an error if the terminal is not wired?
a)
b) c)
Review Question 2
On a subVI, which terminal setting causes an error if the terminal is not wired?
a)
b) c)
Review Question 4
Which of the following forms of documentation are available on the block diagram?
a) b) c) d)
Review Question 4
Which of the following forms of documentation are available on the block diagram?
a) b) c) d)
10
Review Question 5
Which of the following statements are true about high-level File I/O Vis?
a)
b)
c)
High-level File I/O functions are more efficient than low-level I/O High-level File I/O functions perform the open/create, read/write, and close within the VI High-level File I/O functions are specific to one file type
11
Review Question 5
Which of the following statements are true about high-level File I/O Vis?
a)
b)
c)
High-level File I/O functions are more efficient than low-level I/O High-level File I/O functions perform the open/create, read/write, and close within the VI High-level File I/O functions are specific to one file type
12
type of numeric indicator that displays one or more plots of data, typically acquired at a constant rate
Displays
13
Remembers history new point added to end of plot Good for inside a loop
Graph:
New plot of all new data
Good for outside the loop Use the Context Help window to determine how to wire multiplot data to Waveform Graphs and XY Graphs
14
15
Right-click the chart and select AdvancedUpdate Mode from the shortcut menu Strip chart is the default update mode Scope chart and Sweep chart modes display plots significantly faster than the strip chart mode
16
17
Error Handling
Essential for: Debugging - helps to catch programming errors Stress testing - helps to test application boundary cases Robustness - helps detect errors introduced by system and environment differences
18
Remember... without a mechanism to check for errors, you know only that the VI does not work properly
19
20
creates a pop-up dialog box to notify user of error that has occurred Configurable to handle warnings, too Avoid using in subVIs
Merge Error VI
combines multiple error wires into a single error wire error received on the top most input will be passed out, others will be ignored
21
Use error wires to propagate errors along and handle appropriately Merge errors from different wire paths
22
Use shift-registers to detect errors and warnings in all loop iterations Use error status as a condition to stop a loop
23
24
24
Codes are subdivided into ranges according to product and VI grouping Most codes are unique, but some error codes are used by more than one product or VI grouping
25
Debugging
Your VI isnt broken, but you are getting unexpected data or behavior
Any unwired or hidden subVIs? Incorrect default data being used? Undefined data being passed? Numeric representation correct? Node execution order correct?
26
26
Debugging Tools
-use -use
highlight execution
probes to see the current value in the wire -set breakpoints to pause execution at a specific point in the code
-single-step
27
Use execution highlighting to watch the data flow through the block diagram If the VI runs more slowly than expected, confirm that you turned off execution highlighting in subVIs
28
28
observe intermediate data values check the error output of VIs and functions, especially those performing I/O
Values can be retained in the wires so that you can probe wires for data after execution has finished
29
29
When you reach a breakpoint during execution, the VI pauses and the Pause button appears red You can take the following actions at a breakpoint:
Single-step through execution using the single-stepping buttons Probe wires to check intermediate values Change values of front panel controls Click the Pause button to continue running to the next breakpoint or until the VI finishes running
30
30
Single-step through the VI to view each action of the VI on the block diagram Suspend the execution of a subVI to
edit values of controls and indicators control the number of times it runs go back to the beginning of the execution of the subVI
Open subVI and select OperateSuspend When Called from the shortcut menu
31
31
Homework
Debug and add error handling to the VI, FixMe.vi
32
32
Welcome!
Workshop
6 of 7
33
Today's Topics
Review of Workshop 5
34
Review Question 1 You are logging data from multiple sensors over many hours that you will process later using VIs written by a colleague. Which file type would best to use?
a) b) c)
35
Review Question 1 You are logging data from multiple sensors over many hours that you will process later using VIs written by a colleague. Which file type would best to use?
a) b) c)
36
Review Question 2
______
______
_____
______
Review Question 2
Close File
39
All instances of a polymorphic VI must have the same connector pane. TRUE
40
VI Server
LabVIEW organizes and operates on its parts (front panel, button, arrays, etc.) within an architecture called VI Server, which is object oriented. Terminology: A class defines what an object is able to do, what operations it can perform (methods), and what properties it has. An object is a member of a class.
41
VI Server: Organization
Generic Object GObject
Pets
Control
Control
Dogs Cats
Boolean
Array
Labrador
Poodle
Stop
LED
Boolean
42
Property Nodes
Access the properties of an object Enable you to modify the appearance of front panel objects programmatically in response to certain inputs.
For example,
If a user enters an invalid password, you might want a red LED to start blinking If a data point is above a certain value, you might want to show a red trace instead of a green one
By default, if an error occurs on 3rd of 5 terminals, last two do not execute and error is output
43
43
Invoke Nodes
Use
the Invoke Node to perform actions, or methods, on referenced items (VI, Control) Most methods have parameters
Examples
of VI Methods:
Front Panel: Center Default Values: Reinitialize all to Default Print: VI to HTML
44
45
Invoke Node
46
46
VI
VI SubVI
47
1. Select the portion of the block diagram that will be in the subVI. 2. Select EditCreate SubVI; LabVIEW automatically creates the control references needed for the subVI.
48
48
Demonstration: Creating References for Property and Invoke Nodes; Selecting a Class
49
Variables
Cannot pass data between parallel loops with a wire Variables allow you to circumvent normal dataflow by passing data from one place to another without connecting the two places with a wire
50
50
Variables
Variables - Block diagram elements that allow you to access or store data in another location
Types:
Local - Stores data in front panel controls and indicators Global - Stores data in special repositories that can be accessed from multiple VIs Functional Global - Stores data in While Loop shift registers Shared - Transfers data between various distributed targets connected together over a network
51
51
NOTE: Boolean controls with associated local variables must use switch mechanical action; boolean latch action is incompatible with local variables
52
52
Use a global variable to share data among VIs on the same computer, especially if you do not use a project file
Use a single process shared variable if you may need to share the variable information among VIs on multiple computers in the future
53
53
54
must have a project open to create a shared variable Variable configuration data is stored in Project Libraries LabVIEW will automatically create a library if the variable was not created from an existing library
55
56
Verify that variables contain known data values before the VI runs
If you do not initialize the variable before the VI reads it for the first time, it contains the default value of the associated front panel object
57
57
58
59
59
Variables: Recap
Variable Type Local variable Global variable Scope A single VI Notes Tied to a front panel control/indicator Multiple VIs on Tied to a special global VI that has a front same panel but no block diagram computer Multiple VIs on Implemented using a While Loop with an same uninitialized shift register to store global computer data Multiple VIs on Implemented using a project library in a same project computer Can easily convert into a networkpublished shared variable Across an Ethernet network Implemented using a project library in a project Often used to communicate with RealTime targets
60
Race Condition
A situation where the timing of events or the scheduling of tasks may unintentionally affect an output or data value
Common
problem for programs that execute multiple tasks in parallel and share data between the tasks
Race
Often,
code with a race condition can return the same result thousands of times in testing, but still be capable of returning a different result
Avoid
race conditions by: Controlling shared resources Properly sequencing instructions Identifying and protecting critical sections within your code Reducing use of variables
61
61
62
62
63
63
A critical section of code is code that may behave inconsistently if some shared resource is altered while it is running If one loop interrupts another loop while it is executing critical code, then a race condition can occur Eliminate race conditions by identifying and protecting critical code with:
o o
64
64
65
65
Semaphores
Semaphores behave like a talking stick only the one with the semaphore/stick can talk/operator
66
66
Homework
Programmatically
67