Top Banner
1 ELEC 450 summer 2012 LAB EXPERIMENT 4 PRACTICAL QPSK SYSTEM 1. Objective Learn about all the necessary stages in a practical QPSK system (transmitter, channel, receiver) that addresses practical issues in wireless communications, such as carrier frequency and phase offset, timing offset and frame synchronization. Learn about the bit error rate performance of a QPSK as a function of frequency offset, delay and signal to noise ratio. Learn about the bit error rate performance of a QPSK wireless link as a function of distance using the link budget. 1.1. Lab overview and table of contents The first part of the lab experiment begins with experiments using Simulink only, the USRP software defined radio units are not used. The experiments run a complete QPSK system with transmitter, simulated channel model (with noise, frequency offset and delay) and receiver implemented in Simulink. The second part uses two USRPs (from adjacent lab stations) to create a complete QPSK system with Simulink transmitter, real RF radio channel with antennas, and Simulink receiver. QPSK Transmitter and Receiver Copyright 2011 The MathWorks, Inc. Transmitter Receiver Double-click To Open Scopes At Run Time Model Parameters Info Double-click To Close Scopes BER Display AWGN Channel with Frequency Offset & Variable Time Delay
23

ELEC_450_SDR_Lab_FINAL.pdf

Nov 07, 2014

Download

Documents

Amita Sharma

electrical lab experiment
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ELEC_450_SDR_Lab_FINAL.pdf

1

ELEC 450 summer 2012

LAB EXPERIMENT 4

PRACTICAL QPSK SYSTEM

1. Objective

Learn about all the necessary stages in a practical QPSK system (transmitter, channel, receiver)

that addresses practical issues in wireless communications, such as carrier frequency and phase

offset, timing offset and frame synchronization.

Learn about the bit error rate performance of a QPSK as a function of frequency offset, delay and

signal to noise ratio.

Learn about the bit error rate performance of a QPSK wireless link as a function of distance using

the link budget.

1.1. Lab overview and table of contents

The first part of the lab experiment begins with experiments using Simulink only, the USRP software

defined radio units are not used. The experiments run a complete QPSK system with transmitter,

simulated channel model (with noise, frequency offset and delay) and receiver implemented in Simulink.

The second part uses two USRPs (from adjacent lab stations) to create a complete QPSK system with

Simulink transmitter, real RF radio channel with antennas, and Simulink receiver.

QPSK Transmitter and Receiver

Copyright 2011 The MathWorks, Inc.

Transmitter Receiver

Double-click

To Open Scopes

At Run Time

Model

ParametersInfo

Double-click

To Close Scopes

BER Display

AWGN Channel with

Frequency Offset &

Variable Time Delay

Page 2: ELEC_450_SDR_Lab_FINAL.pdf

2

1.2. Preparation questions

1. For a QPSK receiver, obtain numerical values for the theoretical bit error rate as a function of

Eb/No from 0 to 15 dB (i.e. plot a curve or make a table). For a bit error rate of 410 what is

Eb/No?

2. Find the maximum free space range (distance) that can be covered for a wireless QPSK data link

with data rate 40 Kbits/sec, bit error rate 410 , transmit power one microwatt, antennas with

zero gain. Assume the bandwidth is equal to the bit rate and the receiver noise figure is 5 dB.

Link budget formulas are in the Appendix.

1.3. Lab table of contents

2. Baseband data transmission

2.1. Digital messages

2.2. Pulse shaping

3. Quadrature Phase Shift Keying

3.1. QPSK transmitter theory

3.2. Transmitting QPSK in Matlab Simulink

3.2.1. Baseband QPSK signal

3.2.2. Real QPSK signal within Simulink

3.2.3. Complex QPSK signal within Simulink

3.2.4. Real QPSK signal at radio frequency (RF)

3.3. QPSK receiver

3.3.1. Receiver for complex baseband QPSK signal within Simulink without USRP

3.3.2. Receiver for real QPSK signal within Simulink without USRP

3.3.3. Receiver for reak QPSK signal at RF using USRP

3.3.4. Practical QPSK receiver design challenges

4. Lab instructions

4.1. Setup at each lab station

4.2. Lab instructions overview

4.3. QPSK system experiments using Simulink only, USRP not used

4.3.1. Familiarization with the Simulink QPSK model

4.3.2. Running the experiment, obtaining BER performance

4.3.3. Running the experiment, observing when the system “breaks”

4.4. QPSK system experiments using 2 USRPs and antennas

4.4.1. Experimental setup with 2 USRPs and antennas

4.4.2. Familiarization with USRP transmitter and receiver blocks

4.4.3. Running the experiment

4.5. Review questions

Appendix

Page 3: ELEC_450_SDR_Lab_FINAL.pdf

3

2. Baseband data transmission

2.1 Digital messages

The figure below shows how a digital message is constructed for a practical QPSK system.

The unipolar Barker code is a 13-bit sequence

