0% found this document useful (0 votes)
44 views38 pages

Labview Clad Review

The document discusses various LabVIEW programming concepts including Boolean objects, data flow, arrays, enumerations, conditional disable structures, event structures, sequence structures, timing functions, file formats, modularity, the connector pane, errors vs warnings, and debugging tools to help organize and execute LabVIEW code. Control and indicator terminals allow passing data into and out of structures and functions to control execution based on available data. Proper use of structures, timing, and debugging aids help develop modular and well-organized LabVIEW programs.

Uploaded by

christ9088
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views38 pages

Labview Clad Review

The document discusses various LabVIEW programming concepts including Boolean objects, data flow, arrays, enumerations, conditional disable structures, event structures, sequence structures, timing functions, file formats, modularity, the connector pane, errors vs warnings, and debugging tools to help organize and execute LabVIEW code. Control and indicator terminals allow passing data into and out of structures and functions to control execution based on available data. Proper use of structures, timing, and debugging aids help develop modular and well-organized LabVIEW programs.

Uploaded by

christ9088
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 38

Room: Rapson Hall 54

Time: 4-5 PM
Mechanical Actions of Boolean Objects
 Switch when pressed
 Switch when released
 Switch until released

 Latch when pressed


 Latch when released
 Latch until released
Custom Controls & Type Definitions
Control Type Def Strict Type Def
• No connection • Connection between the •Connection between
between the one you saved file and all saved file and all
saved and the instances instances
instance in the VI
• Forces the data type of
• Update the file, but each instance to be •Forces everything about
the instances are not identical (clusters, enum) an instance to be identical
updated to the strict type
• Changes made to file will
definition, except:
populate throughout
each instance •label
•description
•default value

*.ctl *.ctl *.ctl


Data Flow
 Block diagram execution is
dependent on the flow of data
 Block diagram does NOT
execute left to right
 Node executes when data is
available to ALL input terminals
 Nodes supply data to all output
terminals when done
 If the computer running this
code had multiple processors,
these two pieces of code could
run independently without
additional coding
Arrays: the index
The index (zero-based) tells you :
• the dimension of the array (1D, 2D, 3D, etc.)
• the index of the element displayed in the upper left corner
- the 1D array below is displaying index 1 to contain a value of 3.00; we do
not know the value of index 0 from this image because the value at index
0 is hidden from view

2D Array (uninitialized)
1D Array (initialized)
(row)
(column)

index
TIP: drag the edge of the index to add another dimension to an a
Arrays: the elements

• Arrays can be of many different data types, but


only one data type at a time
Enumeration
• An enum represents a pair of values, a string and
a numeric, where the enum’s value is one of a
defined list of value pairs

• Appears as a string to you, and a number to computer


Conditional Disable Structure
 Use to define conditions that indicate which code on the
block diagram executes
Examples:
 If running as an executable, then programmatically close
LabVIEW when VI finishes
 If running on Windows, look for file here; if running on Mac OSX
then look here.
Event Structure
Event Structure — LabVIEW’s programmatic tool
for handling events.
• Therefore, execution of code can be dependent
on whether or not an event has occurred
• Waits for an event to
occur indefinitely,
unless configured to
timeout.

9
Notify and Filter Events in Config. Window

Notify Events (green arrow)


User action has already occurred

Filter Events (red arrow)


User performed action but event is not
processed. Allows you to customize event
handling.
Notify and Filter Events in Config. Window

Notify Events (green arrow)


User action has already occurred

Filter Events (red arrow)


User performed action but event is not
processed. Allows you to customize event
handling.
Flat Sequence Structure
 Executes each frame beginning with the left-most frame
and ending with the right-most frame
 The previous frame must complete before the next frame
executes
 Data can be passed out of or between frames using tunnels
 Once the sequence begins, it cannot be stopped

1st 2nd 3rd


Stacked Sequence Structure
 Executes frame 0, then frame 1, etc. until the last frame
executes
 Returns data only after the
last frame executes
 To transfer data from frame
to frame, a Sequence Local Sequence
Local
must be created (right-click
» Add Sequence Local)
• Once the sequence begins,
it cannot be stopped
• Formula node
Other Structures
 Formula Node
 Timed Loops

Sequence
Local
Multiple Loop Design Pattern
Producer/Consumer

