EEE-351 Principles of Communication Systems
Lab Report-02:
Title: Introduction to Labview
Student Name Abdul Wahab
Faiq Jhanzaib
FA20-BEE-010
Registration Number FA20-BEE-048
BEE-5B
Class/Section
Instructor’s Name Sir Khan Afsar
Lab Assessment Marks
Pre Lab /1
/1
Ability to use software /5
Follow procedures /5 /10
In Lab
Troubleshoot software /5 /5
Q&A /5
Presentation /4
Post-Lab Analysis /4 /4
Writing /4
COMSATS University Islamabad (CUI), Islamabad Campus Page
1
Objectives
This lab familiarizes the students with some basic components of LabVIEW software. The following topics will
be covered in this lab:
- Front Panel and Block Diagram
- Constructing a Virtual Instrument (VI)
- Programming Structures (If/Else, For Loop)
- Mathscript Node
- Basic manipulations/operations
- Signal Generation and Spectral Analysis
Note: Understanding and performing this lab is essential for the subsequent USRP based communications
labs.
In Lab Tasks
Task 2.1
Construct a VI to add two input numbers and display the output on the front panel.
Procedure:
1. Start >> LabVIEW >> Blank VI (from ‘Getting Started’ screen
2. On the Front Panel, add two ‘Numeric Controls’ (inputs) and one ‘Numeric Indicator’ (output)
3. Name them ‘x’, ‘y’ and ‘x+y’
COMSATS University Islamabad (CUI), Islamabad Campus Page
2
4. Switch to the Block Diagram – note the inputs and outputs (same names as Front Panel)
5. Right-click on the Block Diagram and choose ‘Add’ under Numeric Palette – drag and drop on the Block
Diagram
6. Connect the inputs and outputs using the mouse for wiring
COMSATS University Islamabad (CUI), Islamabad Campus Page
3
7. Save the VI as Add2_Nos.vi
8. Modify the icon (top right corner) by right clicking on the icon and choosing ‘Edit icon’
9. After editing the icon, right click on the icon again and choose ‘Show connector’ and connect the inputs
and output appropriately.
10. The final VI should look like this
COMSATS University Islamabad (CUI), Islamabad Campus Page
4
11. To run the VI
enter x and y values in the Front Panel
Click the icon in the top left corner of the Front Panel
COMSATS University Islamabad (CUI), Islamabad Campus Page
5
Task 2.1:
Construct a VI to add two numbers. a=x+y?
Above figure shows that two number are added ‘Numeric Controls’ (inputs) and one ‘Numeric
Indicator’ (output) and we named them x, y and x+y.
Result:
Figure 1
Figure 1 shows the sum of two numbers stored in variable x and y and the result shown in x+y.
COMSATS University Islamabad (CUI), Islamabad Campus Page
6
Task 2.2
Input a numerical data from the Front Panel (Numeric Control) and display the result (Numeric Indicator) after
multiplication with a constant. Use the procedure in task 2.1 where required.
Result:
Figure 2
Figure 2 show the multiplication of constant with variable a and result shown in variable b.
COMSATS University Islamabad (CUI), Islamabad Campus Page
7
Task 2.3
Create a VI to add ‘5’ to an input number if it is greater than ‘10’, otherwise add ‘10’ to the input number and
display the output in either case in front panel. See figure 4 and section 2.7 for reference.
Procedure:
1. Open a blank VI
2. On the Front Panel, insert a ‘numeric control’ to obtain the input number and a ‘numeric indicator’ for the
output
3. In the Block Diagram, go to ‘Structures’ in the Programming Palette (right click for the Palette)
4. Click on ‘Case structure’, drag and drop it onto the Block Diagram. Adjust the size of the structure as needed
5. Insert a ‘Greater?.vi’ from ‘Comparison’ in the Programming Palette
6. Compare the input to a ‘constant’ (Numeric << Programming Palette) set to 10.
7. If the condition (number > 10) = True, set the case structure to ‘True’ and ‘Add’ 5 to the number
8. If the condition (number > 10) = False, set the case structure to ‘False’ and ‘Add’ 5 to the number
9. Edit the icon and the connector, after saving the VI.
COMSATS University Islamabad (CUI), Islamabad Campus Page
8
Result:
Figure 3
Figure 3 shows that the numeric value is greater than 10 it simply add 5 to a number but if
the number is less than 10 it will simply add 10 to a number.
Task 2.4
Create a VI to output the sum of numbers from1 to the input number.
Example: If number ‘5’ is input in the front panel, then sum of numbers from ‘1’ to ‘5’ should be displayed as
output. See section 2.7 and figure 5 for reference.
Procedure:
1. Open a Blank VI
2. In the Front Panel, insert a ‘numeric control’ and name it ‘input’ and a ‘numeric indicator’ and name it
‘output’.
3. On the Block Diagram, drag and drop a ‘For Loop’ from Structures in the Programming Palette
4. Connect the ‘Loop Count’ to ‘input’ and the ‘Loop Iteration’ to an ‘Add.vi’ (the loop iteration starts from
0 to (N-1)) and build an array with the results.
5. Sum the array elements.
6. Edit the icon and connector.
COMSATS University Islamabad (CUI), Islamabad Campus Page
9
Result:
Figure 4
Figure 4 shows that the input numeric value is 5 and the result shown in output is 15. The
function is such that to output the sum of numbers from 1 to the number input.
COMSATS University Islamabad (CUI), Islamabad Campus Page
10
Task 2.5
Create a VI to generate a composite signal with Mathscript node with two sinusoidal waves. The amplitude and
frequencies should be controllable on the run-time with knob and numeric control respectively. After composite
signal generation, show the time-domain waveform of composite signal along with the Power spectral density
(PSD) using “FFTPower Spectrum and PSD” VI. Then filter the composite signal in mathscript node and show
the time-domain and spectral plots in comparison with the earlier graphs.
Procedure:
1. Open a Blank VI
2. On the Block Diagram, drag and drop a ‘MathScript’ from Structures in the Programming Palette as
shown in the figure 6.
3. Write a MATLAB code in the ‘MathScript’ to generate a signal 𝑠𝑠(𝑡𝑡) = 𝑠𝑠1(𝑡𝑡) + 𝑠𝑠2(𝑡𝑡), where 𝑠𝑠1 =
𝑎𝑎1 cos(2𝜋𝜋𝜋𝜋1𝑡𝑡) and 𝑠𝑠2 = 𝑎𝑎2 cos(2𝜋𝜋𝜋𝜋2𝑡𝑡). Time vector, 𝑡𝑡, can be generated as previously done in lab 1
using a sampling frequency 𝑓𝑓𝑠𝑠.
4. Right-click the left side of MathScript Node frame and select Add Input from the shortcut menu.
5. Type 𝑎𝑎1 in the input terminal to add an input for the 𝑎𝑎1 variable in the script.
COMSATS University Islamabad (CUI), Islamabad Campus Page
11
6. Repeat the step 4-5 to add four more inputs as 𝑎𝑎2, 𝑓𝑓1, 𝑓𝑓2 and 𝑓𝑓𝑓𝑓.
7. Now on the front panel insert three ‘numeric control’ and name them ‘𝑓𝑓1’, ‘𝑓𝑓2’ and ‘𝑓𝑓𝑓𝑓’.
8. On the front panel insert two ‘Knob control’ and name them ‘𝑎𝑎1’ and ‘𝑎𝑎2’.
9. On the Block Diagram, join the numeric controls and knob controls to the inputs of the Math Script node.
10. In the Math Script node, write a MATLAB code to filter out the signal 𝑠𝑠1 from the composite signal 𝑠𝑠.
Keeping 𝑓𝑓1 < 𝑓𝑓2, use a 4th order low pass Butterworth filter to extract the signal 𝑠𝑠1 from the composite
signal 𝑠𝑠.
11. Name the filtered signal as 𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓_𝑠𝑠1
12. Right-click the right side of Math Script Node frame and select Add Output from the shortcut menu.
13. Type 𝑠𝑠 in the input terminal to add an output for the composite signal, defined as a 𝑠𝑠 variable in the
script.
14. Repeat the step 11-12 to add one more output as 𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓_𝑠𝑠1
15. Add two waveform graphs in the Block Diagram and connect one of them with the output of the Math
Script Node ‘𝑠𝑠’ and the other one with the output ‘𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓_𝑠𝑠1’
16. For the PSD of the signals ‘𝑠𝑠’ and ‘𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓_𝑠𝑠1’, take a connection from each signal and attach each with
two different blocks of “FFT Power Spectrum and PSD” VI. The “FFT Power Spectrum and PSD” VI
can be inserted as shown below
17. Insert two waveform graphs and to visualize the output of the PSD, connect the outputs of the PSD to
these two newly added waveforms.
18. For time-domain plots, go to the property of waveform graph and set the scaling factor multiplier to the
inverse of sampling frequency (inverse of sampling frequency is the sampling time)
19. Use Autoscale or set the maximum value in seconds to display the waveform (some cycles) properly.
Too many cycles in limited space will cause poor waveform display.
20. For PSD, set the multiplier to the sampling frequency Set the name to Frequency (Hz) and set the
maximum such that peaks are properly visible. The block diagram and front panel are illustrated below
COMSATS University Islamabad (CUI), Islamabad Campus Page
12
Block Diagram
(Write your own code in the blank space for
mathscript node)
Lab 01 13
Front Panel (Example)
Lab 01 14
Figure 5: It shows the given block diagram code with the implementation and the connecting wires to shows the response on the
system by changing values.
Lab 01 15
Results:
Figure 6:It shows the result of block diagram with the graphical representation by changing
the values in the blocks.
Lab 01 16
Critical Analysis / Conclusion
In this lab we learnt about software known as LABVIEW. We learn about the front panel
and block diagram and their purposes. We make some basic calculators which include
arithmetic operations like sum, multiplication, and some programming structures like for
loop and if/else condition etc. It supports thousands of inbuilt functions that range from
analysis and I/O etc.
1. Graphical Programming: LabVIEW uses a graphical programming language with a Front
Panel for user interaction and a Block Diagram for implementing program logic.2. Front Panel: It
serves as the user interface, allowing users to input data through controls and view results via
indicators. 3. Block Diagram: The place where you design program functionality by connecting
nodes that represent functions and operations. 4. Built-In Functions: LabVIEW offers an
extensive library of built-in functions and toolkits for various applications, saving time in program
development. 5. Programming Structures: For Loops: Useful for iterative tasks with a fixed
number of iterations. While Loops: For tasks that continue until a specific condition is met. If/Else
Conditions: Implement conditional logic in programs.
Lab 01 17