Sunteți pe pagina 1din 61

F.

Diagrama Bloc
Diagrama Bloc (DB) reprezint programul
propriu-zis dezvoltat n mediul LabVIEW i
conine codul surs al instrumentului virtual.
O DB conine urmtoarele elemente:
- terminale
- noduri
- fire de legtur
- structuri
Figure 2.15. Example of a Block Diagram and Corresponding Front Panel
Terminalele sunt porturi de intrare-ieire ce fac
legtura dintre PF i DB.
Ele sunt corespondentele obiectelor de pe PF i
se reprezint pe DB printr-un simbol care este n
concordan cu tipul de dat vehiculat de
obiect.
Terminale

Same label name


Terminalele pot fi terse de pe DB doar odat cu
obiectul de pe PF. Mutarea unui terminal pe DB
nu conduce la mutarea obiectului corespunztor
de pe PF.

Terminalele cu conturul ngroat corespund


controalelor, iar cele cu conturul subire
corespund indicatoarelor de pe PF.
View Terminals as Icons
By default, View as Icon
option enabled.
Deselect View as Icon for a
more compact view.
The terminals in Figure 2.15 belong to four
front panel controls and indicators. Because
terminals represent the inputs and outputs
of your VI, subVIs and functions also have
terminals shown at left. For example, the
connector panes of the Add and Subtract
functions have three node terminals. To
display the terminals of the function on the
block diagram, right-click the function node
and select Visible ItemsTerminals from the
shortcut menu.
Controls, Indicators, and Constants

Controls, indicators, and constants behave as inputs and outputs of the block
diagram algorithm. Consider the implementation of the algorithm for the area
of a triangle:
Figure 2.16. Area of a Triangle Front Panel
Figure 2.17. Area of a Triangle Block Diagram with Icon Terminal View
Figure 2.18. Area of a Triangle Block Diagram without Icon Terminal
View
Noduri n DB
Nodurile sunt obiecte de pe DB care sunt
caracterizate de un numr de intrri/ieiri i
care execut diverse operaii i funcii n
timpul rulrii IV-ului.
Nodurile sunt analoage instruciunilor,
funciilor i subrutinelor din limbajele de
programare bazate pe text.
Nodurile pot fi funcii, subVI-uri sau
structuri.
Noduri

Noduri

13
Structurile sunt elemente pentru controlul
proceselor, cum ar fi structura Case, bucla
For i bucla While.
Structurile din LabView sunt echivalentul
grafic al instruciunilor de ciclare (for, while)
i de decizie (if,case) din limbajele de
programare clasice.
O structur este reprezentat printr-un
dreptunghi a crui dimensiune poate fi
modificat.
Noduri Funcie
Functions are:
Fundamental operating elements of LabVIEW.
Do not have front panels or block diagrams, but do have
connector panes.
Has a pale yellow background on its icon.
Double-clicking a function only selects the
function.
Functions do not open like VIs and subVIs.
SubVI Nodes
SubVIs :
Are VIs that you use on the block diagram of another VI.
Have front panels and block diagrams.
Use the icon from the upper-right corner of the front
panel as the icon that appears when you place the
subVI on a block diagram.
When you double-click a subVI, the front panel
and block diagram open.
Any VI has the potential to be used as a subVI.
Any VI has the potential to be used as a
subVI. When you double-click a subVI on the
block diagram, its front panel window appears.
The front panel includes controls and
indicators. The block diagram includes wires,
icons, functions, possibly subVIs, and other
LabVIEW objects.
The upper right corner of the front panel
window and block diagram window displays
the icon for the VI. This is the icon that
appears when you place the VI on a block
diagram as a subVI.
SubVIs also can be Express VIs. Express VIs
are nodes that require minimal wiring because
you configure them with dialog boxes. Use
Express VIs for common measurement tasks.
You can save the configuration of an Express VI
as a subVI.
LabVIEW uses colored icons to distinguish
between Express VIs and other VIs on the block
diagram. Icons for Express VIs appear on the
block diagram as icons surrounded by a blue
field whereas subVI icons have a yellow field.
Express VIs
Express VIs:
Are a special type of subVI.
Require minimal wiring because you
configure them with dialog boxes.
Save each configuration as a subVI.
Icons for Express VIs appear on the
block diagram as icons surrounded by
a blue field.

