# Chapter 11: Spread Spectrum (SS) and CDMA Systems¶

## Example 11.1, Page 322¶

In [1]:
import math

#Variable declaration
CR1=1.2288; #Mcps(Clock rate 1)
CR2=5.;#Mcps(Clock rate 2)
R1=9.6; #Information rate in Kbps for CR1
PG2=256;  #Processing Gain for CR2

#Calculations
PG1=10*math.log10(CR1*10**3/9.6);#Processing Gain for CR1
R2=CR2*10**3/PG2;#information rate in Kbps for CR2

#Results
print 'The processing gain for clock rate 1.2288Mcps is %d dB'%PG1
print 'Improvemrnt in information rate is %.2f Kbps'%(R2-R1);

The processing gain for clock rate 1.2288Mcps is 21 dB
Improvemrnt in information rate is 9.93 Kbps


## Example 11.2, Page 326¶

In [2]:
#Variable declaration
#From figure 11.5 we get resultant demodulated signal at a mobile;
Rx=[[1,1,1,1,-3,1],[1,-3,1,1,1,1],[1,-3,1,1,1,-3],[1,-3,1,1,1,1],[-1,3,3,-1,3,-1]];#Resultant demodulated signal at mobile

#from Figure 11.4
c1=[[-1,-1,-1,-1,1,1],[1,-1,1,1,-1,-1],[1,-1,1,-1,-1,-1],[-1,1,1,1,-1,1],[1,-1,-1,1,-1,1]];
c2=[[1,1,-1,1,1,-1],[-1,1,-1,1,-1,-1],[-1,-1,1,1,1,-1],[1,1,-1,-1,1,-1],[1,-1,-1,-1,-1,-1]];
c3=[[-1,-1,1,-1,1,-1],[-1,-1,-1,1,1,1],[-1,1,1,-1,-1,1],[-1,1,-1,-1,-1,-1],[1,1,1,-1,1,1]];

#Calculations&Results
#t={[1  2 3 4 5 6];[7 8 9 10 11 12];[13 14 15 16 17 18];[19 20 21 22 23 24];[25 26 27 28 29 30]};
#for Mobile 1
for i in range(0,5):
Demod1=c1[i][0]*Rx[i][0]+c1[i][1]*Rx[i][1]+c1[i][2]*Rx[i][2]+c1[i][3]*Rx[i][3]+c1[i][4]*Rx[i][4]-1
if(Demod1<0):
B1=1;
else:
B1=0;

#for mobile 2
for i in range(0,5):
Demod2=c2[i][0]*Rx[i][0]+c2[i][1]*Rx[i][1]+c2[i][2]*Rx[i][2]+c2[i][3]*Rx[i][3]+c2[i][4]*Rx[i][4]+1;
if(Demod2<0):
B2=1;
else:
B2=0;

#for mobile 3
for i in range(0,5):
Demod3=c3[i][0]*Rx[i][0]+c3[i][1]*Rx[i][1]+c3[i][2]*Rx[i][2]+c3[i][3]*Rx[i][3]+c3[i][4]*Rx[i][4]-1;
if(Demod3<0):
B3=1;
else:
B3=0;

print "Value of integration at end of bit period for mobile1",Demod1
print "Value of integration at end of bit period for mobile2",Demod2
print "Value of integration at end of bit period for mobile3",Demod3
print "The  recovered signal at mobile 1 is ",B1
print "The  recovered signal at mobile 2 is ",B2
print "The  recovered signal at mobile 3 is ",B3
print "In all cases, Recovered signal is negated value of transmitted signal"

Value of integration at end of bit period for mobile1 -12
Value of integration at end of bit period for mobile2 -8
Value of integration at end of bit period for mobile3 8
The  recovered signal at mobile 1 is  1
The  recovered signal at mobile 2 is  1
The  recovered signal at mobile 3 is  0
In all cases, Recovered signal is negated value of transmitted signal


## Example 11.3, Page 332¶

In [3]:
import math

#Variable declaration
BW=100; #in MHz
Fspac=10;  #frequency spacing in kHz

