Lab3: introduction to Labview -...
Transcript of Lab3: introduction to Labview -...
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
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 Boolean data type (0,1)
Blue Integer
Orange Floating point (double)
pink String data type
Figure 4 Functions palette
Contents of the control palette:
Name Use
Num Ctrls Use to input a number
through knobs , dials ,
and slides
Buttons Use to insert a
pushbutton or toggle
switch and slide switch
Text Ctrls User to inter a string or
to display a string or to
make a label to make to
code more realistic and
readable
leds Used as indicators
Graph indicator Used to display a graph
on the front panel
Contents of the function palette:
Name Use
Input Use to create an input
like a simulated signal
and DAC input or voice
input
Output Use to create an output
like a DAC output
Exec control Use to create case
structure and loops
Arith & comp 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 6 shows the block diagram screen
Figure 5 front panel 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
Figure 6 block diagram of example 1
The front panel should contain three inputs and three outputs as shown in
figure 7
Figure 8 shows the block diagram screen:
Figure 7 front panel of example 2
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
Example 3
Make a labview program that takes the mark of a student. The program
contain five leds as following :
Led 1 Mark( 90-100)
Led 2 Mark(80-89)
Led 3 Mark (70-79)
Led 4 Mark (60-69)
Led 5 Fail
If the formula is
correct then this
led is green
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 10 shows the block diagram screen
Figure 9front panel of example 3
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 12 shows the block diagram of example 4
Figure 11 front panel of example 4
Figure 12 block diagram of example 4
Comment :
Simulated signal can be found on the function palette >> input
What happen when increasing the frequency over 500?why?
To choose
the signal
type
To add noise
to the signal
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
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 14 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 15 front panel of example 6
Figure 16 shows Block diagram of example 6
Figure 16 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
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
1 2 20y x x
1 2 3* *y x x x
2
1( )y x
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