19
Expandable Nodes versus Icons
You can display VIs and Express VIs as icons or as
expandable nodes. Expandable nodes appear as icons
surrounded by a colored field. SubVIs appear with a
yellow field, and Express VIs appear with a blue field.
Use icons if you want to conserve space on the block
diagram. Use expandable nodes to make wiring easier
and to aid in documenting block diagrams. By default,
subVIs appear as icons on the block diagram, and
Express VIs appear as expandable nodes.
To display a subVI or Express VI as an expandable
node, right-click the subVI or Express VI and remove
the checkmark next to the View As Icon shortcut menu
item.
Figure 2.19. Icon vs. expandable node
Firele de legtur
Transfer datele ntre obiectele de pe DB.
Fiecare fir are o singur surs de date, dar orict
de muli receptori. Firele au diferite culori, stiluri
i grosimi ce depind de tipurile de date
vehiculate. Un fir rupt, ce nu poate transporta
date, se reprezint printr-o linie ntrerupt. Un fir
cu dou surse de date este un fir rupt.
In figura urmtoare sunt prezentate principalele
tipuri de fire ce vehiculeaz date ntr-un IV.
Informaia vehiculat n VI-urile construite n
LabVIEW se prezint sub forma unei largi
varieti de tipuri de date.
Cele mai importante sunt datele numerice, dar
i alte tipuri cum ar fi booleenele, irurile de
caractere sau clusterele sunt de asemenea
foarte utilizate.
Mai jos sunt date tipurile de date numerice
precum i celelalte tipuri de date care sunt n
mod obinuit utilizate n construcia VI-urilor.
Tipuri de date cu firele de legtur
corespunztoare, n LabVIEW
Definitii
Array (Tablou): Un Array grupeaz date de acelai
tip i este alctuit din elemente i dimensiune.
Elementele sunt reprezentate de datele ce
alctuiesc tabloul. Dimensiunile sunt repezentate
de lungimea, nlimea sau adncimea tabloului. Un
tablou se poate construi din date de tip numeric,
boolean, ci de fiiere, string, waveform i cluster.
Se poate selecta din subpaleta Array&Cluster.
Cluster (Grupuri): Un Cluster grupeaz elemente
de date de tipuri diferite, la fel ca un mnunchi de
fire dintr-un cablu telefonic, n care fiecare fir din
cablu reprezint un element diferit al grupului
(cluster-ului).
Paleta de funcii
Paleta de funcii este o fereastr ce se deschide
doar de pe DB. Aceasta conine operatori, funcii,
noduri, structuri i subIV-uri cu ajutorul crora se
construiete programul n LabVIEW. Accesarea
paletei de funcii se face n modurile urmtoare:
View Show Functions Palette
MD pe DL.
In cel de-al doilea mod, paleta poate fi fixat ca
fereastr pe ecran prin mouse stnga pe pioneza
din stnga sus a acestei ferestre. Altfel, paleta se
nchide dup realizarea unui mouse stnga
oriunde pe DB.
To view or hide categories,
click the Customize button
on the palette, and select or
deselect the Change Visible
Palettes option.

Figure 2.20. Functions Palette


