demystifying waveform design and signal processing … · (srrc) are implemented. the srrc filter...

24
1 DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING FOR WIRELESS COMMUNICATIONS Wan Zhi Jun 1 , Phang Piao Chun 2 1 Raffles Institution, One Raffles Institution Lane, Singapore 575954 2 DSO National Laboratories, 20 Science Park Drive, Singapore 118230 ABSTRACT This project investigates the MATLAB modelling and simulation of a Differential Phase Shift Keying (DPSK) communication receiver designed to perform close to the ideal Bit Error Rate (BER) performance. The receiver model was tested against captured modulated signal transmitted from a RF signal generator known as Vector Signal Generator with known pseudo- random (PN) sequence generator. Unlike highly conceptual and simplified mathematical models described in introductory digital communication textbooks, the receiver algorithm developed for the BER simulation is designed to match the exact sampling frequency to symbol rate ratio as the captured data. To compare the receiver performance against the theoretical, the estimated BER is plotted against the ideal performance. The completed receiver model consists of a square root- raised cosine matched filter, a divide-by-4 decimator, a 2-samples-per-symbol based symbol synchroniser, a Frame Synchronizer correlator and an error counter for BER calculation. INTRODUCTION DPSK is a commonly used modulation scheme in certain military communication systems where receivers suffer from varying Doppler channel environment. While there are other techniques described in literature, differentially demodulated PSK has certain advantages over other modulation schemes, including the more efficient use of bandwidth, power efficiency and simplicity in implementation (Richer et. al, 2006). In this project, the main objective is to develop a DPSK receiver using MATLAB programming language to recover a set of data generated by a Vector Signal Generator’s internal PN9 pseudorandom generator and root-raised-cosine filter algorithm. The data carried a 400 bps modulated signal sampled at 3200 Hz (8x oversampling) and is processed without the knowledge of the initial state value from which the PN9 shift register generates its sequence. Hence the program includes a section that use correlation technique to identify the starting data sequence so that bit comparison can take place. In this report, the various transmitter and a receiver components of the communication system are represented in block diagrams to show the sequence of data transformation as well as programming sequence. To minimise error, the transmitting and receiving process are mirrored, hence the implementation of matched filters and paired modulation and demodulation techniques.

Upload: others

Post on 07-May-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

1

DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING FOR

WIRELESS COMMUNICATIONS

Wan Zhi Jun1, Phang Piao Chun

2

1Raffles Institution, One Raffles Institution Lane, Singapore 575954

2DSO National Laboratories, 20 Science Park Drive, Singapore 118230

ABSTRACT

This project investigates the MATLAB modelling and simulation of a Differential Phase Shift

Keying (DPSK) communication receiver designed to perform close to the ideal Bit Error Rate

(BER) performance. The receiver model was tested against captured modulated signal

transmitted from a RF signal generator known as Vector Signal Generator with known pseudo-

random (PN) sequence generator. Unlike highly conceptual and simplified mathematical models

described in introductory digital communication textbooks, the receiver algorithm developed for

the BER simulation is designed to match the exact sampling frequency to symbol rate ratio as the

captured data. To compare the receiver performance against the theoretical, the estimated BER is

plotted against the ideal performance. The completed receiver model consists of a square root-

raised cosine matched filter, a divide-by-4 decimator, a 2-samples-per-symbol based symbol

synchroniser, a Frame Synchronizer correlator and an error counter for BER calculation.

INTRODUCTION

DPSK is a commonly used modulation scheme in certain military communication systems where

receivers suffer from varying Doppler channel environment. While there are other techniques

described in literature, differentially demodulated PSK has certain advantages over other

modulation schemes, including the more efficient use of bandwidth, power efficiency and

simplicity in implementation (Richer et. al, 2006).

In this project, the main objective is to develop a DPSK receiver using MATLAB programming

language to recover a set of data generated by a Vector Signal Generator’s internal PN9

pseudorandom generator and root-raised-cosine filter algorithm. The data carried a 400 bps

modulated signal sampled at 3200 Hz (8x oversampling) and is processed without the knowledge

of the initial state value from which the PN9 shift register generates its sequence. Hence the

program includes a section that use correlation technique to identify the starting data sequence so

that bit comparison can take place.

In this report, the various transmitter and a receiver components of the communication system

are represented in block diagrams to show the sequence of data transformation as well as

programming sequence. To minimise error, the transmitting and receiving process are mirrored,

hence the implementation of matched filters and paired modulation and demodulation

techniques.

Page 2: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

2

MATERIALS AND METHODS

MATLAB is used to code the transmitter and receiver components for simulation as well as

actual data recovery. The simulation model for BER simulation is shown in Figure 1. Using

MATLAB functions, randomly generated binary numbers are passed through a serial/parallel

converter which converts them to symbols. Symbols are then modulated using DPSK and

upsampled 8 times in a Square Root Raised Cosine filter. The Average White Gaussian noise

