Vous êtes sur la page 1sur 11

2/21/2016

Graphical Programming
chap1

Motivation #1: Nobody takes data by hand anymore.


Utilize power of PC to automate data acquisition, analysis
and display from a complete experiment (which might be
comprised of one or more physical instruments).
Motivation #2: Im an experimentalist first and a
programmer second. I want to get my data from my
experiment easily and quickly.
Motivation #3: My advisor handed me an instrument and a
manual and told me to make them talk to each other. (I was
told its a good learning experience!)
2/21/2016

Communicating GPIB and serial

GPIB - General Purpose Interface Bus


digital, 24 conductor parallel Bus
Standardized communication - IEEE 488
Control many instruments (16) from one GPIB
plug-in card

Uses built in Serial Port (RS-232 standard)

Serial transmission of data (1 bit at a time)


Data transfer rates low/ works over long
distance

Communicating to an Experiment

Data Acquisition Board -


DAQ
2/21/2016

What is LabView?

Laboratory Virtual Instrument Engineering Workbench


Is a graphically oriented programming language for data acquisition (DAQ)
and instrument control - (G programming language)
A widely adopted standard in industry, academic and research labs maybe
90% of the market.
More powerful and flexible than individual instruments since utilizes
versatility of personal computer.

Basic Functions of Virtual Instrumentation

Data acquisition
Data analysis
Data presentation
Process monitoring and control
2/21/2016

LabVIEW versus C programming

C, Fortran, Basic use text based programming languages to create lines of code
LabVIEW using G graphical programming language in picture/ icon format
(block diagram). Most of syntax is eliminated. - formal knowledge of
programming not required.
2/21/2016

Lets start with some basics...

A LabVIEW application is called a VI (Virtual Instrument). We will


always refer to LabVIEW applications as VIs.

Every VI has two major components:


Front Panel - it serves as the user interface,
Block Diagram - it contains the graphical source code that defines the
functionality of the VI.

In addition, each VI possesses an Icon and Connector Pane - those


serve as an interface - they identify the VI so that you can use the
VI in another VI. A VI within another VI is called a subVI. A subVI
corresponds to a subroutine in text-based programming languages.

This is an example of a front panel:


Control
Icon

Indicator

Two kinds of components on the front panel: Front Panel -


Controls - Inputs from the User interface between
Indicators - Outputs to the User user and program
2/21/2016

Each front panel has a corresponding diagram associated with it.


When you place a control or indicator of the front panel, a
corresponding terminal automatically appears on the diagram
Control terminal
Indicator terminal

Nodes - analogous to
statements, operators,
functions and subroutines
Block Diagram
Wires - data paths between source and
destination terminals

Dataflow Programming

Text based languages (C, Basic, Fortran) execute line-by-line


DATAFLOW principle governs execution in G programs

Node executes once all data arrives at input terminals


Node supplies data to all output terminals when
finished executing
Data flows along wires from output terminals to next
destination terminals.
Dataflow execution is DATA DEPENDANT
Therefore, timing issues become important!
2/21/2016

In order to manipulate with different components, a Tool Palette is


available: positioning tool
operating tool

wiring tool

Run (one execution only) and Run Continuously Buttons

Lets see this in action example 1_1.vi. Well also see a simple debugging
(bad wires etc.)

HELP!!!!

Help is available on-line for LabVIEW. As you develop


your own VIs, make sure you include a help panel so you
can annotate how your software works, functions of the
parameters, etc..
LOTS of examples at http://www.ni.com/Labviewse . This
is were all of the Labview Student Edition examples can be
found.
2/21/2016

Much more about front panel components:


There are many different front panel components:
Numeric: Boolean: Graphs:

Every component when placed on the front panel has a pull-down


menu with a large number of options.
Lets see this in action (example1_2.vi).
.

Those options are (for example):

Visible Items (Label, Caption, Unit Label, Digital Display,


Ramp (knobs and dials only)
Find Terminal - useful when a diagram is very large
Change to Control/Indicator
Representation (double, extended etc.)
Data Range
Format and Precision
and more depending on the specific component
Scale of the indicators can be changed during VIs execution
Very similar pull-down menu exists for terminals

.
2/21/2016

VIs are not usually run in the continuous mode. Generally, most of
the VIs have a while loop that controls the execution of this particular
VI.

Here is only a brief introduction into the while loop

example1_3.vi
iteration
terminal conditional
terminal

Whatever placed inside the while loop, will execute until an


appropriate logic value is received by the conditional terminal.

The iteration terminal counts the number of executions of the loop.

Now we can say more about Graphs and Charts

Graph - usually collect the data in an array and then plot the data to
the graph, which is similar to a spreadsheet that first stores the data
then generates a plot of it.

Charts - appends new data points to those already in the display.


On a chart, you can see the current reading or measurement in
context with data previously acquired.
2/21/2016

A Chart:

Lets see a chart in action (example1_4.vi), and XY Graph (gp1_5.vi)


.

A very important issue in every programming language: DEBUGGING

Pause execution
Start Single Stepping
Highlight execution Probe
(for beginners only)

Breakpoint

Graphical Programming Lecture 1- Fundamentals presented by Witold Noco Ph.D.


2/21/2016

A more practical example:

Design a simple SCADA system showing the following


measurements from the tank:
Temperature [C]
Pressure [MPa]

Temperature Input [4-20mA] (4mA = 20C; 20mA=300C)


Pressure Input [4-20mA] (4mA = 0,1MPa; 20mA=20MPa)

Show alert if Temp > 250 and signalise alarm if Temp > 280
Show alert if Press > 15 and signalise alarm if Press > 18

Vous aimerez peut-être aussi