Funciile pe palet sunt grupate dup destinaia
lor. Cele mai utilizate sunt cele din subpaleta
Programming, care se expandeaz n mod
implicit. Celelalte sunt biblioteci care pot fi
apelate de ctre utilizator la construirea de
aplicaii dedicate.
De exemplu, dac se realizeaz un VI necesar
procesrii unor semnale achiziionate n
prealabil, se utilizeaz funcii din subpaleta
Signal Processing.
Dac este necesar un aparat matematic complex, avem
la dispoziie biblioteca Mathematics.
Multe din aceste subpalete nu sunt populate cu funcii.
Adugarea de biblioteci acestor subpalete se face prin
instalarea toolkit-urilor dedicate puse la dispoziie de
National Instruments.
Meniul shortcut al funciilor
Fiecare funcie are disponibil un meniu shortcut, cu
ajutorul cruia se stabilesc o serie de parametri, se pot
vizualiza etichete (funcia poate fi etichetat, la fel ca
orice terminal), se poate apela helpul mare, se pot
vizualiza exemple, se pot face descrieri ale funciei sau
se pot stabili punct de ntrerupere n vederea depanrii
programului.
Aceste opiuni sunt comune tuturor funciilor, n
prima parte a meniului, prin opiunile:
Visible Items
Help
Examples
Description and Tip
Set Breakpoint
Pe lng acestea, mai exist o serie de opiuni
specifice fiecrei funcii. O opiune comun mai
este Replace, prin care se permite utilizatorului
nlocuirea funciei cu o alta prin deschiderea
automat a paletei de funcii.
Bara cu unelte n DB
n figura de mai jos sunt prezentate comenzile
barei de meniuri a diagramei bloc.
Semnificaiile comenzii barei de meniuri sunt
prezentate n cele ce urmeaz:
Run lanseaz programul;
Run Continuously - lanseaz programul n mod
continuu ca i n limbajul de programare C cu
ajutorul buclei While;
Abort execution oprete programul;
High light execution (Execuie animat)
comand foarte util care permite vizualizarea
fluxurilor de informaii n blocurile diagramei n
timpul execuiei programului;
Retain Wires atunci cnd este activat
cablurile (wires) pstreaz o copie a ultimei
valori n cazul n care programul este oprit;
Step in ruleaz programul treptat revenind la
fiecare bucl n parte;
Step over ruleaz programul nod cu nod
fr ns a intra n detaliile de execuie ale
buclei;
Finish Block Diagram - oprete execuia.
G. Cutarea Controalelor, VI-urilor i
Funciilor
Until you are familiar with the location of VIs
and functions, search for the function or VI
using the Search button. For example, if you
want to find the Random Number function,
click the Search button on the Functions
palette toolbar and start typing Random
Number in the text box at the top of the
palette. LabVIEW lists all matching items that
either start with or contain the text you typed.
You can click one of the search results and
drag it to the block diagram, as shown in
Figure 2.21. Double-click the search result
to highlight its location on the palette.
If the object is one you need to use
frequently, you can add it to your Favorites
category. Right-click the object on the
palette and select Add Item to Favorites, as
shown in Figure 2.22.
Figure 2.21. Searching for
an Object in the Functions Figure 2.22. Adding an Item to the Favorites
Palette Category of a Palette
Similar cu butonul Search, se poate utiliza
cutia de dialog Quick Drop pentru a gsi
dup nume, diferitele obiecte i apoi
plasarea lor in DB sau n PF.
Pentru afiarea cutiei de dialog Quick Drop
se va selecta ViewQuick Drop. Apoi se
va tiprii numele obiectului dorit a se
aduga n DB sau n PF. LabVIEW va afia
rezultatul cutrii n Name Match List.
Figure 2.23. Searching for an Object in the Quick Drop Dialog Box
Apelarea helpului n LabVIEW
LabVIEW prezint un puternic sistem de helpuri
prin care utilizatorul este ghidat i ndrumat n
activitatea de programare.
In plus, utilizatorul are la dispoziie un numr
mare de exemple, grupate pe categorii de
aplicaii, n care sunt exemplificate diverse situaii
de operare a unor funcii i n care se pot gsi de
multe ori soluii tehnice.
Att helpurile, ct i exemplele, sunt disponibile
n meniul principal Help, accesabil att de pe PF
ct i pe DB.
De remarcat faptul c National Instruments pune la
dispoziie o bibliotec a utilizatorilor accesibil pe
Internet denumit LabVIEW Zone, n care
dezvoltatorii de instrumente virtuale pot gsi soluii la
problemele lor, dar pot oferi ei nii soluii prin
posibilitatea de a posta n aceast bibliotec propriile
VI-uri.
Local, exist dou tipuri de helpuri ale programului:
un help sumar, apelabil din meniul principal Help
Show Context Help, prin care se deschide o
fereastr permanent n care se afieaz informaii
sumare despre funcia de pe DB sau obiectul de pe
PF.
Informaia este afiat doar la suprapunerea
prompterului mouse-ului peste acel obiect sau
funcie (fr a se face clic). De asemenea, helpul
mic furnizeaz informaii despre funciile din
paleta de funcii la simpla accesare a acestora
cu mouse-ul.
Un help detaliat, specific doar funciilor de pe DB,
apelabil din meniul shortcut al funciei (mouse
dreapta pe funcie), opiunea Help. Help-ul
detaliat se mai poate deschide i apsnd pe
linkul Detailed help din help-ul sumar. Aici se dau
informaii mai detaliate privind funcia, inclusiv
exemple sau aplicaii.
H. Fluxul datelor