(AWGN) channel with a range of Signal-to-Noise Ratios (SNR) is simulated for calculation of

Bit Error Rate (BER). The simulated data is then transmitted. On the receiver side the received

data goes through the processes listed above in a reversed order, and the downsampling process

is split into in-phase and quadrature branches. A synchronisation or clock recovery process in the

receiver is incorporated to measure timing error and symbol recovery. Error count is performed

by cross-correlating the original data with the recovered data to find similarity.

For data recovery, the transmitted signal from Vector Signal Generator is captured by a RF

receiver cum data acquisition module shown in Figure 2.1 and 2.3. Signal is first detected by an

antenna before going through an RF IQ downconverter to product a digitized in-phase and

quadrature phase components denoted by “data_IQ” shown in Figure 2.2. For subsequent bit

recovery, the captured data file undergoes a data format conversion using MATLAB (Refer to

appendix section) before being processed by the receiver algorithm shown in Figure 2.2.

Figure 1: Simulation transmitter and receiver model

T

x

DP

SK

Mo

du

lati

on

pseudo-random

number generation

8

Pulse

Shapin

AWGN

Channel

4

4

Random

Phase

Matche

dFilter

Shapin

Matche

dFilter

Shapin

clo

ck r

eco

ver

y

(Gar

dn

er T

ED

)

DP

SK

dem

od

ula

tion

Error

count

Fra

me

Sy

nc

via

Co

rrel

atio

n

Figure 2.1: Block diagram of transmitter & data acquisition module structure

RF Receiver

&

Data

Acquisition

Antenna

DP

SK

Mo

du

lati

on

8

SRRC

8

SRRC

Vector Signal Generator (conceptual)

data_IQ

Page 3: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

3

A pseudorandom or PN sequence is used to generate the real data. The PN9 generator is a

maximum-length shift register sequence with 9 stages, hence its name. It is described by

polynomial x9 + x

5 + x

0. The polynomial determines the number of stages in the shift register and

the bits to be XOR’d. Figure 3 shows the block diagram for the PN9 generator generating three

symbols.

Initially generator starts with nine 1 values. In the first clock, the least significant bit Bit 0 and

Bit 5 is XOR’d and the XOR’d result is shifted to the most significant bit on the second clock.

This process repeats through all 511 states of the generator (Christiansen, 2010).

Figure 2.2: Block diagram of receiver structure used to recover data

SRRC

4

Timing

synchronizer

DPSK

demodulation

Correlation

with PN9 to

find time delay

Correlation with

PN9 with

knowledge of delay

to find no. of

recovered bits

data_IQ

Figure 2.3: Experimental setup of the Vector Signal Generator and Data Acquisition module

1 1 1 1 1 1 1 1 1

0 1 1 1 1 1 1 1 1 xor

0 0 1 1 1 1 1 1 1 xor

Figure 3: PN9 sequence generator for the first 3 symbols starting with

"111111111"

Page 4: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

4

During simulation, data is passed through a DPSK modulator which conveys data by modifying

the phase of the carrier wave (reference signal). Each symbol is represented by a phase change.

A differential encoder to generate a stream of data input for PSK modulator to output a

waveform with a phase shift corresponding to the symbols in the data.

Signal waveforms modulated by a M-ary phase shift keying scheme are represented by (Proakis

and Salehi, 2000):

( ) ( ) (

)

For DPSK, the Modulation order M is 2. There is no additional phase rotation present since the

data bit undergoes differential encoding.

Matched filter process a received signal such that the effect of noise and Intersymbol

Interference (ISI) is minimised. This maximises SNR of filtered signal and allows more

information to be recovered (Langton, 2003). In this project Square Root Raised Cosine filters

(SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver

ends to achieve matched filtering and maximise SNR (Viswanthan, 2011). The SRRC filter has a

roll-off factor of 0.5 thus it has a bandwidth of 1.5 times of input sampling frequency. The

receiver SRRC filter has the same characteristics as the transmitter filter to achieve matched

filtering.

The channel assumes an Additive White Gaussian Noise (AWGN) and is simulated for SNR of 0

to 15. This is to plot the theoretical Bit Error Rate (BER) curve that is used to evaluate the actual

performance of the receiver model. The SNR is defined as:

where E is the signal energy and N0 is noise. The theoretical probability of error is given as

Proakis and Salehi, 2000):

(√

)

Symbol synchronisation involves the receiver recovering information such as symbol timing and

symbol phase from the incoming signal. Timing recovery algorithms determine the correct time

to sample the symbol pulse shape (Litwin, 2001; Jayaraj, 2010). In this project the Phased

Locked Loop (PLL) algorithm is implemented shown in Figure 3. PLL controls the phase of the

local oscillator and generates an output signal which has a phase related to the input signal. The

PLL algorithm consisting of four components: timing error detector (TED), interpolator,

interpolation controller and loop filter.

Page 5: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

5

The interpolator constructs new data points within the range of a discrete set of known data

points. The interval at which the interpolator constructs new data points is determined by the

