import math
import scipy
from scipy.optimize import fsolve
#Variable declaration
Pe=10**-6;#Probability of error
e=2.71828; #Euler's Number
#Calculations
# For BPSK
#Pe(=10**-6)=e**(-x)/(2*sqrt(%pi*x)); where x=Eb/No
def f(x):
y=2.71828**(-x)/(2*math.sqrt(math.pi*x))-10**-6
return y
x = fsolve(f,0.1);
#Results
print 'Eb/No For BPSK is %.2f dB'%(10*math.log10(x));
print 'FSK requires 3 dB more in terms of Eb/N0 to give the same Pe as BPSK so it comes out to be %.2f dB'%(10*math.log10(x)+3);
import math
#Variable declaration
Pe=10.**-6;#Probability of error
No=10.**-10; # PSD in W/Hz
R=100*10**3; #data rate in bps
#Calculations
#From Example 9.1, Eb/N0= 10.54dB (11.32) for Pe=10**-6
#Therefore
Eb_No=11.32; #From Exa. 9.1
# Eb/No = A**2/(2*No*R);
A=math.sqrt(2*No*(Eb_No)*R);
#Result
print 'Amplitude of a carrier signal is %.3f mV'%(A*1000);
#Incorrect answer in textbook
#Variable declaration
B=['00','10','01','11','01','00','11','10','10','01','01','00'];#Given Bit stream
#Calculations&Results
print "Phase transition table for pi/4-DQPSK Modulation is given as "
print " By Referring Table 9.1 on page No 266 i.e"
print "Symbol Phase transition"
print "00 => 45°"
print "01 => 135°"
print "10 => -45°"
print "11 => -135°"
print "sym Dell phi(k) Phi(k)"
#BitStream='001001110100111010010100';
phase=0; #Taking initial phase as zero
for i in range(0,12):
if(B[i]=='00'):
phase=phase+45;
print ' %s 45 %d'%(B[i],phase);
if(B[i]=='01'):
phase=phase+135;
print ' %s 135 %d'%(B[i],phase);
if(B[i]=='10'):
phase=phase-45;
print ' %s -45 %d'%(B[i],phase);
if(B[i]=='11'):
phase=phase-135;
print ' %s -135 %d'%(B[i],phase);
print 'final phase for the pi/4-DQPSK modulation method for given bitstream is %d degree'%phase
#Variable declaration
CHBW=200; #Channel BW in KHz
R=270.83; #Data rate in kbps
Fc=900; #carrier frequency in MHz
#Calculations
FreqShift=0.5*R;
#Transmitted Frequencies
Fh=Fc*1000+0.25*R;#Max
Fl=Fc*1000-0.25*R;#Min
BWEff=R/CHBW;
#Results
print 'The frequency shift between binary 1 and binary 0 is %.3f kHz'%FreqShift;
print 'Maximum and Minimum value of transmitted frequencies are %.4f mHz and %.4f mHz respectively'%(Fh/1000,Fl/1000);
print 'Bandwidth efficiency is %.2f bps/Hz'%BWEff
import math
#Variable declaration
R=270.; #data rate in kbps
Eb_No=6.; # in dB
GMSK=0.3; #Gaussian minimum shift keying
#Calculations&Results
Tb=1./R *10**3; #in microsec
B=GMSK/Tb;
print '3-dB BW for a gaussian low pass filter is %.f kHz'%(B*1000);
PowerBW=1.41*R;
DegradFac=0.89;
Pe=math.erfc(math.sqrt(2*DegradFac*10**(0.1*Eb_No)));
print 'Power bandwidth in the RF channel is %.1f kHz'%PowerBW
print 'Bit error probability for GMSK is %.1e'%Pe; #Incorrect answer in textbook
import math
#Variable declaration
Rs=19200; #symbols per second
states=64;
#Calculations
Bits_symbol=math.log(states,2);
BitRate=Bits_symbol*Rs;
#Result
print 'Bit Rate of the modulator is %.1f kbps'%(BitRate/1000)
import math
import scipy
from scipy.optimize import fsolve
#Variable declaration
Rb=144; #data rate in kbps
BW=36; #in MHz
Pb=3*10**-5;#probability of bit error
#Calculations
Seff=Rb/BW; #spectral efficiency in bps/Hz
M=2**(Rb/BW); #since the channel is band limited
#since Q[sqrt(2*Eb_No)]=(1/2)*erfc[sqrt(Eb_No)] # refer page no 257 equ 9.35
def f(x):
y=(3./8)*math.erfc(math.sqrt((2./5)*x))-Pb #from eqn 9.66 and 9.35
return y
x = fsolve(f,0.1)
#Result
print 'For a rectangular constellation (refer Figure 9.12), with a Gaussian channel and matched filter reception, the calculated Eb/No value is %.1f dB'%(10*math.log10(x));
import math
import scipy
from scipy.optimize import fsolve
#Variable declaration
Pb=10**-8;#BER probability
#Calculations&Results
print "For 16-PSK:"
# Pb=0.5*Q(0.552*sqrt(Eb_No));
#since Q[sqrt(2*Eb_No)]=(1/2)*erfc[sqrt(Eb_No)] # refer page no 257 equ 9.35
def f(x):
y=0.25*math.erfc(math.sqrt(0.5*0.552**2*x))-Pb
return y
x = fsolve(f,0.1)
print 'Using equation 9.50 we get Eb/No as %d dB (approx)'%round(10*math.log10(x));
print "For 16-QAM"
#Pb=0.75*Q(sqrt(0.8*Eb_No));
def f(x1):
y=(3./8)*math.erfc(math.sqrt(0.4*x1))-Pb
return y
x1 = fsolve(f,0.1)
#since Q[sqrt(2*Eb_No)]=(1/2)*erfc[sqrt(Eb_No)] # refer page no 257 equ 9.35
print 'Using equation 9.66 we get Eb/No as %d dB (approx)'%round(10*math.log10(x1));
print 'Thus 16-QAM has an advantage of about %d dB compared to 16-PSK'%(10*math.log10(x)-10*math.log10(x1));
#Variable declaration
M=8; #number of different signal elements
Fc=250; #carrier frequency in kHz
DelF=25; #kHz
Pe=10**-6;#probability of error
#Calculations
TotalBW=2*M*DelF;
nb=2*math.log(M,2)/(M+3);
#Pe=7*Q(z) and z=approx(5.08)
z=5.08;
Eb_No=(z)**2/math.log(M,2);
bits_sym=math.log(M,2);
#Results
print 'Total bandwidth required is %d kHz \n '%TotalBW;
print 'The bandwidth efficiency is %.4f \n '%nb;
print 'The required Eb/No is %.3f dB \n '%(10*math.log10(Eb_No));
print 'Carried bits per symbol are %d \n '%bits_sym;