100% found this document useful (1 vote)
290 views4 pages

Spread Spectrum - Lab

This document describes a MATLAB simulation of a direct sequence spread spectrum (DS-SS) system with binary phase-shift keying (BPSK) modulation. The simulation implements a DS-SS transmitter that spreads input data with a pseudorandom noise (PN) sequence, modulates the spread signal, and transmits over an additive white Gaussian noise channel. The receiver performs BPSK demodulation, despreading with the same PN sequence, and matched filtering to recover the original data and calculate the bit error rate. Key steps of the simulation include generating the input data and PN sequence, spreading the signal, examining time and frequency domain signals, modeling the channel, and implementing the receiver functions.

Uploaded by

Bibhakar Saha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
290 views4 pages

Spread Spectrum - Lab

This document describes a MATLAB simulation of a direct sequence spread spectrum (DS-SS) system with binary phase-shift keying (BPSK) modulation. The simulation implements a DS-SS transmitter that spreads input data with a pseudorandom noise (PN) sequence, modulates the spread signal, and transmits over an additive white Gaussian noise channel. The receiver performs BPSK demodulation, despreading with the same PN sequence, and matched filtering to recover the original data and calculate the bit error rate. Key steps of the simulation include generating the input data and PN sequence, spreading the signal, examining time and frequency domain signals, modeling the channel, and implementing the receiver functions.

Uploaded by

Bibhakar Saha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ECS 701 Communication Theory Lab Session: Wireless communication systems simulation using MATLAB 3.

Direct Sequence Spread Spectrum System

December 2013

DS-SS Transmission System

The purpose of this experiment is to simulate the digital communication system using Direct Sequence Spread Spectrum with phase shift keying modulation, and observe and analyze signals at dierent points in the system. A digital DS-SS BPSK system is illustrated in Figure 1.

Baseband signal 1/-1

X
PN Sequence Generator

Spreaded Signal

Modulated Signal

+
noise

Modulated Signal with Noise

Demodulated Signal

DeSpreaded Signal

Matched Filter

Recovered Data

2 sin(2 fct )

2 sin(2 fct )

PN Sequence Generator

Figure 1: DS-SS BPSK digital communication system block diagram

1.1

Problem Description

We want to transmit , using a DS-SS BPSK commnication system, a digital data sequence with length of 103 . The digital data sequence should be randomly generated with equal probability for 0and 1. We assume the data has a bit rate of fb = 1Hz . For each bit, we will use a PN sequence with length Nc = 20 to spread the signal. The the carrier used to modulate the data has frequency fc = 4 fb Nc . During the experiment you will: Simulate the transmitter for digital DS-SS BPSK communication. Examine what a DS-SS signal looks like. Examine what happens to the spectrum after spread spectrum. Simulate the transmission channel and receiver of the DS-SS BPSK system. Examine and compare the recovered signal with the original baseband signal.

1.2
1.2.1

Experiment Process
Initilizing the parameters

Open a new MATLAB description le, and insert the following code.

%% Initialize the parameters data = round(rand(1, 1000)); N = length(data); Tb = 1; Nc = 20; fc = 1/Tb*Nc*4; fs = 4*fc; M = fs/Tb; t = 0:1/fs:N*Tb; %Number of bits trasmitting %Symbol duration 1 second %Number of SN chips used for each symbol %Carrier Frequency %Sampling Frequency % Number of samples per symbol %Time vector

After that, save the script and name it as DSSS.m. Run the script by entering DSSS in the MATLAB command window. 1.2.2 Simulation of the transmitter

At the transmitter, you will rstly need to randomly generate a sequence of digital data. i.e. [1,0,0,0,1,1,0,1,...]; After that, you need to generate a PN sequence with appropriate length, and apply spread spectrum by multiplying the baseband signal with the PN sequence. The spreaded spectrum signal will then be transmitted using BPSK modulation. Insert the following code to the MATLAB script and save and run it.

%% At the transmitter side base_band_signal = zeros(1, length(t)); for jj = 1:N if data(jj) base_band_signal((1:M)+M*(jj-1)) = 1; end end base_band_signal = base_band_signal * 2 - 1; %Generate the PN sequence PN = round(rand(1, N*Nc)); %Convert PN to time sampled signal. PN_signal = zeros(1, length(t)); for jj = 1:N*Nc if PN(jj) PN_signal((1:M/Nc)+M/Nc*(jj-1)) = 1; end end PN_signal = PN_signal * 2 - 1; %Direct Sequence Spread Spectrum spreaded_signal = base_band_signal .* PN_signal; %BPSK modulate the spreaded signal modulated_signal = spreaded_signal .* (sqrt(2)/sqrt(Tb)).* sin(2*pi*fc.*t);

