You are on page 1of 18

Inserting Pictures

To insert a picture into your LabView front Panel, simply


cut and paste from another windows application.
• Good way to add personal logo to your Vis
• Good way to add pictures to illustrate your VI. Eg…
Front panel controls valves/ meters on industrial chemical
reactor
• Avoid placing controls and indicators on top of picture.
Need time and CPU time to redraw picture when control/
indicator updated.

Picture for
Lab 3
Last Updated 2/3/05 Week 3 - part b
Global and Local Variables
In all programming languages, the programmer has the ability to
define local variables (within a subroutine or subVI) or global
variables (accessible to VI and all subVI’s).

rate := 0.05
principle := 1000.
money := principle
For I:= 0 to 10
money:=money+money*rate
Next I

In the above example, the user might input the rate of


interest earned and the amount of principle in an
account to calculate the compounded
Last Updated 2/3/05 Week 3 - part b
interest.
Global and Local Variables
In the example, both rate and principal are local variables.

Typical global variables for VI’s might include


• a GPIB address of a instrument
• the current name of an output file
• default settings for an instrument, etc.

Setting up these variables in LabVIEW is similar to setting


up a subVI.

Last Updated 2/3/05 Week 3 - part b


Defining Variables
Start by using Functions>>All Functions>>Structures palette
and selecting the GLOBAL variable

• A node appears on the block diagram for the global variable


• Double click on it to open its front panel.
• Assign a name (label) to each control because you must refer to
the variable by that label.

You can define a Global Node to have more than 1 variable


You can define more than 1 Global Node

Last Updated 2/3/05 Week 3 - part b


Sample Global Node
G P IB A D D R E S S M a ximu m V o lta g e

0 0 .0 0

C u rre n t D a ta F ile M in imu m V o lta g e

0 .0 0

G P IB A D D R E S S

G P IB A D D R E S S

Last Updated 2/3/05 Week 3 - part b


Sharing Global Variables
Once you save the global node as a VI, you can insert it as a
Global node in an VI or subVI

CAUTION: Do not overuse global variables!!!

Due to dataflow architecture, it is difficult to know when a


block of code is writing/ reading global variable.
Since a global variable is BOTH an indicator and control,
you have flexibility, but also more opportunity for errors.

Last Updated 2/3/05 Week 3 - part b


Local Variables
• Only used in a single VI or subVI
• As with Global variable, you refer to Local variable by its label.
• Create a Local variable by Functions>>All Functions>>Structures
and select local variable or right click on control/ indicator and select
CREATE>>Local Variable.
• Remember, variables can act as Controls and Indicators
• Advantage of Local variables over Global variables is that Local
variables do not need a separate VI FRONT PANEL.
• Eg. for the traffic light lab, you can put everything in one VI using
local variables, or put traffic lights in separate front panel from time
controls.
Local Variable Example
Last Updated 2/3/05 Week 3 - part b
Arrays and Clusters
Otherwise known to programmers as Arrays and Structs (or Records)

Clearly, in data acquisition, there is a need to store arrays of data:


For I:= 0 to 10
For J:= 0 to 10
Surface(I, J):= I * J
Next J
Next I

As you would expect, LabVIEW has array structures and all


the accompanying functions which would act on an array.

Last Updated 2/3/05 Week 3 - part b


Arrays etc.
ALL arrays in LabVIEW are 0 indexed

Array elements MUST all be of the same data type eg.


Boolean, Real, Double, Integer, etc.
You can’t do anything whacky like make arrays of arrays.

• You create arrays using the Controls palette and selecting


Array and Cluster
• From the array shell you choose a valid element (Boolean,
String, etc.) M y L abel
Element Display
0

Index Display

Last Updated 2/3/05 Week 3 - part b


Arrays - Adding the Element
Once you have the element display, put your Element inside
(eg. A Boolean Indicator)
M y L abel M y L abel

12 15

To define length of the array,


Grey Out
• increment index control to desired value
• Right mouse click on the element display and choose Data
Operations>>set to default.
• Undefined elements in the array (ie. 15th element of a 10
element
Last Updated array)
2/3/05 are greyed out.
Week 3 - part b
Arrays - Adding Dimensions
Pop-up on the index control to add a dimension
M y L abel
Row
0 Value at Row
18 and
Column Column

Last Updated 2/3/05 Week 3 - part b


Displayed Arrays - Tabular
Resizing the Element Display Allows you to see more
than one element at at time
Element [0,18]
M y L abel

0
18

Last Updated 2/3/05 Week 3 - part b


Array Sizes, Functions, etc.
The size of an array is limited by the Default values of an array
control. - Do not make the default size larger than required.
LOTS of functions to manipulate arrays:
Array Size Sort Array
Index Array Search Array
Replace Element Array Min, Max
Array
Etc. etc.
Get Array Subset

Array Example

Last Updated 2/3/05 Week 3 - part b


Clusters
G cluster - an ordered collection of one or more elements
• Analogous to structures in C
• Clusters can contain any combination of G data types
(unlike Arrays)
• Fixed size (unlike arrays)

Use Clusters to group related data together and reduce wire


clutter. Use Clusters to Bundle data together to pass to SubVI

Cluster

Last Updated 2/3/05 Week 3 - part b


Cluster Example
Use Clusters Function on Control Palette to create a Cluster
c lu s te r a

G P IB A D D R E S S
E rro r c o n d itio n
0

L e n g th o f A rra y

Functions for assembling or building Clusters:

Bundle Array to Cluster


Bundle by Name

Last Updated 2/3/05 Week 3 - part b


Bundle / By Name

Bundle by Name - Reference by Name, not position

time

0 .0 0
H our
N e w V a lu e B u n d le B y N a me
M in u ite 0 .0 0

H our 0

Last Updated 2/3/05 Week 3 - part b


Changing Values/ Debundle
There are equivalent Functions to Debundle

VI example of how to Change value in a Bundle

Last Updated 2/3/05 Week 3 - part b


add stuff on x-y charts.

Last Updated 2/3/05 Week 3 - part b

You might also like