interpolation control in PLL. The loop filter is a low pass filter and determines the characteristics

of the PLL, such as the lock time and capture range. The timing error detection recovers the

timing phase of symbols from the input signal and eliminates timing error. This allows the

symbol synchroniser to compensate for noise while recovering information (Berner, 2005).

The Gardner Timing Error Detection method operates on two samples per symbol. The Gardner

method is most useful on symbol transitions when symbols change signs (positive to negative or

vice versa). In addition the Gardner’s algorithm is robust to carrier offsets, simple to implement

and does not demand high oversampling rates (Litwin, 2001). Hence it is widely used in

industrial applications and is applied in data recovery for this project. The Gardner TED method

is expressed as:

( ) ((

) ̂) [ (( ) ̂) ( ̂)]

((

) ̂) [ (( ) ̂) ( ̂)]

To mirror the components of the transmitter demodulation is performed using the same

parameters such as modulation order and phase rotation. Demodulation is the inverse of

modulation and recovers the original state of the signal before transmission. In demodulation, the

received signal is expressed as (Proakis and Salehi, 2000):

( ) ( ) ( ) ( ) ( ) ( )

To calculate error probability of symbols and bits, the receiver delay needs to be known.

Receiver delay is calculated by cross-correlating the input symbols and output symbols. The

maximum of the cross-correlation function (or lag function) indicates when the signals are best

aligned. This value is then used to find the time delay by inputting the maximum coordinates into

the lag function.

Interpolator

Interpolation

Controller

Loop

Filter

Timing

Error

Detector

x(t)

Figure 4: Block diagram of Phase Locked Loop

Page 6: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

6

RESULTS AND DISCUSSION

BER Simulation:

The MATLAB code used for building the transmitter and receiver as well as generating results is

provided in the appendix. Simulation is conducted on randomly generated bits and the theoretical

BER curve is plotted using the blue continuous line shown in Figure 5. The red discrete plots are

error rates calculated by cross correlating received simulation data and original data for different

SNR values between 0 and 15. As seen in Figure 5, the first 8 plots lie on the theoretical curve,

showing that the designed receiver performs close to ideal. The last 2 plots deviate slightly from

the theoretical curve as BER becomes more inaccurate due to insufficient amount of bits. The

comparison of theoretical BER and receiver BER reflects that the receiver model performs close

to ideal.

Data Recovery:

The receiver's performance is further evaluated by recovering real data. The transmitted data_IQ

has undergone differential BPSK modulation and hence modulation order is 2 and data is

transmitted at 1 bit/symbol. A scatter plot (in-phase and quadrature phase) of the transmitted data

with 8 times oversampling (400 bps sampled at 3200 Hz) is shown in Figure 6.1.

It can be seen from the figure that a phase shift and frequency offset have been introduced in the

RF receiver due to transmitter and receiver oscillator mismatch. At this stage, the signal is

Figure 6.1: Scatterplot

for transmitted data

Figure 6.2:

Scatterplot of Delay

(5)

Figure 6.3:

Scatterplot of Delay

(7)

Figure 5: BER curve with theoretical and actual plots

Page 7: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

7

affected by symbols interfering with neighbouring pulses prior to receive match filtering,

resulting in inter-symbol interference. In addition, noise present in the channel and the actual RF

receiver distorts the original data.

To gain insight into how signals will look like after symbol synchronization, let’s turn our

attention to observing signals after a divide-by-8 decimation. Two out of the eight possible sets

of decimated samples (seven samples apart) retained after the decimation process are shown in

Figure 6.2 and 6.3. The plot with points in each quadrant closest to each other correspond to the

desired symbol recovered signal (Figure 6.2). The rest of the delay plots are in the appendix.

Next to be examined is the captured “data_IQ” after receive match filtering as shown in Figure

6.4. Compared to the transmitted data in Figure 6.1, the quadrants in which the plots occupy are

more clearly defined and there is less overlap of plot points from one quadrant to another.

The symbol synchronised data_IQ is shown in Figure 6.5. If frequency offset and initial

acquisition process are disregarded, it is observed that the spreading has further decreased

resulting in two distinct quadrants which corresponds to data bits “0” and “1”. After the captured

data passes through the entire receive chain, including symbol synchronization, the recovered

data are partially cross-correlated with the PN9 sequence to determine the similarity. The best

alignment is shown by the peak value of 510 (Figure 7.1), meaning there are 2 incorrect bits

present. Figure 7.2 identifies which bits are recovered incorrectly. The bits recovered incorrectly

are the 2nd and 3rd bits which is due to acqusisition error of the timing recoverty module.

The PLL symbol synchronization algorithm used in recovering is highly successful as out of total

of 512 bits transmitted, 510 are successfully recovered. This shows the reliability in symbol

synchronisation through the use of interpolation in PLL.

Figure 6.5: Scatterplot of

synchronised data

Figure 6.4:

Scatterplot of

filtered data

Figure 7.1:

Cross

correlation

between original

data and

