The sequence
c(
t) is pseudo-random, unpredictable to an outsider, but that can be generated deterministically. Each user is assigned uniquely one of these sequences—that is, the spreading codes assigned to two users are not related at all. Moreover, the bit rate of
c(
t) is much higher than that of the message. As in many other modulation systems, the modulated baseband signal
x(
t) has a much higher rate than the message, and as such its spectrum is much wider than that of the message that is already wide given that it is a sequence of pulses. This can also be seen by considering that
x(
t) as the product of
m(
t), and
c(
t), its spectrum is the convolution of the spectrum of
m(
t) with the spectrum of
c(
t) with a bandwidth equal to the sum of the bandwidths of these spectra.
When transmitting over a radio link the baseband signal
x(
t) modulates an analog carrier to obtain the transmitting signal
s(
t). At the receiver, if no interference occurred in the transmission, the received signal
r(
t) =
s(
t), and after demodulation using the analog carrier frequency, the spread signal
x(
t) is obtained. If we multiply it by
c(
t) we get
Simulation of direct sequence spread spectrum.
In this simulation we consider that the message is randomly generated and that the spreading code is also randomly generated (our code does not have the same characteristics as the one used to generate the code for spread-spectrum systems). To generate the train of pulses for the message and the code we use filters of different length (recall the spreading code changes more frequently than the message). The spreading makes the transmitting signal have a wider spectrum than that of the message (see
Figure 12.13).
The binary transmitting signal modulates a sinusoidal carrier of frequency 100 Hz. Assuming the communication channel does not change the transmitted signal and perfect synchronization at the analog receiver is possible, the despread signal coincides with the sent message. In practice, the effects of multipath in the channel, noise, and possible jamming would not make this possible.
%%%%%%%%%%%%%%%%
% Simulation of
% spread spectrum
%%%%%%%%%%%%%%%%
clear all; clf
% message
m1 = rand(1,12)>0.9;m1 = (m1-0.5) ∗ 2;
m = zeros(1,00);
m(1:9:100) = m1
h = ones(1,9);
m = filter(h,1,m);
% spreading code
c1 = rand(1,25)>0.5;c1 = (c1-0.5) ∗ 2;
c = zeros(1,100);
c(1:4:100) = c1;
h1 = ones(1,4);
c = filter(h1,1,c);
Ts = 0.0001; t = [0:99] ∗ Ts;
s = m. ∗ c;
figure(1)
bar(t,m); axis([0 max(t) -1.2 1.2]);grid; ylabel(‘m(t)’)
subplot(312)
bar(t,c); axis([0 max(t) -1.2 1.2]);grid; ylabel(‘c(t)’)
subplot(313)
bar(t,s); axis([0 max(t) -1.2 1.2]);grid; ylabel(‘s(t)’); xlabel(‘t (sec)’)
% spectrum of message and spread signal
M = fftshift(abs(fft(m)));
S = fftshift(abs(fft(s)));
N = length(M);K = [0:N-1];w = 2 ∗ K ∗ pi/N-pi; f = w/(2 ∗ pi ∗ Ts);
figure(2)
subplot(211)
plot(f,M);grid; axis([min(f) max(f) 0 1.1 ∗ max(M)]); ylabel(‘—M(f)—’) subplot(212)
plot(f,S); grid; axis([min(f) max(f) 0 1.1 ∗ max(S)]);ylabel(‘—S(f)—’); xlabel(‘f (Hz)’)
% analog modulation and demodulation
s = s. ∗ cos(200 ∗ pi ∗ t);
r = s. ∗ cos(200 ∗ pi ∗ t);
% despreading
mm = r. ∗ c;
for k = 1:length(mm);
if mm(k) > 0
m2(k) = 1;
else
m2(k) = -1;
end
end
figure(3)
subplot(411)
plot(t,s); axis([0 max(t) 1.1 ∗ min(s) 1.1 ∗ max(s)]);grid; ylabel(‘s_a(t)’)
subplot(412)
plot(t,r); axis([0 max(t) 1.1 ∗ min(r) 1.1 ∗ max(r)]);grid; ylabel(‘r(t)’)
subplot(413)
plot(t,mm); axis([0 max(t) 1.1 ∗ min(mm) 1.1 ∗ max(mm)]);grid; ylabel(‘m_a(t)’)
subplot(414)
bar(t,m2); axis([0 max(t) -1.2 1.2]);axis([0 max(t) 1.1 ∗ min(mm) 1.1 ∗ max(mm)])
grid;ylabel(‘m(t)’); xlabel(‘t (sec)’)