15
Multiple Loop Design Pattern
Master/Slave: a type of Producer/Consumer

• uses notifiers
to allow loops
to run at
different rates

16
Producer/Consumer with Queues

Data type here


determines the
data type that
can be placed
in the queue

17
Graphs vs. Charts
• Chart:
• 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 multi-
plot data to Waveform Graphs
and XY Graphs
Chart Update Modes
• Right-click the chart and select Advanced»Update
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
Notifier vs. Queue
Tool Function When to use
Notifier - sends alert to helps control - have a parallel loops that are
timing of parallel loops running at different rates and 1+ loop
- can transfer data between is dependent on another
loops - want to transfer data from one loop
- data NOT buffered (lossy) to another

Queue - helps control timing of parallel - have a parallel loops that are
loops running at different rates and 1+ loop
- transfers data between loops is dependent on another
- buffers data to be transferred - want to transfer ALL data from one
(FIFO) loop to another
Semaphores

Run the top VI first

Run the bottom VI second

21
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
Comparison of Timing Functions
Red represents
times when Wait Moment next loop
functions are NOT iteration can begin
restricting

Other code
(running in
parallel with
waits)

10 ms 20 ms 30 ms
VI Timing Types
• Execution Timing
• Provides the design pattern with a function that specifically allows the
processor time to complete other tasks
• In some cases, a Wait function is not necessary
• Use of Timeout inputs can provide execution timing

• Software Control Timing


• Timing (pauses, waits, time checks) you put in place to make the code
execute after a certain amount of time.

• Example:
• If you must acquire data for 5 minutes, you could remain in the acquisition state until
the 5 minutes elapses. However, during that time you cannot process any user
interface actions such as stopping the VI. To process user interface actions, you
must implement timing (checking if 5 min has passed since the start of acquisition)
so that the VI continually executes for the specified time
VI Timing Execution Timing

Software Control Timing

25
File Formats
ASCII TDMS Direct Binary
Numeric Good Best Best
Precision

Share data Best (Any program Better (NI Good (only with
easily) Programs easily) detailed
metadata)
Efficiency Good Best Best

Ideal Use Share data with Share data with Store numeric
other programs programs when data compactly
when file space and storing simple with ability to
numeric precision array data and random access
are not important metadata
Modularity and SubVIs

27
Modularity and SubVIs

28
Icon and Connector Pane: Setting up
the Connector Pane
• Right-click the icon in the
upper right corner of the front
panel and select Show
Connector (before LV 2011)
• Each rectangle on the connector
pane represents a terminal

• Select a different pattern by


right-clicking the connector
pane and selecting Patterns
from the shortcut menu

29
Errors vs. Warnings
Error Warning
Status = TRUE Status = FALSE
Code is non-zero
Debugging Tools

- use highlight execution


- use probes to see the current value in
the wire
- set breakpoints to pause execution
at a specific point in the code

- single-step through the code


VI Server: Organization Generic
Object
GObject

Pets Control

Control
Dogs Cats Boolean Array

Labrador Poodle Stop LED


Boolean
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

• Execute from top to bottom


By default, if an error occurs on 3rd of 5 terminals, last two do not
execute and error is output

33
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

Method Name
Parameters
Implicitly and Explicitly Linking
Invoke/Property Nodes
Explicitly Linked Implicitly Linked
(requires reference) (color/ label for data type/label)
Property
Node

Invoke
Node

35
Variables: Recap
Variable Type Scope Notes
Local variable A single VI • Tied to a front panel control/indicator
Global variable Multiple VIs on • Tied to a special global VI that has a front
same panel but no block diagram
computer
Functional Multiple VIs on • Implemented using a While Loop with an
global same uninitialized shift register to store global
computer data
Single-process Multiple VIs on • Implemented using a project library in a
shared variable same project
computer • Can easily convert into a network-
published shared variable
Network- Across an • Implemented using a project library in a
published Ethernet project
shared variable network • Often used to communicate with Real-
Time targets
Race Conditions: Shared Resources

37
Race Conditions: Sequencing
What is the final value?
Four possible outcomes:
• Value = (Value * 5) +2
• Value = (Value + 2) * 5
• Value = Value * 5
• Value = Value +2

38

You might also like