recovered data

Figure 7.2:

Comparison of

original set of

bits and

recovered bits

Page 8: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

8

CONCLUSION

The project covers the design and simulation study of a DPSK receiver in a communication

systems comprising square root raised cosine filter with roll-off factor of 0.5, phase locked loop

based symbol synchroniser with Gardner Timing Error Detection method and DPSK

demodulation. The DPSK receiver model is able to work close to the ideal BER performance and

can recover data from captured signal. Carrier recovery is not considered in this project as the

impact of frequency offset on receiver performance is not expected to be overly detrimental.

Furthermore both transmitter and receiver are stationary and hence does not suffer from

Doppler's effect. In reality however, carrier offsets result in inter-carrier interference due to

mismatched frequencies and can cause serious detection problem. Hence future studies on real

applications of communication systems will require carrier frequency - in some cases phase

offset - compensation to be taken into account so as to mitigate the negative effects of

synchronisation error.

Page 9: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

9

REFERENCES

1. Richer, M.S. et al. 2006, Advantages/Disadvantages/Applications of Various Modulation

Schemes, The ATSC digital television system, proc. Arlington, Texas: University of Texas at

Arlington, IEEE, vol.94, pp.37-43, Retrieved from

http://www.uta.edu/faculty/krrao/dip/Courses/EE4330/comparison%20of%20modulation%20me

thods.pdf

2. Christiansen, G. 2010, Data Whitening and Random TX Mode, pp3-4. Dallas, Texas: Texas

Instruments Incorporated, Retrieved from http://www.ti.com/lit/an/swra322/swra322.pdf

3. Proakis, J. G., Salehi, M. 2000, Digital Transmission via Carrier Modulation pp286-335.

Contemporary Communication Systems using Matlab, Brooks/Cole Publishing Company,

Thomson Learning

4. Litwin, L. 2001, Matched Filtering and Timing Recovery in Digital Receivers, RF Time and

Frequency: pp32-44, Retrieved from http://mobiledevdesign.com/site-

files/mobiledevdesign.com/files/archive/mobiledevdesign.com/images/archive/0901Litwin32.pdf

5. Viswanthan, M. 2011, Square Root Raised Cosine Filter (Matched/Split Filter

Implementation), Gaussian Waves - Signal Processing Simplified, Retrieved from

http://www.gaussianwaves.com/2011/04/square-root-raised-cosine-filter-matchedsplit-filter-

implementation-2/

6. Jayaraj, N. B. 2010, Minimum Symbol Error Rate Timing Recovery System, pp1-4. Logan,

Utah: Utah State University, Retrieved from

http://www.ece.usu.edu/grad/reports_theses_disseratations/2010/Bage_Jayaraj_Nagendra/thesis.

pdf

7. Berner, M. 2005, Timing and Carrier Recovery, S-72.333 Postgraduate Course in Radio

Communications Fall 2004/Spring 2005, pp6-16, Retrieved from

http://www.feng.pucrs.br/~decastro/pdf/CTRecovery.pdf

8. Cubukcu, E. 2012, Root Raised Cosine (RRC) Filters and Pulse Shaping in Communication

Systems, pp4-8. NASA, Engineering & Science Contact Group (ESCG), Retrieved from

http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20120008631.pdf

9. Langton, C. 2003, Linear Time Invariant (LTI) Systems and Matched Filter, pp1-2. In:

Intuitive Guide to Principles of Communications, Retrieved from http://complextoreal.com/wp-

content/uploads/2013/01/mft.pdf

10. Prapulla, V., Bhattacharjee, R. and Nandi, S. An Implementation of /4-DQPSK Modem on

Fixed Point DSP, Guwahati, India: Indian Institute of Technology Guwahati

11. Smith III, J. O. 2015, MUS420/EE367A Lecture 4A Interpolated Delay Lines, Ideal

Bandlimited Interpolation, and Fractional Delay Filter Design. Center for Computer Research in

Page 10: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

10

Music and Acoustics (CCRMA) Department of Music. Stanford, California: Stanford University,

Retrieved https://ccrma.stanford.edu/~jos/Interpolation/Interpolation_4up.pdf

12. Srinivasan, B., 1994, IS-54 Digital Cellular Modem Implementation on the TMS320C5x,

Application Report. Dallas, Texas: Texas Instruments Incorporated, Digital Signal Processing

Applications - Semiconductor Group

13. Weiss, S., Bennett, M. R., Gibson, E. and Tisdale, N. C. 2000, A Differential QPSK Modem

Using the TMS320C6711DSK, Communications Research Group, School of Electronics &

Computer Science, University of Southampton, SO17 1BJ, UK

14. Weiss, S., Braithwaite, S. J. and Stewart, R. D. 2000, Software π/4-DQPSK Modem: A

Student Project Using the TMS320C6201 EVM Board, Communications Research Group, Dept.

of Electronics & Computer Science, University of Southampton, SO17 1BJ, UK

Page 11: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

11

APPENDIX