#Calculations
FreqTones=BW*10**3/Fspac;
Chips=math.log(FreqTones,2);

#Result
print 'Minimum number of chips required are %d chips'%Chips

Minimum number of chips required are 13 chips


## Example 11.4, Page 332¶

In [4]:
import math

#Variable declaration
R=120; #transmission rate in kbps
Hop=2000; #per second
Spectrum=10; #in MHz

#Calculations&Results
#For 32-FSK
Bits_sym=math.log(32,2);
SR=R/Bits_sym;
print 'Bits per symbol are %d'%Bits_sym
print 'Hops per second are 2000 and Symbol rate is %d kbps'%SR
Sym_hop=SR*10**3/Hop;
Min_BW=Sym_hop*SR;
Nonoverlap_hop=Spectrum*10**3/Min_BW;
print 'Symbols transmitted per hop are %d'%Sym_hop;
print 'Number of non-Overlapping hop frequencies are %d'%(round(Nonoverlap_hop))

Bits per symbol are 5
Hops per second are 2000 and Symbol rate is 24 kbps
Symbols transmitted per hop are 12
Number of non-Overlapping hop frequencies are 35


## Example 11.5, Page 332¶

In [5]:
import math

#Variable declaration
R=200;#input data rate in bps
Fhop=200;#per second
k=1;#Multipication_Factor

#Calculations&Results
# We have 32-FSK modulation scheme
Bits_sym=math.log(32,2);
Rs=Fhop/Bits_sym;
print 'There are 200 hops per second and Symbol rate is %d symbols per sec'%Rs;

SDur=1/Rs;
L=Fhop/Rs;
CDur=SDur/L;
Separation=1/CDur;
M=2**Bits_sym;
Hop_BW=k*M*Fhop*L;
Gp=M*k*L;

print ' Minimum separation between frequency tones should be %d Hz'%Separation;
print ' Number of different frequency tones produced by a frequency synthesizer are %d'%M;
print ' Processing Gain is %d'%Gp;
print 'Hopping bandwidth is %d kHz'%(Hop_BW/1000);

There are 200 hops per second and Symbol rate is 40 symbols per sec
Minimum separation between frequency tones should be 200 Hz
Number of different frequency tones produced by a frequency synthesizer are 32
Processing Gain is 160
Hopping bandwidth is 32 kHz


## Example 11.6, Page 342¶

In [6]:
#Variable declaration
M1=[1,0,0,1,1];

Rx1=[[1,1,1,1,-3,1],[1,-3,1,1,1,1],[1,-3,1,1,1,-3],[1,-3,1,1,1,1],[-1,3,3,-1,3,-1],[1,-1,-1,0,0,0]];#Resultant demodulated signal at mobile(Z(t)) from path1
Rx2=[[-1,-1,1,1,1,1],[-3,1,1,-3,1,1],[1,1,1,-3,1,1],[1,-3,1,-3,1,1],[1,1,-1,3,3,-1],[3,1,-1,0,0,0]];#Resultant demodulated signal at mobile(Z(t-2Tc)) from path2
Rx=Rx1+Rx2; #since,Z(t)=z(t)+Z(t-2Tc)

#from Figure 11.13 (d) & Figure 11.14
c1=[[-1,-1,-1,-1,1,1],[1,-1,1,1,-1,-1],[1,-1,1,-1,-1,-1],[-1,1,1,1,-1,1],[1,-1,-1,1,-1,1]];
c2=[[-1,1,-1,-1,-1,-1],[1,1,1,-1,1,1],[-1,-1,1,-1,1,-1],[-1,-1,-1,1,1,1],[-1,1,1,-1,-1,1],[-1,1,0,0,0,0]];

#Calculations&Results
#case-1:Z(t)*C1(t);
for i in range(0,5):
Demod_1=c1[i][0]*Rx[i][0]+c1[i][1]*Rx[i][1]+c1[i][2]*Rx[i][2]+c1[i][3]*Rx[i][3]+c1[i][4]*Rx[i][4]+c1[i][5]*Rx[i][5];
if(Demod_1<0):
B1=1;
else:
B1=0;

