Professional Documents
Culture Documents
Ben Jeffery
24th October 2002
What is it?
Laboratory Virtual Instrument Engineering
Workbench.
Development environment for the G
language.
Produced by National Instruments for
all major operating systems.
Originally developed for communication
with lab devices.
A really useful tool.
Disadvantages:
Cost 1000 minimum.
Hard to master advanced techniques.
Code can become an impenetrable mess if
youre not careful!
Creating highly customized applications can
become time consuming.
Overview:
The Language
Building an application
Front Panel
Source Diagram
Programming
Structures
Built-in Functions
User Vis
Tips
The G Language:
Completely graphical programming language.
Source code is a diagram of nodes and wires.
Codeflow
UnlockCAL(HeaterMat);
GetTempCAL(HeaterMat);
SetTempCAL(HeaterMat);
LockCAL(HeaterMat);
Guiding Principle:
A node does not run until
data sits at all its wired inputs.
Data Dependency
Building an Application:
Applications are called virtual instruments (VIs)
Two parts to make:
1. Front Panel
2. Source Diagram
Always start with the front panel.
Draw a pencil block diagram of the main
functions of the diagram.
Make this diagram in G code.
Done.
Controls
Indicator
Constant
Types of Node:
Types of nodes:
Indicators and Controls
Functions:
Built in Functions
User VIs (sub-routines)
Structures
Types of Wire:
As terminals accept only defined data
types, so wires have defined types.
This is indicated by colour and style.
Usual data types:
8,16,32 bit Integers (Signed and Unsigned)
Single, Double and Extended floating point
Complex
Boolean
String
Arrays
Clusters (Combination of any above)
Program Control:
Run Once: Program executes until
all data is sunk.
Run Continuously:
Run Once occurs
repeatedly.
Abort Execution:
Immediate halt.
Pause Execution:
Useful for debugging.
A Closer Look
Weve covered most of the basics of the
environment. Now lets look at methods and
techniques of programming.
Structures
Built In Functions
User Vis
Clusters
Programming Tips
Structures:
How you control data flow
Case Structure
While Loop (with shift registers)
For Loop
Sequence
Formula Node
Events Structure
Understanding the operation of these is vital.
Case:
While:
Shift Registers:
For Loop:
Sequence:
Formula Node:
Event Structure:
Built in Functions:
Over 100 built in functions
Built in Functions:
Low Level
Boolean Logic
Arithmetic
Comparisons
These functions accept different data types and
often arrays can be directly wired.
Mid Level
Array Manipulation (Transpose, interpolate,
subset...)
String Manipulation (Search, format,
replace...)
Time and Date
Built in Functions:
High Level
File I/O
Device communication (GPIB, serial etc)
Network communication (TCP, UDP, IrDA)
Waveform manipulation (FFT, Filters,
Analysis)
Math
Sound and Graphics
Program Control
Advanced: Semaphores, Queues,
Occurrences.
So check before you build your own
User Vis:
For often used routines or to prevent an excess of
code on your diagram create a user vi
Create the vi as if it were a stand alone program
Right click the icon to access the wiring and icon
menu.
Show connector and select a pattern of
terminals and then use the wiring tool to select
controls and indicators to be terminals.
Edit the icon
Place the vi where you need it using select a vi
off the function pallet.
Lets see that in LabVIEW:
Clusters:
Collection of one or more items of data
Best used as Named Clusters
Programming Tips:
Use a left to right layout
Use named clusters for both neatness and ease
of variable selection.
If functions need to happen in a sequence
establish a data dependency, so that the
functions are connected in a chain.
This is easily done using the error cluster.
Remember that functions not connected and in
the same frame will run in parallel.
Make user VIs so that your code is modular.
Experiment