MATLAB CODE

There are 2 part: BER simulation and Bit Recovery from Captured Data.

Part 1. BER Simulation

Initialization

close all;

plotmode=false; % true: plot intermediate results

% false: plot only the BER results

Define simulation parameters

Rbit = 400; % Bit rate (bits/second)

M = 2; % Modulation order (2 for BPSK and 4 for QPSK)

BitsPerSym=log2(M); % Bits/Symbol (2 for QPSK)

Rsym = Rbit/BitsPerSym; % Symbol rate (symbols/second)

nSamps = 8; % Number of samples per symbol

% (up-sampling factor in transmitter)

% Calculate sampling frequency in Hz

Fs = Rsym * nSamps;

% frameLength should be large enough for Monte Carlo Simulation

frameLength = 8192*4; % Number of symbols in a frame

% We need add some data before and after in order to get the correct

% computation of BER since some delay is introduced in the simulation

prepost=2*64; % 64 for pre and 64 for post

Plot theoretical BER

% Define the SNR grid

initial_snr = 0;

final_snr = 15;

snr_step = 0.25;

snr_in_dB = (initial_snr:snr_step:final_snr)';

% initialize the Pe

Pe=zeros(size(snr_in_dB));

hber=figure;

for i=1:length(snr_in_dB),

snr = 10^(snr_in_dB(i)/10);

Pe(i)= qfunc(sqrt(2*snr));

Page 12: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

12

end;

semilogy(snr_in_dB, Pe); % theoretical PE

xlabel('E/N_0 (dB)');

grid on

title('Bit Error Rate');

Monte Carlo Simulation of BER

SNR for Monte Carlo Simulation in dB

snr_in_dB_MC=(0:1:15)';

% Simulated Error Rate

smld_ber=zeros(size(snr_in_dB_MC));

for imc=1:length(snr_in_dB_MC)

snrdb=snr_in_dB_MC(imc);

% Ratio of baseband bit energy to noise power spectral density (dB)

EbNodB = snrdb;

% Calculate SNR in dB.

SNR = EbNodB;

Transmitter

1. Generate the random input bit stream

% Generate frameLength*BitsPerSym of random binary data

xBit = randi([0 1], (frameLength+prepost)*BitsPerSym, 1);

2. Convert into symbols

xbitInMatrix = reshape(xBit, BitsPerSym, frameLength+prepost)';

xSym = bi2de(xbitInMatrix); % Convert to integers

% Plot some symbols/bits in a stem plot.

if plotmode

figure;

msym=128; % number of symbols to be plotted

subplot(211);

stem((0:msym-1), xSym(1:msym));

title('Random Symbols');

xlabel('Symbol Index');

xlim([0 msym]);

subplot(212);

stem((0:msym*BitsPerSym-1), xBit(1:msym*BitsPerSym));

title('Random Bits');

Page 13: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

13

xlabel('Bit Index');

xlim([0 msym*BitsPerSym]);

end

3. Baseband Modulation DPSK

% Create a DPSK modulator.

PhaseRotation=0; % DPSK/QPSK

hMod = comm.DPSKModulator(M, ... % modulation order

PhaseRotation, ...

'BitInput',false); % use symbol data as input

% Modulate the symbol data.

txSym = step(hMod, xSym);

% Scatter plot to show the constellation

if plotmode

figure;

subplot(221); plot(txSym, '-o'); title('All (Transition)'); axis equal;

xlabel('In-phase'); ylabel('Quadrature');

subplot(222); plot(txSym, 'o'); hold on;

plot(txSym(2:2:end), 's'); hold off; axis equal; title('All');

xlabel('In-phase'); ylabel('Quadrature');

subplot(223); plot(txSym(1:2:end), 'o'); axis equal; title('Even');

xlabel('In-phase'); ylabel('Quadrature');

subplot(224); plot(txSym(2:2:end), 'o'); axis equal; title('Odd');

xlabel('In-phase'); ylabel('Quadrature');

end

if plotmode

scatterplot(txSym); title('All');

end

% Plot some symbols/bits in stem plots.

if plotmode

figure;

subplot(211);

stem((0:msym-1), real(txSym(1:msym)));

title('Transmitted Symbols (Real)');

xlabel('Symbol Index');

xlim([0 msym]);

subplot(212);

stem((0:msym-1), imag(txSym(1:msym)));

title('Transmitted Symbols (Imag)');

Page 14: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

14

xlabel('Symbol Index');

xlim([0 msym]);

end

4. Apply pulse shaping using matched SRRC filter. Upsample x8

5. Spectrum estimator used to verify that the frequency spectrum of the baseband signal is

centered at zero Hz, and that it has been filtered properly.

% Specify a square root raised cosine filter with a filter length of 8

% symbols and a rolloff factor of 0.2.

nSym = 8; % Length of the filter in symbols

beta = 0.5; % Rolloff factor

% Design the transmitter filter. Apply a gain to normalize passband

% gain to unity.