barker=[+1 +1 +1 +1 +1 -1 -1 +1 +1 -1 +1 -1 +1]

that has excellent autocorrelation properties, i.e. the matlab command

plot(xcorr(barker,barker)) shows a single peak of 13 and sidelobes of 1 or 0.

The Barker code is used as a “unique word” for frame synchronization, i.e to determine where the

information bits begin and identify the byte boundaries.

2.2 Pulse shaping

( )m t is a digital message as shown in the figure below.

Each data frame contains 26 bits header (For Sync Purpose) and 174 bits data bits,

first 105 bits contain "Hello world ###" message. Scrambler is there to improve data

transition density and frequency offset estimation.

1

Out

Scrambler

Repeat

2x

Message

Source

1

Matrix

Concatenate

Unipolar

Barker Code

Page 4: ELEC_450_SDR_Lab_FINAL.pdf

4

In the figure above, ( )p t is chosen to be a so-called square pulse, where we can write

for 0 and 0 o( ) 1 therwise tp t T . We send one such pulse for each data bit, a positive pulse

( )p t for logic 1 and a negative pulse for logic 0. In the figure, the message is shown in the interval

0 8t T and the data bits are 11100101.

For the period 0 t T , 0( 1) ( )pm A tt and the data is logic 1. For the next period 2T t T ,

1 (( ) ) 1p tm t A T , and the data is logic 1. In the example figure above, the message is shown in

the interval 0 8t T and the information bits are 11100101

We can write 0 1 2( ) ( ) ( ) ( 2 ) ... ( )k

k

m t A p t A p t T A p t T p t kA T

where the real constants 1kA depending on whether a logic 1 or a logic 0 was sent.

In the figure above, 0 1 2 3 4 5 6 71, 1, 1, 1, 1, 1, 1, 1A A A A A A AA

When ( )p t is chosen to be a square pulse in the time domain as shown in the figure above, then the

spectrum ( )P f is a sinc function that occupies significant bandwidth. When the sharp edges of a

square pulse ( )p t are rounded or smoothed by a filter, then the bandwidth is reduced, but the pulse

extends beyond the time interval 0 t T .

Ideally, we wish ( )P f to be strictly band-limited (to avoid interference with the adjacent channel in the frequency domain)

but without any inter-symbol interference (ISI) (to avoid interference with the adjacent symbol in the

time domain)

One solution is to use a pulse with a raised cosine (RC) spectrum ( )P f that has a time domain pulse

2 2 2

( / ) ( /( )

)

/ 1 4 /

sin t T cos t T

t Tp

Tt

t

Page 5: ELEC_450_SDR_Lab_FINAL.pdf

5

In the figure below, ( ) ( )x t p t

The parameter is the excess bandwidth (i.e. the bandwidth in excess of the absolute possible

minimum bandwidth).

If the receiver filter is matched to the transmitter filter, then the overall raised cosine spectral

characteristic is split evenly between the transmitting filter and the receiving filter. In this case we

choose the pulse spectrum to be ( )P f with time domain pulse shape

2 2

[ (1 ) / ] 4 ( / ) [ (1 ) / ]( )

( / )[1 16 ( / ) ]

sin t T t T cos t T

t T t Tp t

In a practical system, we use this square root raised cosine pulse shape instead of a square pulse.

3 Quadrature Phase Shift Keying (QPSK)

3.1 QPSK transmitter theory

Recall that we can send separate messages 1 2( ), ( )m t m t on the I and Q channels, i.e.

