Lab 2: Digital Modulations Due: November 1, 2018 In this lab you will use a hardware device (RTL-SDR which has a frequency range of 25 MHz 1.75 GHz) to implement a digital receiver with Quaternary Phase Shift Keying (QPSK) modulation scheme. An ASCII (text) message is transmitted wirelessly from a USRP device and you need to use your RTL-SDR device in order to receive and and decode the transmitted message. A zip file including all the required files is uploaded on the class website. Please note you need to attend the lab sessions to complete this lab. Setup. Use sdrinfo command to make sure your RTL-SDR device is properly installed and ready to use. Download the zip file EE107 Lab2 files from the class website and extract it into the following path: Z:\MATLAB\EE107_Lab2_files In Home tab of MATLAB go to the Set Path, click on Add with Subfolders and select the above folder. Click on the Save button and then close the window. This will add the path of required libraries for the Simulink models provided in the folder. Part 1. Finding the PPM error (frequency offset) of your RTL-SDR device Parts Per Million (PPM) is a measurement unit used to quantify very small values. In this lab, the frequency offset of the RTL-SDR is measured in PPM, and the value obtained can subsequently be used as a correction parameter when interfacing with the device via MATLAB or Simulink. The RTL-SDR may have quite a significant offset due to its hardware, and fining this offset can be important depending on the method of communication. It is more important for digital communication schemes, while analog communications are relatively tolerant by comparison. Note that every RTL-SDR will have different hardware characteristics, and you will need to complete this step separately for each device you may have [1]. The USRP transmitter is sending a single tone sine wave with a frequency of 20 khz and sampling rate of 200 khz. The carrier frequency is 433MHz, and since the USRP radio has a fixed master clock rate of 100 MHz, it is configured to resample the signal from 200 khz to 100 MHz before modulation, by interpolating by a factor of 500. The block diagram of the USRP transmitter is as follows: The signal received by the RTL-SDR is sampled at a rate of 2.4 MHz, and then decimated to reduce the sampling rate to 400 khz. Some matrix operations are then performed to find the frequecy offset value. Finally, the PPM error is obtained by the following equation [1] f offset e PPM = f c 10 6 (1) 1
Figure 1: USRP transmitter [1] Figure 2: RTL-SDR receiver [1] The block diagram of the RTL-SDR receiver is depicted in Figure 2. Open the Simulink model rtlsdr rx ppm.slx in MATLAB. Run the model and find the frequency offset and PPM error of your RTL-SDR device. The spectrum analyzer window will show a visual representation of how severe is the frequency error of your RTL-SDR. Note that the tone should be positioned at 0 Hz in the baseband spectrum. After running the simulation for around 3 minutes, the RTL-SDR should be warmed up and the frequency offset and PPM values should stabilize. When this happens, stop the simulation and read the measured PPM value. Note that the PPM value must be an integer. Then, open the RTL-SDR Receiver Block and modify the PPM value of your device. Re-run the model, and wait for few minutes again to see if the correction has worked. In this case a PPM value of 0 should be shown in the display box. Lastly, make a note of the PPM value you determined during this exercise as you will need it for the following parts of the lab. 2
Part 2. Finding the carrier frequency In this part of the lab, you are supposed to find the carrier frequency of the USRP transmitter. The carrier frequency is between 400 MHz - 500 MHz, and you need to perform a frequency sweep with your RTL-SDR receiver to find the exact value of carrier frequency. Open the m-file rtlsdr rx specsweep.m in MATLAB Editor. Run the code and observe the spectrum sweep plot. The spectrum sweep will be saved in the same folder you are running the code. For example, the RTL-SDR spectrum sweep obtained in Logan Airport (BOS) is shown in Figure 3. Your output should be something similar to Figure 3. Choose a different name for the output figure (in line 20), and then ask the TA to turn on the USRP transmitter. Run the program again to generate a new spectrum sweep plot. Compare the obtained figure in order to find the carrier frequency f c. Enter the PPM value of your RTL-SDR device in line 28 of the code and comment on the effect of frequency offset on finding the carrier frequency. Try two other values (+1000 and -1000) for PPM and find the frequency offset using the spectrum. Check to see if the results agree with Equation (1). Modify the frequency range (in lines 21 and 22) to sweep the FM radio band (88 MHz - 108 MHz). Are you able to specify the FM stations that you listened to in Part 3 of Lab 1 (92.9 MHz, 104.1 MHz, and 106.7 MHz)? Is there still a frequency offset? RTL-SDR Spectrum Sweep Range = 50MHz to 1750MHz Bin Width = 10.9375kHz Number of Bins = 155648 Number of Retunes = 1216 40 Power Ratio (dbm) [relative to 50 load] 20 0-20 -40-60 -80-100 200 200 400 600 800 1000 1200 1400 1600 Frequency (MHz) Relative Power (Watts) 150 100 50 0-50 200 400 600 800 1000 1200 1400 1600 Frequency (MHz) Figure 3: RTL-SDR spectrum sweep at Logan Airport (BOS) [1] 3
Figure 4: RTL-SDR hardware followed by a receiver Figure 5: Block diagram of a QPSK receiver Part 3. QPSK receiver using RTL-SDR In this part we will use the MATLAB model for transmission from a USRP node and reception at an RTL- SDR device using QPSK modulation [2]. The USPR will transmit a text message continuously over the air, and your task is to receive this message using your RTL-SDR device. The receiver block diagram for the RTL-SDR is given in Figure 4 and the detailed diagram of the QPSK receiver is given in Figure 5. The shadowed blocks are the ones you will need to study by either plotting the input or the output or both as specified in each step below. Initialization Open the Simulink model rtlsdr qpsk rx.slx in MATLAB. Go to the RTL-SDR Receiver Block and set the PPM value and the carrier frequency you obtained in Parts 1 and 2, respectively. Pulse shaping filter In digital communication, the spectrum of the transmitted signal is determined by a pulse shaping filter. The frequency response of this filter gives the shape of the transmitted spectrum. Raised Cosine (RC) is one of the most popular pulse shapes due to having the desired property of zero-inter-symbol Interference (ISI) at the recovery sampling point. Although, this response extends over several symbol periods, as shown in Figure 6, the contribution from all other symbols is zero at the ideal sampling points. Normally the RC response is not implemented as a single filter at the transmitter, but rather it is split across the transmitter and receiver as two Square Root Raised Cosine (SRRC) filters [1]. In this exercise, we will use SRRC pulse to shape the spectrum of the transmitted and received signals. You will learn more about this pulse shaping filter in class. 4
Figure 6: The zero-isi property of raised cosine pulse shaping [1] Figure 7: QPSK constellation, with phase offset: 45 ; (b) Phase offset 0 [1] Open the Raised Cosine Receiver Filter Block and set the roll-off factor of the SRRC receive filter to α = 0.5. In the Raised Cosine Receiver Filter Block go to View Filter Response and observe the impulse response and magnitude response of the SRRC receive filter. Considering the impulse response and assuming an upsampling factor of 4 sample per symbol for the SRRC filter, find the filter span in the number of symbols. QPSK constellation diagrams QPSK is a common example of digital phase modulation schemes. In this modulation scheme 2 bits are grouped to form a symbol, and mapped to one of the points in the constellation (the map of all possible symbols in a modulation scheme) as shown in Figure 7. Note that a QPSK contellation may be defined in two different ways based on the phase offset. We can also use different schemes for mapping symbols to constellation points. In PSK modulation schemes constellation points are equidistant from the origin, meaning that all symbols have the same energy [1]. Plot the constellation diagram before and after the Carrier Synchronizer Block, and also after the Symbol Synchronizer Block. Comment on the difference of these plots and infer the role of carrier and symbol synchronizers. 5
Eye diagrams In a digital communication system, the amount of ISI and noise present in the received signal can be viewed on an oscilloscope. Specifically, we may display the received signal on the vertical input with the horizontal sweep rate set at 1/T. The resulting oscilloscope display is called an eye diagram because of its resemblance to the human eye. The effect of ISI is to cause the eye to close, thereby reducing the margin for additive noise to cause errors (the vertical height of the eye opening). Note that ISI also distorts the position of the zero crossings and causes a reduction in the width of the eye opening. As a consequence, the system is more sensitive to a synchronization error and exhibits a smaller margin against additive noise [3]. Plot the eye diagram before the Symbol Synchronizer Block and after the Frame Synchronizer Block. Comment on the difference of these plots and infer the role of symbol and frame synchronizers. Decoding the message Run the model and see if you can decode the transmitted message properly. What is the ASCII message which has been sent from the USRP transmitter? Is there any error in the received message? Report For the report, include all the plots that you produced and the associated discussion. Also show a sample of the received text message. References [1] B. Stewart, K. Barlee, D. Atkinson, and L. Crockett, Software Defined Radio using MATLAB and Simulink and the RTL-SDR, 1st ed., Strathclyde Academic Media, 2015. Accessed on: October, 2018. [Online]. Available: https://www.desktopsdr.com/download-files [2] MATLAB and Simulink Hardware Support for SDR. Available: https://www.mathworks.com/sdr [3] J. G. Proakis, M. Salehi, and G. Bauch, Contemporary Communication Systems Using MATLAB, 3rd ed., Cengage Learning, 2012. 6