#case-2:Z(t)*C1(t-2Tc);
for j in range(0,5):
Demod_2=c2[j][2]*Rx[j][2]+c2[j][3]*Rx[j][3]+c2[j][4]*Rx[j][4]+c2[j][5]*Rx[j][5]+c2[j+1][0]*Rx[j+1][0]+c2[j+1][1]*Rx[j+1][1]-10
if(Demod_2<0):
B2=1;
else:
B2=0;

print "case-1:z(t)*c1(t)";
print "Value of integration at end of bit period for mobile(case-1)",Demod_1
print "The recovered signal at mobile(case-1) is ",B1
print "Actual bit values are",M1
print "Recovered and actual values are not matching",

print "\n\ncase-2:z(t)*c1(t-2Tc)"
print "Value of integration at end of bit period for mobile(case-2)",Demod_2
print "The recovered signal at mobile(case-2) is ",B2
print "Actual bit values are",M1
print "Recovered and actual values are not matching",

#case3-Sum of path1 and path2
print "\n\ncase-3:Sum of path1 & path2 integrator"
Demod_3=Demod_1+Demod_2;
print "Sum of integrator outputs(rake receiver output)",Demod_3

for k in range(0,5):
if(Demod_3<0):
B3=1;
else:
B3=0;

print "Detected bit value ",B3
print "Actual bit values are",M1
print "Recovered and actual values are matching"

case-1:z(t)*c1(t)
Value of integration at end of bit period for mobile(case-1) -12
The recovered signal at mobile(case-1) is  1
Actual bit values are [1, 0, 0, 1, 1]
Recovered and actual values are not matching

case-2:z(t)*c1(t-2Tc)
Value of integration at end of bit period for mobile(case-2) -12
The recovered signal at mobile(case-2) is  1
Actual bit values are [1, 0, 0, 1, 1]
Recovered and actual values are not matching

case-3:Sum of path1 & path2 integrator
Sum of integrator outputs(rake receiver output) -24
Detected bit value  1
Actual bit values are [1, 0, 0, 1, 1]
Recovered and actual values are matching


## Example 11.7, Page 360¶

In [7]:
#Variable declaration
Prm=-97;#the signal strength from the base stations in  dBm
#The constant ( K ) is the part of the broadcast message that is sent to the mobile by the base station on the paging channel.
K=-73; #dB
P2=18; #power as directed by BS (dBm)

#Calculations&Results
Ptm=K-Prm;
print 'The mobile transmitter power be set as a first approximation of %d dBm'%Ptm
Pwr_Redu=Ptm-P2;#power reduction
print 'Power reduction = %d dBm'%Pwr_Redu
Time=6*1.25;
print 'Time required by mobile station to make changes as directed by base station is %.1f msec'%Time


The mobile transmitter power be set as a first approximation of 24 dBm
Power reduction = 6 dBm
Time required by mobile station to make changes as directed by base station is 7.5 msec


## Example 11.8, Page 362¶

In [8]:
import math

#Variable declaration
P1=-95; #pilot1 in dBm
P2=-100; #pilot2 in dBm
P3=-101; #pilot3 in dBm
P4=-105; #pilot4 in dBm
P5=-102; #pilot in dBm

#Calculations&Results
#Pcj = received power of the jth pilot in the candidate set
# Pai= received power of the ith pilot in the active set
Pa1=P1-NoiseP;
Pa2=P2-NoiseP;
Pa3=P3-NoiseP;
Pa4=P4-NoiseP;
Pc5=P5-NoiseP;

X=10*math.log10(10**(0.1*Pa1)+10**(0.1*Pa2)+10**(0.1*Pa3)+10**(0.1*Pa4)+10**(0.1*Pc5));
print "Since P1>P2>P3>P4, we replace P4"
T_COMP=(P5-P4)/0.5;
print 'The value of T-COMP that could trigger the mobile station to generate a PSMM should be <= %d dB (<= %d)'%(T_COMP,round(10**(0.1*T_COMP)));

Since P1>P2>P3>P4, we replace P4
The value of T-COMP that could trigger the mobile station to generate a PSMM should be <= 6 dB (<= 4)