Programele scrise n limbaje procedurale,


bazate pe instruciuni text (Visual Basic,
C/C++, Java, etc.), sunt executate
secvenial, dup conceptul flux controlat,
n care instruciunile se execut ntr-o
ordine prestabilit prin program.
Limbajul G, dup care funcioneaz LabVIEW,
folosete tehnica fluxului de date (data flow),
n care datele i efectuarea funciilor i a
nodurilor se realizeaz n paralel.
Chiar n interiorul unui VI programul lucreaz
multitasking, n sensul c se pot executa mai
multe funcii n acelai timp, cu condiia ca
acestea s aib toate datele disponibile la
intrare.
Dup acest concept, pot rula n acelai timp mai
multe VI-uri. Aadar, un nod care are disponibile
datele la toate intrrile, este efectuat indiferent
de starea celorlalte noduri. Evident ns, dac
ieirea unui nod reprezint intrare pentru alt nod,
cel de-al doilea nod va trebui s atepte pn ce
este efectuat cel dinainte.
Un model al conceptului data flow este ilustrat
n figura urmtoare. In figur se prezint modul
n care se realizeaz funciile f i g, ambele de
variabile A i B, n cazul programrii procedurale
i al programrii n LabVIEW.
In cazul Programrii clasice nti se citesc datele
A, apoi cele B, dup care se efectueaz funcia
f(A,B), apoi funcia g(A,B).
De remarcat c funcia g se efectueaz abia
dup efectuarea funciei f, dei datele de intrare
sunt disponibile pentru ambele funcii. E posibil
ns ca datele B s fie disponibile naintea
datelor A. Programul ateapt nti datele A, apoi
le citete pe cele B, ducnd la pierdere de timp.
In cazul programrii n LabVIEW, nu exist o
prioritate ntre intrrile A i B, fiecare dat fiind
citit de ndat ce este disponibil.
Mai mult, funciile f i g se efectueaz
independent una de cealalt, de ndat ce datele
de intrare sunt disponibile.
In felul acesta se obine o economie substanial
de timp, esenial n aplicaiile n care operaiile
trebuie s se succead cu vitez (ex.: achiziii de
semnale de frecven ridicat i prelucrarea
concomitent a informaiei).
Alocarea i managementul memoriei se face
automat de ctre program, doar pentru datele
care sunt n lucru. Dup ce datele cu care s-a
lucrat nu mai sunt necesare, memoria se
elibereaz. In felul acesta se realizeaz i o
economie important de resurse.
For a dataflow programming example, consider a block
diagram that adds two numbers and then subtracts
50.00 from the result of the addition, as shown in Figure
2.24. In this case, the block diagram executes from left
to right, not because the objects are placed in that order,
but because the Subtract function can not execute until
the Add function finishes executing and passes the data
to the Subtract function. Remember that a node
executes only when data are available at all of its input
terminals and supplies data to the output terminals only
when the node finishes execution.

Figure 2.24. Dataflow Programming Example


In Figure 2.25, consider which code segment would execute first
the Add, Random Number, or Divide function. You cannot know
because inputs to the Add and Divide functions are available at
the same time, and the Random Number function has no inputs.
In a situation where one code segment must execute before
another, and no data dependency exists between the functions,
use other programming methods, such as error clusters, to force
the order of execution.

Figure 2.25. Dataflow Example for Multiple Code Segments


I. Realizarea unui VI simplu
Most LabVIEW VIs have three main tasksacquiring
some sort of data, analyzing the acquired data, and
presenting the result. When each of these parts are
simple, you can complete the entire VI using very few
objects on the block diagram. Express VIs are
designed specifically for completing common,
frequently used operations. In this section, you learn
about some Express VIs that acquire, analyze, and
present data. Then you learn to createa simple VI
that uses these three tasks, as shown in Figure 1.27.
On the Functions
palette, the Express VIs
are grouped together in
the Express category.
Express VIs use the
dynamic data type to
pass data between
Express VIs.