1 2( ), ) )) ( (( t q tm m ti t

We can choose 1 2 an( d ( )) mm tt to be separate digital messages or two parts of the same digital

message with the same kind of waveform as shown in section 2.1. above. When we use both the I

and Q channels, the modulation is called Quadrature Phase Shift Keying (QPSK).

Page 6: ELEC_450_SDR_Lab_FINAL.pdf

6

To write an expression for QPSK, a digital message can be written as a complex envelope

0 1 2( ) ( ) ( ) ( ) ( 2 ) .k

k

s t p t kT C p t C p t TC C p t T

where

( ) ( ) ( )s t i t jq t is a complex message waveform, kj

k k k kC aA jB e

is the digital data,

where and cos sink k k k k ka B aA

There are 4 possible values of kC depending on whether a logic 00, 01, 10 or 11 was sent.

The signal constellation for QPSK consists of the 4 points located at 1kC j

In polar form kj

k k k kC aA jB e

, so that with 1 and 1k kBA ,

(2 1)2 and

4k ka

n

are the 4 possible phases of a QPSK signal.

From the expression for ( )s t , and assuming a square root raised cosine pulse ( )p t we see that at time

0t , 0

0 0 0( )j

s t A jB ea

is a complex constant. For the next period at time t T ,

1

1 1 1( )j

s t A jB ea

, etc. In general, for the time period t kT ( ) kj

k k ks t A jB ea

is a fixed

amplitude and phase.

0 1 2( ) ( ) ( ) ( ) ( 2 ) .k

k

i t p t kT A p t A pA t T A p t T

and

0 1 2( ) ( ) ( ) ( ) ( 2 ) .k

k

q t p t kT B p t B pB t T B p t T

For QPSK, we choose 1 and 1k kBA , so that 1kC j .

3.2. Transmiting QPSK in Matlab Simulink

3.2.1. Baseband QPSK signal

The complex signal ( ) ( )k

k

s t p t TC k is the complex baseband QPSK waveform, and is

generated in Simulink via the model shown below. The QPSK modulator block accepts bits and

groups them in pairs to determine the value of

kC.

The RC transmit filter generates the square root raised cosine pulses

( )p t kT

Page 7: ELEC_450_SDR_Lab_FINAL.pdf

7

3.2.2. Real QPSK signal

To create a real QPSK signal within Simulink at intermediate frequency 1f using these equations, we (1)

generate the complex baseband signal ( ) ( ) ( )s t i t jq t and (2) upconvert it to the desired carrier

frequency with a standard IQ transmitter to yield 1 1(( ) ( ) ) 2cos2s f t q t sint f ti t

The spectrum of ( )s t will be centered at 1f and has both positive and negative frequency

components. This signal is not used in this lab experiment.

3.2.3. Complex QPSK signal

To create an complex QPSK signal in Simulink at intermediate frequency 2f using these equations,

we (1) create the complex baseband signal ( ) ( ) ( )s t i t jq t and (2) upconvert it to the desired

carrier frequency by multiplying by 22j f te

. The results is another complex signal

2

2 2 2 2

2

2

2 2

( ) [ ( ) ( )]

( )sin 2 [ ( )cos( 2) ( )sin 2 ]

( ) ( )

cos 2

j f ts t i t jq t e

f t q t f t j q t f t i t f t

i t jq

i

t

t

We can create a second QPSK signal in Simulink at a different intermediate frequency 3f in the same

way to yield

3 3 3( ) ( ) ( )s t i t jq t

We can create a composite signal consisting of several QPSK signals at 2 3,f f etc. This signal is not

used in this lab experiment.

3.2.4 Real QPSK signal at radio frequency (RF)

Transmitter

1

Tx OutputSquare root

Raised Cosine

Transmit Filter

QPSK

QPSK

Modulator

Baseband

Bits Generation

FFT

After RC

Tx Filter

Page 8: ELEC_450_SDR_Lab_FINAL.pdf

8

The upconversion of a QPSK signal to a radio frequency (RF) wave at cf is the function of the USRP sink

block (standard IQ transmitter) with inputs and ( ( ))i t q t .The USRP transmitter accepts a complex

baseband signal ( )s t from section 3.2.1. and multiplies it by 2 cj f te

and takes the real part to generate

a real RF signal ( )s t centered at and c cf f .

For some software radios it is recommended to use the complex signal 2 ( )s t at intermediate frequency

2f from section 3.2.3 to avoid using the complex baseband signal ( ) ( ) ( )s t i t jq t that may have

some DC content. 2 ( )s t can be up-converted to RF by the USRP transmitter to generate a real RF signal

( )s t centered at 2 2 + and c cf f f f .

3.3. QPSK receiver

We can simulate the QPSK receiver within Simulink without using the USRP source block.

3.3.1. Receiver for complex baseband QPSK signal within Simulink without USRP

The complex baseband QPSK signal from section 3.2.1 is already in the complex baseband format

(( ))i t jq trequired for the USRP receiver.

Upsample by 4

QPSK Transmitter with USRP(TM) Hardware

Open the companion sdruqpskrx model

Note: Before running the QPSK models, first run the companion models for frequency offset calibration.

Open the companion sdrufreqcalibrx modelOpen the companion sdrufreqcalibtx model

Copyright 2011 The MathWorks, Inc.

SDRu

Transmitter

192.168.10.2

Data

USRP Transmitter

Square root

Raised Cosine

Transmit Filter

QPSK

QPSK

Modulator

Baseband

Info

Bits Generation

Page 9: ELEC_450_SDR_Lab_FINAL.pdf

9

3.3.2. Receiver for real QPSK signal within Simulink without USRP

To receive the real QPSK signal 1 1(( ) ( ) ) 2cos2s f t q t sint f ti t from section 3.2.2, we use a

standard IQ receiver set up for 1f with complex output (( ))i t jq t

This IQ receiver can be implemented with real cosines and sines and low pass filters. The real QPSK

signal from section 3.2.2. is not used in this lab experiment.

3.3.3 QPSK signal at radio frequency (RF) with USRP

Oversampled by 2

Receiver

1

BERTiming

Recovery

DataOut

DataValid

Square root

Raised Cosine

Receive Filter

To

Sample

Frame Conversion

Fine Frequency

Compensation

In BERData Decoding

Coarse Frequency

Compensation

Buffer

Automatic Gain

Control

After RC

Rx Filter1

FFT

After RC

Rx Filter

After Fine Frequency

Compensation

After Coarse Frequency

Compensation

1

dataIn

QPSK Receiver with USRP(TM) Hardware

Open the companion sdruqpsktx model

Note: Before running the QPSK models, first run the companion models for frequency offset calibration.

Open the companion sdrufreqcalibrx modelOpen the companion sdrufreqcalibtx model

Copyright 2011 The MathWorks, Inc.

SDRu

Receiver

192.168.10.2

Data

Data Len

USRP Receiver

dataIn QPSK Receiver

Model

ParametersInfo

Page 10: ELEC_450_SDR_Lab_FINAL.pdf

10

To receive the QPSK signal at RF from section 3.2.3, the USRP source block is used to downconvert the

real RF signal to complex baseband (( ))i t jq t

The USRP works with the real QPSK signal at RF carrier frequency cf

(( ) ( )s 2)co 2 c cf t q t sis ft ti nt To receive a QPSK signal at RF, we use the USRP source block. The USRP receiver multiplies the real

valued radio frequency (RF) signal ( )s t by 2 dj f te

to generate (( ))i t jq t , where the USRP

downconversion frequency (local oscillator) d cf f is very close to but not exactly the same as the

received carrier frequency cf This is called complex downmixing and is equivalent to the standard IQ

receiver, where in the figure below and ( ) R ( ) Im (e{ )} )( qi t x t x tt and df is the frequency of the

USRP source block.

The USRP receiver block has a complex output with real and imaginary components and ( ( ))i t q t ,

thus the USRP receiver block with frequency set to cf will have outputs

( ) ( )cosi t a t ,

( ) ( )sinq t a t , where

2 ( )d cf f t

Oversampled by 2

Receiver

Timing

Recovery

DataOut

DataValid

Square root

Raised Cosine

Receive Filter

To

Frame

Fine Frequency

Compensation

In Data Decoding

Coarse Frequency

Compensation

Automatic Gain

Control

Enable

1

dataIn

Page 11: ELEC_450_SDR_Lab_FINAL.pdf

11

The complex signal output from the USRP source block (( ))i t jq t is bandlimited to the sampling

rate of the USRP receiver block. The USRP receiver block output can be recorded to a file and used

again at a later time. This file source will have the same sampling rate and bandwidth as the USRP

receiver block used to record it.

With a sampling rate of 256KHz and complex samples, the bandwidth will be 256 KHz (because the

complex signal spectrum is not symmetric and does not have redundant mirror-image positive and

negative frequencies)

We can “tune in” (receive) any of the QPSK signals in this bandwidth by shifting the spectrum of the

USRP source output. We shift by e.g 2f KHz by multiplying the USRP source output (complex signal)

(( ))i t jq t by 2

2 2

2cos sin2 2

j f tf t j f te

, so that the QPSK signal that first appeared at 2f

Hz (see section 3.2.3) now appears at zero Hz.

For the QSPK system in this lab, there is only one QSPK signal at baseband (see section 3.2.1), so

there is no need to “tune in” a signal. However, we would need to do this if we used the QPSK

signal from section 3.2.2 or 3.2.3.

With a square root raised cosine matched filter, the received data ( )i t at sampling times t kT

is 1kA and the received data ( )q t is 1kB , where is adjusted to sample at the peak of the

raised cosine pulse ( )p t at the output of the matched filter. In the complex domain, the received

data (( ))i t jq t at sampling times t kT is 1kC j

3.3.4 Practical QPSK receiver design challenges

The challenge in a practical receiver is to compensate for the frequency offset d cf f and to find

the correct sampling times t kT to obtain the data 1kC j , followed by frame

synchronization so that the data can be decoded into the message bits.

The Simulink receiver does these tasks in stages:

• FFT-based coarse frequency compensation,

• PLL-based fine frequency compensation,

• timing recovery with fixed-rate resampling and bit stuffing/skipping,

• frame synchronization, and

• phase ambiguity resolution.

Page 12: ELEC_450_SDR_Lab_FINAL.pdf

12

The details of each block in the receiver are shown in the Appendix. A detailed understanding of

exactly how these blocks work is not required to run the lab experiment

4. Lab setup and instructions

In all experimental sections, record your observations at each step as appropriate, with sketches or

(annotated) screenshots as needed. In particular, respond to each step labeled “TASK FOR LAB

REPORT”. To take a screen shot, click – Accessories – Take Screenshot – Current Window.

4.1 Setup at each lab station.

1. The small grey box is the USRP software defined radio. The USRP has a receiver (Rx) input, a

transmitter (Tx) output and an Ethernet connection to the computer.

a. The USRP digitally up-converts an I-Q signal sent via Ethernet from the computer to an

analog RF signal at the Tx output connector (SMA type) (section 3.2.4).

b. The USRP Tx output (analog RF signal) may be connected to a 30 dB attenuator,

followed by coaxial cable to a quarter-wave monopole antenna to be radiated.

c. Another antenna that will pick up analog RF signals may be connected to the USRP Rx

input connector (SMA type)

d. The USRP digitally down-converts the analog RF signal at the Rx input connector into I

and Q format and sends it via Ethernet to the computer (section 3.3.3).

e. The computer is running Linux (Scientific) with Matlab Simulink software installed and

dual monitors.

f. The username and password are both “student” (without quotes).

g. The Matlab Simulink software is launched by single-clicking the icon at the top left.

h. Upon launching Matlab, navigate to Desktop/Matlab. There are two folders,

“commdemos” for the Simulink-only experiment, and “commusrp” for the radio

experiment using the USRP.

4.2 Overview of lab instructions

The first part of the lab experiment begins with experiments using Simulink only, the USRP is not used.

Oversampled by 2

Receiver

1

BERTiming

Recovery

DataOut

DataValid

Square root

Raised Cosine

Receive Filter

To

Sample

Frame Conversion

Fine Frequency

Compensation

In BERData Decoding

Coarse Frequency

Compensation

Buffer

Automatic Gain

Control

After RC

Rx Filter1

FFT

After RC

Rx Filter

After Fine Frequency

Compensation

After Coarse Frequency

Compensation

1

dataIn

Page 13: ELEC_450_SDR_Lab_FINAL.pdf

13

The experiments run a complete QPSK system with transmitter, simulated channel model and receiver

implemented in Simulink.

The second part uses two USRPs (from adjacent lab stations) to create a complete QPSK system with

Simulink transmitter, real RF radio channel with antennas, and Simulink receiver. The distance between

antennas is varied to observe over what distance the link works and at what distance the link fails.

4.3. QPSK system experiments using Simulink only, USRP not used.

4.3.1. Familiarization with the Simulink QPSK system model

1. From within the Matlab command window, navigate to Desktop/Matlab/commdemos and open

the file commqpsktxrx.mdl The model block diagram will appear

2. The model simulates a complete QPSK system that sends a message stream “hello world xxx”

where xxx are digits 000-099. As mentioned in Section 2.1, the messages are sent in frames 174

bits long with 26 bits for frame synchronization.

3. The system performance (link quality) is measured in two ways:

a. by the live BER display while the simulation is running, and

b. the number of errors in the “hello world xxx” text display in the Matlab command

window when the simulation is stopped.

4. Double click the “info” block (green) to open the documentation for commqpsktxrx.mdl,

including detailed description of each component. It is strongly recommended to read this

documentation.

5. Double click the Transmitter block to see the components inside that block (same as figure in

section 3.2.1). Double clicking on any block will reveal the components of that block, or a dialog

box with parameters for that block.

6. Double click the “AWGN channel ….” block to see the components of the channel model. The

model includes phase/frequency offset, variable delay and AWGN.

QPSK Transmitter and Receiver

Copyright 2011 The MathWorks, Inc.

Transmitter Receiver

Double-click

To Open Scopes

At Run Time

Model

ParametersInfo

Double-click

To Close Scopes

BER Display

AWGN Channel with

Frequency Offset &

Variable Time Delay

Page 14: ELEC_450_SDR_Lab_FINAL.pdf

14

7. Double click the “receiver” block. Observe the location of the 3 constellation displays (Matlab

calls them “Discrete-Time Scatter Plot Scope”).

8. Double click the “timing recovery “ block. Observe the location of the Discrete-Time Scatter Plot

Scope titled “after timing recovery”

4.3.2. Running the experiment, obtaining BER performance

9. Double click the “model parameters” (yellow) block. From the “setting types” dropdown menu,

select “channel impairment settings”. There are 3 types of impairments, AWGN (Eb/No),

frequency offset and delay. Set the Eb/No to 20 dB and frequency offset to 2 Hz and click OK to

apply and close the dialog box.

10. In the model parameters block, there are 4 delay parameters that determine how much and

how quickly the delay changes. Set the delay parameters as follows: delay type triangle, delay

step 0.05 samples/frame, minimum delay 0 samples, maximum delay 1 sample. Clock OK to

apply and close the dialog box.

11. Run the model “simulation”>”start”. Observe that multiple windows open displaying various

signal constellations, frequency spectra and graphs.

12. Observe the spectrum display “after RC Tx filter”.

13. TASK FOR LAB REPORT: From this display, what is the approximate data rate? See the X(f) plot

in section 2.2 for a hint.

14. Observe the 4 constellation plots at different stages of the receiver. The first constellation

labeled “after RC Rx Filter” shows a slowly rotating constellation due to the 2 Hz frequency

offset. Only the last constellation plot labeled “after timing recovery” shows the correct

constellation. Thus for a practical channel with frequency and timing offsets, the coarse and

fine frequency compensation, and timing recovery stages are needed to obtain the correct

constellation.

15. Stop the simulation “simulation”>”stop” and observe the “hello world xxx” display in the Matlab

Convert Delay from

samples to symbols

1

Outz-f

In

Delay

Variable

Fractional Delay

Phase/

Frequency

Offset

-K-

Gain

2

Delay Select

Delay Generator

FFT

After Channel

Time

Actual Delay

AWGN1

In

Page 15: ELEC_450_SDR_Lab_FINAL.pdf

15

command window.

16. Experiment with different values of Eb/No and frequency offset and observe the constellation

displays and the BER display. The BER display (on the receiver model block diagram) shows the

bit error rate, total number of errors and total number of bits sent.

17. TASK FOR LAB REPORT: Record your visual observations of the constellations for two different

values of Eb/No and frequency offset.

18. Experiment with different values of Eb/No and observe the relationship between the BER and

the number of errors in the text message and answer the questions in step 19.

19. TASK FOR LAB REPORT: At what Eb/No and BER is the text message essentially error-free? At

what Eb/No and BER is the message text mostly garbled (no recognizable text)? What is the dB

difference in Eb/No between an essentially error free message and a mostly garbled message?

20. TASK FOR LAB REPORT: Prepare a table of BER versus Eb/No and frequency offset as follows,

and comment on the difference in BER performance between theory and practice.

Eb/No(dB) / freq offset(Hz)

QPSK theoretical BER, 0 Hz offset

Simulation result 0 Hz offset

Simulation result 5 KHz offset

Simulation result 12 KHz offset

3

5

7

10

15

4.3.3. Running the experiment, observing when the system “breaks”

21. Recall that the challenge in a practical receiver is to compensate for the frequency offset

d cf f and to find the correct sampling times t kT to obtain the data 1kC j ,

followed by frame synchronization so that the data can be decoded into the message bits. The

system will “break” (stop functioning correctly, i.e. the BER will be close to 0.5) if one or more of

the frequency compensation and/or timing recovery fails and/or frame synchronization fails. 22. Frequency compensation failure: with Eb/No= 20 dB at which the BER is close to zero, increase

the frequency offset until the system “breaks” (i.e. the frequency compensation fails).

23. TASK FOR LAB REPORT: What is the maximum frequency offset before the system “breaks”?

24. Timing recovery failure: with Eb/No=20 dB and frequency offset 0 Hz, change the 4 delay

parameters until the system “breaks” (i.e. the timing recovery fails).

25. TASK FOR LAB REPORT: Identify a combination of the 4 delay parameters at which the system

“breaks”. The combination of delay parameters is not unique.

26. Frame synchronization failure: For a well-designed system, the frame synchronization should not

fail at an Eb/No that yields usable data, i.e. the frame synchronization unique word (Barker

code) should be long enough so that it is reliably recognized even with a high BER. For a poorly

designed system, the frame synchronization could fail at an Eb/No that is sufficient to obtain

useful data, and that data would be unnecessarily lost. In such a system, the BER versus Eb/No

Page 16: ELEC_450_SDR_Lab_FINAL.pdf

16

curve would suddenly jump up to near 0.5 when the Eb/No falls below the threshold at which

frame synchronization fails.

27. TASK FOR LAB REPORT: Test the system at low Eb/No and decide whether or not frame

synchronization is failing at an Eb/No that is sufficient to obtain useful data. State the reasons

for your answer.

4.4. QPSK system experiments using 2 USRPs and antennas

4.4.1. Experimental setup with 2 USRPs and antennas

28. Work together with the lab group next to you.

29. At one lab station, connect the USRP Tx output to a 30 dB attenuator followed by a one meter

(or more) length of coaxial cable and a monopole antenna set to be a quarter wavelength long

at 915 Mhz.

30. At the other lab station, connect the USRP Rx input to a length of coaxial cable and a monopole

antenna.

31. Place the antennas on the bench less than 20 cm apart.

4.4.2. Familiarization with Simulink USRP transmitter and receiver blocks.

32. In the Matlab command window, navigate to Desktop/Matlab/commusrp/usrpdemos and open

sdruqpsktx.mdl

33. The QPSK transmitter block generates the complex baseband QSPK signal with square root

raised cosine pulses, and feeds the complex signal to the Simulink USRP transmitter block that

upconverts the signal to RF carrier frequency cf as described in section 3.2.4. Click the blue

“info” block and read the details.

34. Click on the USRP transmitter block to set the parameters. Set the gain to 0 dB (this corresponds

to 0 dBm or 1 milliwatt) and set the frequency to either 910 or 920 MHz (to avoid interfering

with the link set up by the other 2 lab groups.

35. Open sdruqpskrx.mdl

Upsample by 4

QPSK Transmitter with USRP(TM) Hardware

Open the companion sdruqpskrx model

Note: Before running the QPSK models, first run the companion models for frequency offset calibration.

Open the companion sdrufreqcalibrx modelOpen the companion sdrufreqcalibtx model

Copyright 2011 The MathWorks, Inc.

SDRu

Transmitter

192.168.10.2

Data

USRP Transmitter

Square root

Raised Cosine

Transmit Filter

QPSK

QPSK

Modulator

Baseband

Info

Bits Generation

Page 17: ELEC_450_SDR_Lab_FINAL.pdf

17

36. The QPSK receiver block takes the RF signal and downconverts it to complex baseband as

described in section 3.3.3. Click the blue “info” block and read the details.

37. Click on the USRP receiver block to set the parameters. Set the gain to 0 dB.

4.4.3. Running the experiment

38. Start the transmitter sdruqpsktx.mdl from one lab station using “simulation”>”start”

39. Start the receiver sdrupqpskrx.mdl from the other lab station using “simulation”>”start”

40. Let the simulation run for about 5 seconds.

41. Stop the receiver using “simulation”>”stop”

42. Observe the “hello world xxx” output in the Matlab command window.

43. Move the antennas further apart and repeat steps 39-42.

44. Find the largest distance over which the link works reliably (almost no errors in message text)

45. Find the smallest distance over which the link fails consistently (almost no recognizable message

text)

46. What is the ratio of these two distances?

47. Recall the answer to step 19 and recall the free space path loss formula in dB

0 32.4 20log ( ) 20log ( )f GHzL d m When the distance ratio is 2 to 1, then the path loss

increases by 6 dB, i.e. 20 log (2/1)= 6.

48. TASK FOR LAB REPORT: Explain your observations in steps 39-46, i.e. is the distance ratio in step

46 reasonable given the formula in step 47 and the theoretical BER for QPSK in step 20? Sketch

the curve of BER vs Eb/No to aid your explanation. Hint: with all link budget parameters

constant, increasing the path loss by 6 dB will reduce the Eb/No by an identical amount. Using

the link budget equations, write an equations for Eb/No as a function of distance d.

49. TASK FOR LAB REPORT: Using the link budget formulas in the Appendix, estimate the noise

figure of the receiver. Hint: all link budget parameters are known except the noise figure,

QPSK Receiver with USRP(TM) Hardware

Open the companion sdruqpsktx model

Note: Before running the QPSK models, first run the companion models for frequency offset calibration.

Open the companion sdrufreqcalibrx modelOpen the companion sdrufreqcalibtx model

Copyright 2011 The MathWorks, Inc.

SDRu

Receiver

192.168.10.2

Data

Data Len

USRP Receiver

dataIn QPSK Receiver

Model

ParametersInfo

Page 18: ELEC_450_SDR_Lab_FINAL.pdf

18

assuming the link margin M=1 (0 dB). Write an equation for F as a function of all other link

budget parameters.

50. Change the USRP receiver gain 1G from 0 to 20 dB and repeat steps 39-49. Explain the results.

Why is the noise figure lower? Hint: The USRP has a low noise preamplifier first stage, followed

by a higher noise second stage of amplification before the A/D. Recall the expression for the

noise figure of cascaded gain stages, 21

1

1FF

GF

where

1F is the noise figure and 1G is the

gain of the first stage of the USRP (the USRP dialog box adjusts the gain of the first stage only).

4.5 Review questions

1. Name the stages required in a practical communications link to compensate for frequency

offsets and delays that are not known in advance. Explain qualitatively how each stage works.

2. (optional) Reconcile the parameters of a stage with the robustness of that stage (i.e. the

frequency offset or delay at which the system “breaks”.

APPENDIX

A.1 Link budget formulas for terrestrial link (not in dB)

, 0/r o t t rPG GP L

2

0

4L

d

, 0( / )r n kT SP N WF

0

bES R

N N W

,

,

1r o

r n

PM

P

Link budget formulas in dB

Page 19: ELEC_450_SDR_Lab_FINAL.pdf

19

, 0

0

, 0

0

0

, ,

32.4 20log ( ) 20log ( )

( / )

228.6

10log 290

20

0

4

r o t t r

r n

r o r n

P G G L

f GHz d m

k T S N W F

k

T

k T

L

P PM

P

P

A.2 SIMULINK MODELS OF RECEIVER STAGES FOR

FREQUENCY COMPENSATION, TIMING RECOVERY AND FRAME SYNCHRONIZATION

Coarse frequency compensation

Find frequency offset using FFT

1

Out-1

Gain

In Freq Of f set

Find Frequency

Offset

Time

Estimated Frequency

Offset

Phase/

Frequency

Offset

In

Frq

Compensate

for Frequency Offset

1

In

Page 20: ELEC_450_SDR_Lab_FINAL.pdf

20

This subsystem does the following:

1. Creates a tone at M*Foffset, where M is the modulation order of the signal

2. Finds the index of the maximum amplitude across the frequency band

3. Converts the index to the frequency offset according to

Foffset = IndexofMaxAmplitude * FrameSize / (FFTLength * M * FrameSampleTime)

1

Freq

Offset

W:0, Ts:[-1, 0]

Welch

Periodogram

N

Tf

FFTSig

FreqOf f set

findfreqoffset

Find Frequency

Offset

u

v

u v̂

Complex Power

-C-

Alphabet

size

1

In

Page 21: ELEC_450_SDR_Lab_FINAL.pdf

21

Fine frequency compensation

Timing recovery

To determine the phase error detector gain Kp, See Equation 7.30 of "Digital

Communications - A Discrete-Time Approach" by Michael Rice.

Baseband implementation of the QPSK Phase PLL listed in Figure 7.2.4 of

"Digital Communications - A Discrete-Time Approach" by Michael Rice. See

Appendix C.2 of the same book for the details of PLL design.

1

OutUnbuffer

Ine

PED

PED

eu

Loop Filter

-1jGain

Estimated Phase

Difference

z-1

DDS

In

Ph

Complex

Phase Shift

1

In

Baseband implementation of the Symbol Timing Synchronization listed in Chapter 8.4

of "Digital Communications- A Discrete-Time Approach" by Michael Rice. See

Appendix C.2 of the same book for the details of PLL design.

MATLAB Implementation

of Scalar-based Timing Recovery

2

DataValid

1

Out

strobe

Timing Recovery

PLLIn

DataOut

Clk

Number of

Valid Samples

Data

Clk

DataOut

DataValid

Modified Buffer

[strobe]

Goto

[strobe]

From

In Out

Enabled Wire

Clk numValid

numValidCalc

Calculate Number of

Valid Samples

Buffer

After Timing Recovery

1

In

Page 22: ELEC_450_SDR_Lab_FINAL.pdf

22

Timing recovery PLL

Data decoding

Sample-based processing is adopted because

1. Strobe signal is required to generate for EVERY sample for processing and output

sampling, delayed strobe signal would affect the accuracy of bit stripping/stuffing

2. The BER performance degrades significantly even with frame size 2 and 4

Baseband implementation of the Symbol Timing Synchronization listed in Chapter 8.4

of "Digital Communications- A Discrete-Time Approach" by Michael Rice. See Appendix

C.2 of the same book for the details of PLL design.

To determine phase error detector gain Kp, See Equation 8.42 &

Figure 8.4.7 of "Digital Communications - A Discrete-Time Approach"

by Michael Rice.

2

ClkOut

1

DataOut

In

strobe

eTED

Timing Error

Detector

Time

Normalized

Timing Error

Delta

Underf low

mu

NCO_ctrl

NCO Control

Loop Filter

In

mu

Out

interp_filter

Interpolation Filter

Z-1

Integer Delay2

Z-1

Integer Delay1

1

DataIn

Buffer one frame data in case that contiguous

data scatter across two adjacent frames

This subsystem calculates the delay of the channel, align the data with

the detected frame head, resolves the possible phase ambiguity issue

during the fine frequency compensation and demodulates the data.

Rx signal is delayed by (RxBufferedFrames+1) frames.

The value 1 comes from one frame buffered at Data

Buffering subsystem with in the current subsystem

1

BER

received

Signal To

Workspace

BarkerRef

Data

Phase

Phase Offset

Estimator

Phase

Data

Out

Phase Ambiguity

Correction

& Demodulation

Error Rate

Calculation

Tx

Rx

Descrambling

Z-1

Delay1

Z-1

Delay

Barker Ref erence

Data

DelayCompute

Delay

Buffer

Bits Generation

Barker Code

Symbol Generation

Delay

RxData

Data

aligndata

Align Data

Trigger

1

In

Page 23: ELEC_450_SDR_Lab_FINAL.pdf

23

Phase ambiguity resolution

1. Find the maximum free space range (distance) that can be covered for a wireless QPSK data link

with data rate 40 Kbits/sec, bit error rate 410 , transmit power one microwatt, antennas with

zero gain. Assume the bandwidth is equal to the bit rate and the receiver noise figure is 5 dB.

Link budget formulas are in the Appendix.

Solution

Pro=Pt+Gt+Gr-L0=-60+0+0-L0

L0=32.4+20 log f(GHz) + 20 log d(m)=32.4+0+20log(d)

Pro=-60-32.4-20log(d)

Prn=k+T+(Eb/No)+W+F=-204+15+46+5=-138 dBW

M=Pro-Prn=0=-92.4-20log(d)+138

20log(d)=138-92.4=45.6

Log(d)=45.6/20=2.28

D=190 meters

Phase Ambiguity Resolution

and Demodulation

1

Out

QPSK

QPSK

Demodulator

Baseband-1

Gain

In

Ph

Complex

Phase Shift

Complex Phase

Shift

2

Data

1

Phase