Professional Documents
Culture Documents
Faculty of Engineering
Electronics and Electrical Communications Engineering Department
Experiments Notes
For
Communications Laboratory
4th year
Prepared by:
First semester
2021-2022
Table of Contents
FACULTY OF ENGINEERING
COMMUNICATIONS LABORATORY
FOURTH YEAR
EXPERIMENT (C1)
ATTENDANCE REPORT
C1: Introduction to LabVIEW and NI-USRP
Part 1: Introduction to LabVIEW
1-Introduction:
LabVIEW (Laboratory Virtual Instrument Engineering Workbench) is a graphical
programming language that uses icons instead of lines of text to create applications. In
contrast to text-based programming languages, where instructions determine the order
of program execution, LabVIEW uses dataflow programming, where the flow of data
through the nodes on the block diagram determines the execution order of the VIs and
functions. VIs, or virtual instruments, are LabVIEW programs that imitate physical
instruments. In LabVIEW, you build a user interface by using a set of tools and
objects. The user interface is known as the front panel. You then add code using
graphical representations of functions to control the front panel objects. This graphical
source code is also known as block diagram code.
LabVIEW programs are called virtual instruments, or VIs, because their appearance
and operation imitate physical instruments, such as oscilloscopes and multi-meters.
A VI contains the following two components:
• Front panel: Serves as the user interface.
• Block diagram: Contains the graphical source code that defines the functionality of
the VI.
As shown in Figure (1) simple add and subtract program the code in the block
diagram panel and user interface in the front panel to set inputs and see outputs.
C1-1
1.1-Block Diagram Panel:
Block diagram panel contains the graphical source code that defines the functionality
of the VI to place objects on the block diagram, simply drag and drop them from
the Functions palette. The Functions palette automatically appears when you right-
click anywhere on the block diagram workspace it contains many functions,
constants, structures…etc. as shown in Figure (2).
Figure (3) – a) Structures functions – (b) Array functions -(c) Comparison functions
C1-2
1.2-Front Panel:
The front panel window of the VI is the graphical user interface or GUI of a VI. The
front panel window contains a toolbar across the top and controls palette as shown in
Figure (4) that you can access by right-clicking anywhere on the front panel.
Figure (5) – (a) Numeric controls – (b) Boolean controls -(c) Graph controls
C1-3
1.3-Examples:
Example 1: Create a VI to add two Numbers
1) Start LabVIEW>>File>>New VI, front panel and block diagram panel appear.
2) Right click on anywhere on block diagram panel functions palette appears.
3) From numeric functions choose add block.
4) Right click on one of add block's inputs and choose create then control a control
block connected to one input.
5) Repeat step 4 to the other input of add block.
6) Right click on the output of add block and press create indicator.
Note: control refers to input and indicator refers to output.
7) Now the block diagram panel and the front panel is as shown in Figure (6)
8) Enter x and y values in front panel and click the icon in the top left corner of
the front panel then result of addition will appear in "x+y" indicator.
C1-4
7) Connect output of greater block to the input of case structure as shown in Figure (7).
C1-5
Figure (9)-spaghetti code design can be messy
Any questions you might have about LabVIEW programming, the following tutorials
and reference material [1-2] will help guide you through the process of learning
LabVIEW:
2-Lab Experiment
In this experiment you will build two subVIs: source.vi and error detect.vi. You will
then plug your subVIs into a simulator provided to you (shown in Figure 10). The
goals of this pre-lab are:
(1) To practice LabVIEW programming.
(2) To understand how to build and use subVIs.
What is subVIs?
Modularity, by definition, means to use modules or smaller parts for the overall
objective. Within LabVIEW, program modularity means creating smaller sections of
code known as subVIs. SubVIs are the same as VIs. They contain front panels and
block diagrams, but you call them within a VI. A subVI is similar to a function in
text-based programming languages.
C1-6
. Figure (10)-Simulator block diagram
8) Go to front panel and press run the random bit should appear at the front panel.
9) To generate a stream of random bits with certain length, go to block diagram and
choose from structures function for loop.
10) Right click on the letter "N" and choose create control to control the number of
iterations of for loop.
C1-7
11) Inside the for loop put random number generator block followed by round to
nearest block and connect output of round to nearest block to the right edge of for
loop as shown in Figure (12).
14) Go to front panel and enter Number of bits (for example 10) then press run
random bits appear as shown in Figure(14).
C1-8
2.2-Create error detector SubVi:
Error detector aims to calculate bit error rate by comparing the transmitted bits
sequence and the detected bits sequence the details of error_detect.vi are given in
Table (2) there are number of ways to implement error detector SubVI in LabVIEW
for instance compare bit by bit between transmitted sequence and detected sequence.
Table (2)
Inputs Transmitted bit sequence
Detected bit sequence
Outputs Bit error rate
1) For loop takes bit by bit from the transmitted sequence and detected sequence then
compare between them using if equal block If transmitted bit and detected bit are
equal the output of if equal block is true and hence add zero to error, in case of
bits aren't equal output of if equal block is true and hence add one to error then
divide the number of error bits by the total number of bits by using divide block
to calculate BER.
2) To add shift register to the for loop right click on the for loop and then press add
shift register then right click on the right node of shift register and press create
constant and set this constant equals zero which is the initial value of error.
3) Now convert this code into subvi as shown previously and name it
"error_detect.vi"
C1-9
2.3-Simualte BPSK and QPSK vs SNR:
Now source.vi and error_detect.vi implemented successfully and ready to use with
simulator go to folder named "C1 " on desktop then replace source.vi and
error_detect .vi with yours vis.
1. Open awgn_simple.vi and check from block diagram panel that subvis are
connected successfully as shown in Figure (10)
2. Go to front panel and set the following parameters:
Modulation type="BPSK" Length =1000 Iterations =100
3. Vary the noise power from 0 dB to -10 dB with step -2 dB then run the code after
each step and fill the Table (3).
Table (3)
Noise power(dB) -0 -2 -4 -6 -8 -10
BER_BPSK
4. After each step check data symbols figure and received symbols figure on the
front panel then comment on what do you realize?
5. Repeat step (3&4) for QPSK modulation and fill Table (4).
Table (4)
Noise power(dB) -0 -2 -4 -6 -8 -10
BER_QPSK
C1-10
C1:Introduction to LabVIEW and NI-USRP
Summary
In this part of the introductory lab you will learn about the NI RF hardware
to be used in the Wireless Communications Lab. You will acquaint yourself
with the relevant documentation and references available to you with regard
to the RF hardware. You will build some simple example VI’s from the NI
documentation and use some of the existing LabVIEW tools (e.g., RF Signal
Analyzer Demo Panel). In the final part of this lab you will explore some of
the VIs that you will use in future labs to control the RF hardware. This part
of Lab 1 introduces NI RF hardware as a tool for digital communication, and
gets you familiar with the help/documentation available for the hardware you
will be working with throughout the course.
In this lab, for the pre-lab, you are required to turn in only the questions
given in Section 2. There are no pre-lab VIs for this lab. As a part of the
lab session, you will construct two VIs by following the instructions given in
the NI documentation. The questions given in Section 3 need to be answered
during the lab only. Please do not submit the answers to these questions with
your pre-lab. At the end of this lab, you will submit a lab report, the details
of which are given at the end of this document.
1 RF Hardware in Wireless
Communications Lab
In this course you will use software recofigurable RF hardware from National
Instruments to build a digital communication system. This hardware can be
easily configured using LabVIEW. The RF Hardware used in the lab is the
National Instruments USRP (Universal Software Radio Peripheral). Figure 1
shows a USRP connected to a PC (running LabVIEW). This PC controls the
USRP through the gigabit ethernet cable connecting the two together. In this
section you will learn more about these modules.
C1-11
Lab C1: Part 2 Introduction to NI RF Hardware
C1-12
Lab C1: Part 2 Introduction to NI RF Hardware
2 Pre-Lab Questions
Review the documentation for the USRP (Help⇒NI-USRP Help). You will
find that the help files found under Devices⇒NI USRP-292x Specifications
and Devices⇒ NI USRP-2920 contain the most comprehensive information
about the USRP. For a deeper understanding of the specifications, please refer
to the following documents:
Answer the following questions about the USRP after reading through the
help files.
4. Why do you think the DDC is implemented? What is its main benefit?
Answer the following general concept questions using [7], [13] and [14].
C1-13
Lab C1: Part 2 Introduction to NI RF Hardware
2. Click New, choose Blank VI, and click OK to create a blank VI.
3. Display the block diagram by clicking it or selecting Window ⇒ Show Block Diagram.
4. Navigate to the NI USRP VIs on the Functions ⇒ Instrument I/O ⇒ Instrument Drivers⇒
NI-USRP⇒ TX palette then choose the four main block of USRP TX as follows:
• niUSRP Open TX Session VI.
• niUSRP Configure Signal VI.
• niUSRP Write TX Data (poly) VI.
• niUSRP Close Session VI
5. Now we are going to create the block diagram shown in Figure 4 by placing the four core VIs
on the block diagram in the order they appear in Figure 4.
6. Hover the cursor over the device name terminal on the niUSRP Open TX Session VI and right
click. Select Create⇒Control to create a front panel field where you specify the NI USRP
device name.
7. Hover the mouse tool over the IQ rate, carrier frequency, and gain terminals of the niUSRP
Configure Signal VI. Right-click each terminal and select Create⇒Control from the shortcut
menu to create frequency, IQ rate, and gain controls
8. Display the front panel by clicking it or selecting Window⇒Show Front Panel. Fields are
displayed in which you can specify a frequency, IQ rate, and gain.
C1-14
Lab C1: Part 2 Introduction to NI RF Hardware
11. Enclose the niUSRP Write TX Data (Poly) VI in the While Loop.
12. Hover the mouse tool over the Loop Condition terminal of the While Loop then Right-click
the Loop Condition terminal and select Create Control from the shortcut menu to create a
STOP button on the VI front panel.
C1-15
Lab C1: Part 2 Introduction to NI RF Hardware
13. Place the Initialize Array function down on the block diagram. Right-click on the dimension
size input and select Create ⇒Constant then Double-click on the constant that was create and
change it to 1 (baseband signal =1).
15. Wire the output of the Initialize Array function block to the data input of the niUSRP Write
Tx Data (poly) VI.
16. Finally, wire the STOP button that was created for the While Loop to the end of data? Input of
the niUSRP Write Tx Data (poly) VI and select CDB from that VIs drop down menu.
Remember that in order to operate your transmitter VI, you must properly configure the
USRP IP Address for the USRP (an input to niUSRP Initialize.vi). You can find the IP addresses
for all of the USRP devices connected to your PC by using the NI-USRP Configuration Utility.
Once that is properly configured, set the rest of the parameters as follows and run the VI:
1. On the other PC open LabVIEW then Click New, choose Blank VI, and click OK to create a
blank VI.
2. Display the block diagram by clicking it or selecting Window ⇒ Show Block Diagram.
3. Navigate to the NI USRP VIs on the Functions ⇒ Instrument I/O ⇒ Instrument Drivers⇒
NI-USRP⇒ RX palette then choose the four main block of USRP TX as follows:
• niUSRP Open RX Session VI.
• niUSRP Configure Signal VI.
• niUSRP Initiate Signal VI.
• niUSRP Fetch RX Data (poly) VI.
• niUSRP Abort VI.
• niUSRP Close Session VI.
To view the received baseband signal and test your transmitter and receiver you will graph the
real and complex parts of the signal acquired by niUSRP Fetch Rx Data (poly).vi. To do this:
5. Place two waveform graphs on the front panel of your VI. These can be accessed from the All
Controls tool palette in the Front Panel (All Controls⇒Graph⇒ Waveform Graph.vi).
C1-16
Lab C1: Part 2 Introduction to NI RF Hardware
6. Retrieve the real and imaginary waveform components from the Data output of niUSRP Fetch Rx
Data (poly).vi. Use Get Complex IQ Component.vi to retrieve these components from
IQWaveform. ThisVI can be accessed from the ALL Functions tool palette on the block diagram
(RF Communications Modulations Analog Utilities MT Get complex IQ Component.VI)
7. On the block diagram, connect the terminal for each waveform graph to its corresponding
waveform for the real and imaginary parts of the acquired signal as shown in Figure 6. (Inside of
the While-Loop structure).
C1-17
Lab C1: Part 2 Introduction to NI RF Hardware
9. Run Transmitter and Receiver VIs simultaneously view the IQ signal on the front panel of
Receiver VI.
Although the baseband signal transmitted from the Transmitter VI is constant equals 1 (In-phase =1,
Quadrature =0) we will receive sinusoidal In-phase and quadrature components on the receiver side.
This occurs because there is carrier frequency offset between the two USRPS used in transmitter and
receiver and can be discussed as follows:
1. Define as the in-phase component, as the quadrature component and as the carrier
frequency of the transmitter. The transmitted signal can be represented as follows:
=
2
+ 2
.
2. The receiver local oscillator generates carrier frequency with frequency mismatch equals ∆
than that of the transmitter carrier frequency so the detection of in-phase component will be as
follows :
= 2
2[ + ∆ ]
=
cos 2[2 + ∆ ]
+ cos 2 ∆
+ sin 2[2 + ∆ ]
+ sin 2 ∆
3. Then passing
to low pass filter to get the detected in-phase component as follows:
ℎ ! ! = cos2 ∆
+ sin 2 ∆
C1-18
Lab C1: Part 2 Introduction to NI RF Hardware
REFERENCES
[1] National Instruments LabVIEW 101, retrieved September 13, 2011, from http://www.ni.com/lv101.
[2] National Instruments, LabVIEW Fundamentals, August 2007, retrieved September 23, 2011, from
http://www.ni.com/pdf/manuals/374029c.pdf.
[3] R.W. Heath Jr., Digital wireless Communication: Physical layer exploration lab using the NI USRPTM, National
Technology & Science Press, 2012,
C1-19
Ain Shams University
Faculty of Engineering
Electronics & Communications Eng. Dept.
COMMUNICATIONS LABORATORY
FOURTH YEAR
Experiment (C2)
Line Coding
Attendance Report