Anda di halaman 1dari 18

Lab3: introduction to Labview

Introduction: Labview is a graphical programming language that uses items instead


of lines of text.
Labview uses dataflow programming but in text-based programming
languages, instructions determine the program execution

You can build a user interface using Labview and the user interface is
known as Front pane
Labview programs are called virtual instruments, because their
appearance and operation imitate the physical instruments

Labview program consists of two components:


Front panel: serves as a user interface
Block diagram: contains the graphical code source
Front panel:
The front panel contains the user interface which can be built by controls
like knobs, pushbutton, LEDS and toggle switches. The front panel is used
to simulate the input devices and supply data to the block diagram. In
addition to that it is used to display the output of the block diagram graphical
code. The front panel is shown in figure 1. The front panel contains the
control palette. The control palette is found only on the front panel. The
control palette is shown in figure 2

Figure 1Front panel screen

Figure 2 Control palette

Block diagram panel:


The block diagram screen contains the graphical code. The items on the
front panel appear as terminals in the block diagram screen. The block
diagram panel contains the functions palette which is available only on the
block diagram screen. The block diagram and the function palette are shown
in figure 3 and figure 4.

Figure 3 block diagram screen

Figure 4 Functions palette

What Do the Different Colors of Wires in Labview Indicate?


To construct a complete code using Labview you need to wire the blocks in
the block diagram screen. Wires have different colors each color indicates a
type of data

Green
Blue
Orange
pink

Boolean data type (0,1)


Integer
Floating point (double)
String data type

Contents of the control palette:


Name
Num Ctrls

Buttons

Text Ctrls

leds
Graph indicator

Use
Use to input a number
through knobs , dials ,
and slides
Use to insert a
pushbutton or toggle
switch and slide switch
User to inter a string or
to display a string or to
make a label to make to
code more realistic and
readable
Used as indicators
Used to display a graph
on the front panel

Contents of the function palette:


Name
Input

Output
Exec control
Arith & comp

Use
Use to create an input
like a simulated signal
and DAC input or voice
input
Use to create an output
like a DAC output
Use to create case
structure and loops
Use to make the
arithmetic operations
and comparison
operations

Example (1):Make a labview program that ask the user to enter(x,y) two numbers and the
program find :

X+y
X*y
X^y
x-y
x/y if y equal zero (answer equal infinity) a red led should light to
warn the user

solution:
The purpose of this program is to learn the arithmetic operations like (add ,
subtract , division , multiplication). The front panel should contain two input
for the two number and four output for the for operation and a warning led
as shown in figure 5

Figure 5 front panel of example 1

figure 6 shows the block diagram screen

Figure 6 block diagram of example 1

comment :
Note that Labview complete the division operator when the denumerator
equals zero

Example (2) (Formula)


Make a labview program to execute the following formula :

Y1=10x1 + 5
Y2=(x1*x2)2+20x3
Y3=sinx2+cosx3

Solution

The front panel should contain three inputs and three outputs as shown in
figure 7

Figure 7 front panel of example 2

Figure 8 shows the block diagram screen:

Figure 8 block diagram of example 2

Comment
Formula tool can be found at arithmetic and comparison and is used to
enter a formula in an easy way for the user

If the formula is
correct then this
led is green

Example 3
Make a labview program that takes the mark of a student. The program
contain five leds as following :
Led 1
Led 2
Led 3
Led 4
Led 5

Mark( 90-100)
Mark(80-89)
Mark (70-79)
Mark (60-69)
Fail

Solution :The purpose for this example is to learn the comparison operators. The front
panel should contain five led as output and one input for the mark as shown
in figure 9

Figure 9front panel of example 3

Figure 10 shows the block diagram screen

Example 4 graph in labview


Make a labview program that plot a sine wave and control its frequency,
amplitude and phase
Solution
The program should contain three knobs (frequency, phase, amplitude) and a
graph screen to show the output.
Figure 11 shows the front panel of the system

Figure 11 front panel of example 4

Figure 12 shows the block diagram of example 4

Figure 12 block diagram of example 4

Comment :
Simulated signal can be found on the function palette >> input
To choose
the signal
type

To add noise
to the signal

What happen when increasing the frequency over 500?why?

Example 5
Make a Labview program that plot two signals on the same graph and
control each signal amplitude and frequency and phase, the first signal is
sine and the second is triangle.
Solution
the program should contain six knobs (two signals) and one graph screen as
shown in figure 13

Figure 13 front panel of example 5

Figure 14 shows the block diagram of example 5

Use to plot to signal on the


same graph similar to hold on
instruction in Matlab and can
be found at function palette>>
signal manipulation

Figure 14 block diagram of example 5

Example 6
Make a Labview program that plots a sine signal or a square according to a
toggle switch control by the user. If the switch is on then the plotted signal is
sine if the switch is off then the plotted signal is square and add noise to
each signal with the noise amplitude is control by the user
Solution
This example contain four knobs (frequency ,phase, amplitude, noise
amplitude ) as shown in figure 15

Figure 15 front panel of example 6

Figure 16 shows Block diagram of example 6

The select operator can be found


in arithmetic and comparison
>>comparison
Work as a multiplexer with a
selector to choose the output

Figure 16 block diagram of example 6

Report exercises:1- Make a Labview program that calculate the average of four number if
the average is bigger than 100 then a green led will be on and if equal
a yellow led will be on and if less a red led will be on.
2- Make a Labview program that execute the following formula

y x 1 x 2 20
y x1 *x 2 *x 3

y (x 1 ) 2

3- Make a Labview program that plot two signal (sine and saw tooth) on
the same graph and control the amplitude and phase and frequency of
each signal
4-

(bonus) make a Labview that select one signal out of four signal to
plot and the program contain only for knobs (amplitude, phase ,
frequency , noise amplitude) and two toggle switches and one graph
screen

Anda mungkin juga menyukai