Figure 1.27. Acquire, Analyze,


and Present Example Front
Panel Window and Block
Diagram Window
Acquire
Express VIs used for the Acquire task include the
following: DAQ Assistant, Instrument I/O Assistant,
Simulate Signal, and Read from Measurement File.
DAQ Assistant
The DAQ Assistant acquires data through a data
acquisition device. You must use this Express VI
frequently throughout this course.
Instrument I/O Assistant
The Instrument I/O Assistant acquires instrument
control data, usually from a GPIB or serial
interface.
Simulate Signal
The Simulate Signal Express VI generates
simulated data such as a sine wave.
Read From Measurement File
The Read From Measurement File Express VI
reads a file that was created using the Write To
Measurement File Express VI. It specifically reads
LVM or TDM file formats. This Express VI does not
read ASCII files.

Analyze
Express VIs used for the Analyze task include the
followingAmplitude and Level Measurements,
Statistics, Tone Measurements, and so on.
Amplitude and Level Measurements
The Amplitude and Level Measurements
Express VI performs voltage measurements on
a signal. These include DC, rms, maximum
peak, minimum peak, peak to peak, e.t.c.
Statistics
The Statistics Express VI calculates statistical data from a
waveform.This includes mean, sum, standard deviation,
and extreme values.
Spectral Measurements
The Spectral Measurements Express VI performs spectral
measurement on a waveform, such as magnitude and
power spectral density.
Tone Measurements
The Tone Measurements Express VI searches for a single
tone with the highest frequency or highest amplitude. It
also finds the frequency and amplitude of a single tone.
Filter
The Filter Express VI processes a signal through filters
and windows. Filters used include the following:
Highpass, Lowpass, Bandpass, Bandstop, and
Smoothing. Windows used include Butterworth,
Chebyshev, Inverse Chebyshev, Elliptical, and Bessel.
Present
Present results by using Express VIs that perform a
function, such as the Write to Measurement File
Express VI, or indicators that present data on the front
panel window. The most commonly used indicators for
this task include the Waveform Chart, the Waveform
Graph, and the XY Graph. Common Express VIs include
the Write to Measurement File Express VI, the Build
Text Express VI, the DAQ Assistant, and the Instrument
I/O Assistant. In this case, the DAQ Assistant and the
Instrument I/O Assistant provide output data from the
computer to the DAQ device or an external instrument.

Write to Measurement File


The Write to Measurement File Express VI writes
a file in LVM or TDMS file format.
Build Text
The Build Text Express VI creates text, usually
for displaying on the front panel window or
exporting to a file or instrument.
Running a VI
After you configure the Express VIs and wire them together, you can run
theVI. When you finish creating your VI, click the Run button on the toolbar
to execute the VI.
While the VI is running, the Run button icon changes to the figure shown at
left. After the execution completes, the Run button icon changes back to its
original state, and the front panel indicators contain data.
Run Button Errors
If a VI does not run, it is a broken, or
nonexecutable, VI. The Run button appears
broken when the VI you are creating or editing
contains errors.
If the button still appears broken when you finish
wiring the block diagram, the VI is broken and
cannot run.
Generally, this means that a required input is not
wired, or a wire is broken. Press the broken run
button to access the Error list window. The Error
list window lists each error and describes the
problem. You can double-click an error to go
directly to the error.
Refer to Figure 1.28 to answer the following quiz questions.

Figure 1.28. Dataflow Questions

1. Which function executes first: Add or Subtract?


a. Add
b. Subtract
c. Unknown
2. Which function executes first: Sine or Divide?
a. Sine
b. Divide
c. Unknown
3. Which function executes first?
a. Random Number
b. Divide
c. Add
d. Unknown
4. Which function executes last: Random, Subtract or Add?
a. Random Number
b. Subtract
c. Add
d. Unknown
5. What are the parts of a VI?
a. Front panel window
c. Project
b. Block diagram window
d. Icon/connector pane

S-ar putea să vă placă și