hXmtFlt = comm.RaisedCosineTransmitFilter('RolloffFactor', beta, ...

'OutputSamplesPerSymbol', nSamps, ...

'FilterSpanInSymbols', nSym, ...

'Gain', 1);

%'Gain', 0.3578);

%b = coeffs(hXmtFlt);

%fvtool(hXmtFlt);

% Apply pulse shaping by upsampling and filtering.

x = step(hXmtFlt, txSym);

% Plot spectrum estimate of signal before pulse shaping.

% Upsampling without filtering

txSymUp=repmat(txSym.', [nSamps 1]);

txSymUp=txSymUp(:);

if plotmode

figure;

pwelch(txSymUp,hamming(512),[],[],Fs,'centered')

title('Spectrum of Upsampled Transmitted Symbol');

end

% Plot spectrum estimate of pulse shaped signal.

if plotmode

hFig = figure;

pwelch(x,hamming(512),[],[],Fs,'centered')

title('Spectrum of Pulse Shaped Transmitted Symbol');

end

Page 15: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

15

% Plot some symbols/bits in a stem plot.

if plotmode

figure;

subplot(211);

stem((0:msym-1), real(txSymUp(1:msym)));

title('Upsampled Transmitted Symbols (Real)');

xlabel('Symbol Index');

xlim([0 msym]);

yl=ylim;

subplot(212);

stem((0:msym-1), imag(txSymUp(1:msym)));

title('Upsampled Transmitted Symbols (Imag)');

xlabel('Symbol Index');

xlim([0 msym]);

ylim(yl);

end

% Plot some symbols/bits in a stem plot.

if plotmode

figure;

subplot(211);

stem((0:msym-1), real(x(1:msym)));

title('Pulse Shaped Transmitted Symbols (Real)');

xlabel('Symbol Index');

xlim([0 msym]);

yl=ylim;

subplot(212);

stem((0:msym-1), imag(x(1:msym)));

title('Pulse Shaped Transmitted Symbols (Imag)');

xlabel('Symbol Index');

xlim([0 msym]);

ylim(yl);

end

Channel

Simulate the communications channel as an delayed channel with AWGN.

% Add white Gaussian noise based on the measured signal power.

%fprintf('Singal Power: %f\n', std(x));

x=x/std(x);

y = awgn(x, SNR-10*log10(nSamps/2));

% Create a delay object to introduce a fixed timing error of 2 samples,

Page 16: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

16

% which is equivalent to 1/2 symbols.

DELAY = dsp.Delay(2);

y = step(DELAY,y);

% Estimate spectrum of the noisy signal and compare it to the spectrum of

% the original upconverted signal.

if plotmode

figure(hFig);

hold on;

pwelch(y,hamming(512),[],[],Fs,'centered')

ax = gca;

hLines = ax.Children;

hLines(1).Color = [1 0 0];

legend('Signal at channel input',...

'Signal at channel output','Location','southwest')

end

Receiver

1. Apply matched SRRC filter

2. Downsample x4

% Create a Raised Cosine receiver filter

hRxFlt = comm.RaisedCosineReceiveFilter( ...

'InputSamplesPerSymbol',nSamps/4, ...

'FilterSpanInSymbols', nSym, ...

'Gain', 0.3578, ...

'DecimationFactor',1); % no downsampling

% Apply pulse shaping by upsampling and filtering.

yFlt = step(hRxFlt, y);

% Downsample x4

yFlt = decimate(yFlt,4);

% Plot spectrum estimate of signal

if plotmode

pwelch(yFlt,hamming(512),[],[],Fs,'centered')

title('Spectrum of Upsampled Received Symbol');

legend('Signal at channel input',...

'Signal at channel output', ...

'Signal after Filter at Rx', ...

'Location','south')

end

% Scatter Plot

Page 17: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

17

if plotmode

scatterplot(yFlt); title('Received Signal aftere Raised Cosin Filtering');

for i=1:4

scatterplot(yFlt(i:4:end));

title(['Scatter Plot for Delay ' num2str(i)]);

end

end

3. Synchronisation PLL algorithm with Gardner TED

4. Downsample x2

% Create a SymbolSynchronizer object to eliminate the timing error.

hSymbolSyn = comm.SymbolSynchronizer('SamplesPerSymbol', nSamps/4,...

'TimingErrorDetector', 'Gardner (non-data-aided)');

ySync = step(hSymbolSyn,yFlt);

%ySync=ySync(1:frameLength);

if plotmode

scatterplot(ySync,4)

title('Synchronized');

end

5. DPSK demodulation

hDemod = comm.DPSKDemodulator(M, ... % modulation order

PhaseRotation, ...

'BitOutput',false);

ySymb = step(hDemod, ySync);

6. Convert the symbol to bits

bitMatrix = de2bi(ySymb,2)';

ybit= bitMatrix(:); % Convert to integers

Analysis

Computer Bit/Symbol Error Rate

Receiver Delay can be estimated from the cross correlation function

[xc, lag]=xcorr(xSym, ySymb);

if plotmode

figure;

plot(lag, xc);

title('Cross Correlation between input and output symbols');

end

[~, i]=max(xc);

td=abs(lag(i)); % time delay introduced

Page 18: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

18

hError = comm.ErrorRate('ComputationDelay',0, 'ReceiveDelay', 0);

errors = step(hError, xSym(prepost/2+(1:frameLength)),

ySymb(prepost/2+td+(1:frameLength)));

smld_ber(imc)=errors(1);

fprintf('SNR=%6.2f Symbol Error rate is: %12.10f\n', SNR, errors(1));

% hBitError = comm.ErrorRate('ComputationDelay',td*BitsPerSym, ...

% 'ReceiveDelay', td*BitsPerSym);

%biterrors = step(hBitError, xBit, ybit);

%fprintf('Bit Error rate is: %f\n', biterrors(1));

Error rates for various SNR values

SNR= 0.00 Symbol Error rate is: 0.1099548340

SNR= 1.00 Symbol Error rate is: 0.0743103027

SNR= 2.00 Symbol Error rate is: 0.0484924316

SNR= 3.00 Symbol Error rate is: 0.0283813477

SNR= 4.00 Symbol Error rate is: 0.0137939453

SNR= 5.00 Symbol Error rate is: 0.0068359375

SNR= 6.00 Symbol Error rate is: 0.0024108887

SNR= 7.00 Symbol Error rate is: 0.0006713867

SNR= 8.00 Symbol Error rate is: 0.0003662109

SNR= 9.00 Symbol Error rate is: 0.0000000000

SNR= 10.00 Symbol Error rate is: 0.0000305176

SNR= 11.00 Symbol Error rate is: 0.0000000000

SNR= 12.00 Symbol Error rate is: 0.0000000000

SNR= 13.00 Symbol Error rate is: 0.0000000000

SNR= 14.00 Symbol Error rate is: 0.0000000000

SNR= 15.00 Symbol Error rate is: 0.0000000000

end

figure(hber);

hold on;

plot(snr_in_dB_MC, smld_ber, '*');

Page 19: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

19

Part 2. Bit Recovery from Captured data

The file conversion of the data to a binary file is given here.

close all

clear all; clc;

% %====================================================

% % retrieve and format waveform file captured by ILA

% %====================================================

%

%data_raw_I = csvread('waveform_diffbpsk_agc.csv', 1,3,[1 3 4096,3]);

%data_raw_Q = csvread('waveform_diffbpsk_agc.csv', 1,4,[1 4 4096,4]);

data_raw_I = csvread('waveform_diffbpsk_noagc.csv', 1,3,[1 3 4096,3]);

data_raw_Q = csvread('waveform_diffbpsk_noagc.csv', 1,4,[1 4 4096,4]);

data_str_I = num2str(data_raw_I);

data_str_Q = num2str(data_raw_Q);

[M,N] = size(data_str_I);

for k=1:M

indx = strfind(data_str_I(k,:),' ');

data_str_I(k,indx) = '0';

end

for k=1:M

indx = strfind(data_str_Q(k,:),' ');

data_str_Q(k,indx) = '0';

end

for k= 1:M

if bin2dec(data_str_I(k,:)) > 2^11-1

data_I(k) = bin2dec(data_str_I(k,:))- 2^12;

else

data_I(k) = bin2dec(data_str_I(k,:));

end;

end

for k= 1:length(data_str_Q)

if bin2dec(data_str_Q(k,:))> 2^11-1

data_Q(k) = bin2dec(data_str_Q(k,:))- 2^12;

else

data_Q(k) = bin2dec(data_str_Q(k,:));

end;

end

data_I = data_I/2048;

data_Q = data_Q/2048;

data_IQ = data_I + 1i*data_Q;

data_IQ=data_IQ(:);

Page 20: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

20

% Plot received data_IQ

scatterplot(data_IQ)

title(['Scatter Plot for DataIQ ']);

PN9 SEQUENCE

Step 0: Generate PN9 sequence. data_IQ is output of the PN9 generator.

Recover the last column of pn9 starting from 9 ones. For every symbol generated, the last bit is

lost. This section recovers the lost bit (the 9th column in PN9 sequence matrix).

m0 = [1 1 1 1 1 1 1 1 1]; % inital value of pn9

n=512;

ypn9=zeros(n, 9);

for i=1:n

n0 = xor(m0(9), m0(5)); % Bit 0 (LSB) and Bit 5 are XORd

m0 = [n0 m0(1:8)]; % XORd value shifted into MSB on next clock

ypn9(i, :)=m0; % stores pn9 sequences in matrix ypn9

%fprintf('%d \n', m0);

fprintf('%-3d: %s \n', i, num2str(m0)); % prints pn9 sequence

end

ypn9rcv = ypn9(:,9); % recover last column of pn9

MATCHED FILTERING

Receiver:

Step 1: Matched filter received data_IQ in receiver

Step 2: Downsample x4

Square Root Raised Cosine Filter with roll-off factor of 0.5 and carrier offset of 200Hz (carrier

offset value not considered)

% Receiver and data parameters

M = 2; % BPSK

nSamps = 8; % x8 oversampling

BitsPerSym = log2(M); % no. of bits per symbol (1)

beta = 0.5; % SRRC roll-off factor

nSym = 8; % no. of symbols per sample

Fs = 3200; % Sampling frequency

Rs = 400; % Symbol rate

% Plot received data with delay

for i=1:nSamps

scatterplot(data_IQ(i:nSamps:end));

title(['Scatter Plot for Delay ' num2str(i)]);

Page 21: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

21

end

% Create an SRRC object for matched filtering.

H = comm.RaisedCosineReceiveFilter( ...

'RolloffFactor', beta, ... % specfiy parameters

'InputSamplesPerSymbol',nSamps, ...

'FilterSpanInSymbols', nSym, ...

'Gain', 0.3578, ...

'DecimationFactor',1); % no downsampling in filter

% Apply downsampling and filtering to recover shape.

data_IQFlt = step(H,data_IQ);

data_IQFlt = decimate(data_IQFlt,4); % decimate 4 times outside filter

scatterplot(data_IQFlt); % Plot filtered data_IQ

title('Scatter Plot for Filtered DataIQ ')

Figure 8.1: Scatterplot for Delay (1) Figure 8.2: Scatterplot for Delay (2)

Figure 8.3: Scatterplot for Delay (3) Figure 8.4: Scatterplot for Delay (4)

Page 22: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

22

SYNCHRONISATION

Receiver: Step 3: Synchronization

Step 4: Down Sampling using Gardner method (x2)

Create a Symbol Synchronizer object to eliminate the timing error. Gardner TED method uses 2

samples/symbol.

hSymbolSyn = comm.SymbolSynchronizer('SamplesPerSymbol', 2,...

'TimingErrorDetector','Gardner (non-data-aided)');

ySync = step(hSymbolSyn,data_IQFlt);

% Plot synchronized data_IQ

scatterplot(ySync,nSamps)

title('Synchronized');

BASEBAND DEMODULATION

Receiver: Step 5 (DPSK demodulation)

Apply matched filtering to the based band signal.

hDemod = comm.DPSKDemodulator(2, ... % modulation order

'BitOutput',true);

yBit = step(hDemod, ySync);

CALCULATE BITS RECOVERED

Step 6: Cross-Correlation to find similarities.

Receiver Delay can be estimated from the cross correlation function. Delay identifies the initial

value of pn9 sequence with respect to

Figure 9.1: Scatterplot for Delay (6) Figure 9.2: Scatterplot for Delay (8)

Page 23: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

23

[ 1 1 1 1 1 1 1 1 1 ] Once initial value is identified, cross-correlate is performed again to find the

no.of bits recovered.

[xc, lag]=xcorr(ypn9rcv, yBit); % Correlate pn9 and output data

figure;

plot(lag, xc);

title('Cross Correlation between pn9 and output symbols');

[~, idx]=max(xc);

td=abs(lag(idx)); % td (time delay) denotes where PN9 seq starts

% ypn9rcv's initial value starts from the td no.

% Generate new pn9 sequence to get original data

m0 = ypn9(td,:); % inital value of pn9 wrt to ypn9

n=512;

ypn9=zeros(n, 9);

for i=1:n

n0 = xor(m0(9), m0(5)); % Bit 0 (LSB) and Bit 5 are XORd

m0 = [n0 m0(1:8)]; % XORd value shifted into MSB on next clock

ypn9(i, :)=m0;

%fprintf('%d \n', m0);

fprintf('%-3d: %s \n', i, num2str(m0));

end

ypn9rcvtd = ypn9(:,9); % original data

% Cross-Correlate original data and output

% Data is binary, hence x => 0,1

% Apply 2x-1 => -1,1 so that for every correct pair of bits +1.

% For every wrong pair of bits -1.

[xc, lag]=xcorr(2*ypn9rcvtd-1, 2*yBit-1);

figure;

plot(lag, xc);

title('Cross Correlation between input and output bits');

[~, idx]=max(xc);

% Find the wrongly recovered bits.

for i=1:512

fprintf('%-3d %d %d\n', i, ypn9rcvtd(i), yBit(i));

end

fprintf('\nWrong Detection:\n');

for i=1:512

if ypn9rcvtd(i)~=yBit(i)

fprintf('%-3d %d %d\n', i, ypn9rcvtd(i), yBit(i));

Page 24: DEMYSTIFYING WAVEFORM DESIGN AND SIGNAL PROCESSING … · (SRRC) are implemented. The SRRC filter is implemented at both the transmitter and receiver ends to achieve matched filtering

24

end

end

% For correct bits recovered plot 0.

% For wrong bits recovered plot 1

figure;

plot(ypn9rcvtd~=yBit);

title('Comparison of original and recovered data')