1.2.3

Examine the baseband signal, PN sequence, and Spread Spectrum signal

We will rstly look at the signal in time domain. Enter the following commands in the command window.

figure subplot(3,1,1) plot(t(1:10*M), base_band_signal(1:10*M)) axis([t(1), t(10*M), -1.5,1.5]) title('Base Band Signal'); xlabel('Time'); subplot(3,1,2) plot(t(1:10*M), PN_signal(1:10*M)) axis([t(1), t(10*M), -1.5,1.5]) title('PN Sequence'); xlabel('Time'); subplot(3,1,3) plot(t(1:10*M), spreaded_signal(1:10*M)) axis([t(1), t(10*M), -1.5,1.5]) title('Spectrum Spread Signal'); xlabel('Time');

Now we will examine the spectrum characteristics of the Spread Spectrum Signal Enter the following commands in the command window.

n = 2^(nextpow2(length(base_band_signal))); BBS = fft(base_band_signal, n)/fs; SSS = fft(spreaded_signal, n)/fs; df = fs/n; f = (0:df:df*(n-1)) -fs/2; figure subplot(2,1,1) semilogy(f, fftshift(abs(BBS))) axis([-5, 5, 1e-2,1e2]) title('Base Band Digital Signal'); xlabel('Frequency'); subplot(2,1,2) semilogy(f, fftshift(abs(SSS))) axis([-5, 5, 1e-2,1e2]) title('Spread Spectrum Signal'); xlabel('Frequency');

Note the change in spectrum. Why is it called spread spectrum? 1.2.4 Simulation of transmission channel

The simplest channel model for simulation and anaslysis is a Additive White Gaussian Noise AWGN channel. And this is what we are going to do here. We need to calculate the actual noise signal (with correct variance) satisfying a given Eb /N0 value. And the noise signal is added to the modulated signal (Additive Noise). Insert the following code to the matlab script and save it.

%% At the transmission channel % calculate noise that is added to the transmitted signal EbNo_dB = 20; % white gaussian noise with 0dB variance noise = 1/sqrt(2)*(randn(1,length(t)) +1i*rand(1, length(t))); % Actual noise satisfying required EbNo value snr = 10.^(EbNo_dB/10)*(1/Tb)/fs; actual_noise = noise./sqrt(snr); received_signal = modulated_signal + actual_noise;

1.3

Simulation of PSK receiver

We use coherrent PSK receiver to demodulate the received signal. The rst step is to BPSK demodulate the received signal by multiplying the carrier signal. The second step is to de-spread the demodulated signal to recover the original data. Insert the following code to the matlab script.

%% At the receiver side % BPSK demodulate the received signal demodulated_signal = received_signal .* (sqrt(2)/sqrt(Tb)).* sin(2*pi*fc.*t); % De-Spread the demodulated signal deSpreaded_signal = demodulated_signal .* PN_signal; % Pass the de-spread signal through a matched filter windowSize = 15; deSpreaded_signal_filtered = filter(ones(1,windowSize)/windowSize,1,deSpreaded_signal); % Decision making, data recovering for ii = 1:N if deSpreaded_signal_filtered(ii*M - M/2) > 0 demodulated_data(ii) = 1; else demodulated_data(ii) = 0; end end % Calcuating BER Err = demodulated_data - data; nErr = length(find(Err ~= 0)); Err_rate = nErr / N;

Run the script and then enter the following code in the command window to compare the recovered signal with the original signal.

figure subplot(2,1,1) plot(t(1:10*M), base_band_signal(1:10*M)) axis([t(1),t(10*M),-1.5,1.5]) title('Base Band Signal'); xlabel('Time'); subplot(2,1,2) plot(t(1:10*M), real(deSpreaded_signal_filtered(1:10*M))) axis([t(1),t(10*M),-3,3]) title('Recovered Signal'); xlabel('Time');

First Draft B. Zhong. Dec 2012. Revision B. Zhong. Nov 2013. 4

You might also like