In [1]:

```
# To compute the carrier power, percentage of total power in carrier power and power in each sideband.
# Given data
PAM=10*10**3# # Power of transmitted AM signal
k=0.6# # Modulation index
# To compute the carrier power
Pc=PAM/(1+k**2/2)# # The carrier power
# To compute percentage of total power in carrier power
PercentPc=(Pc/PAM)*100# # Percentage of total power in carrier power
# To compute power in each sideband
Psideband=(PAM-Pc)/2# # The power in each sideband
# Answer is varrying due to round-off error
# Displaying the result in command window
print '\n The carrier power = %0.2f kW'%(Pc*10**-3)#
print '\n The percentage of total power in carrier power = %0.1f percentage'%(PercentPc)#
print '\n The power in each sideband = %0.3f kW'%(Psideband*10**-3)#
```

In [2]:

```
# To compute a)the peak frequency deviation b)the modulation index.
# Given data
kf=10*10**3# # Frequency deviation constant gain in Hz/V
fm=4*10**3# # Modulating frequency in Hz
A=4# # Maximum instantaneous value of input signal in V
# To compute the peak frequency deviation
deltaf=A*kf# # The peak frequency deviation in Hz
# To compute the modulation index
betaf=deltaf/fm# # The modulation index
# Displaying the result in command window
print '\n The peak frequency deviation = %0.0f kHz'%(deltaf*10**-3)#
print '\n The modulation index = %0.0f'%(betaf)#
```

In [3]:

```
# To determine the IF bandwidth necessary to pass the given signal.
# Given data
fm=100*10**3# # Modulating frequency in Hz
deltaf=500*10**3# # Peak frequency deviation in Hz
betaf=deltaf/fm# # Modulation index
# The IF bandwidth occupied by FM signal using Carson's rule
BT=2*(betaf+1)*fm# # The IF bandwidth necessary to pass the given signal
# Displaying the result in command window
print '\n Using Carson rule, the IF bandwidth occupied by FM signal = %0.0f kHz'%(BT*10**-3)#
```

In [11]:

```
from numpy import arange
from math import sqrt,pi,tan,atan
%matplotlib inline
from matplotlib.pyplot import plot,subplot,title,show,xlabel,ylabel
# To design an RLC network that implements an IF quadrature FM detector
# Given data
fc=10.7*10**6# #Cut-off frequency in Hz
B=500*10**3# #Bandwidth in Hz
phi=5# #phase shift for good system in degree
Q=tan(pi/180*phi)/((fc+B/2)/fc-fc/(fc+B/2))# #Q-factor
L=10*10**(-6)# #Chosen value of inductor
R=Q*2*pi*fc*L# #Value of Resistor
c1=12.13*10**(-12)# #Chosen value of C1
c=(Q/(R*2*pi*fc))-c1# #Value of capacitor
# Displaying the result in command window
print '\n Value of Resistor required for RLC circuit = %0.3f kohm'%(R*10**(-3))#
print '\n Value of Inductor required for RLC circuit = %0.0f microH'%(L*10**(6))#
print '\n Value of Capacitor required for RLC circuit = %0.0f pF'%(c*10**(12))#
# Magnitude plot
f=arange(0.95*10**7,1.2*10**7+0.1,0.05*10**7) # Frequency range for plotting in Hz
mgh=[]
for ff in f:
mgh.append((2*pi*ff*R*c1)/sqrt(1+Q**2*((ff**2-fc**2)/(ff*fc))**2)) # Magnitude transfer function
subplot(311)#
plot(f,mgh)#
#a=gca()#
#a.data_bounds=[0.95*10**7 0#1.2*10**7 2]# # To see the vertical line hiddden by the y axis
xlabel("Frequency")#
ylabel("Magnitude")
title("Magnitude response")
# Phase plot
f=0.95*10**7 # Initial frequency for plotting
phH=[]
for i in range(0,6):
if f<1.25*10**7 :
phH.append((pi/2)+atan(Q*((f**2-fc**2)/(f*fc)))) # Phase transfer function
f=f+0.05*10**7#
f=arange(0.95*10**7,1.2*10**7+0.1,0.05*10**7)
subplot(313)#
plot(f,phH)#
#a=gca()#
#a.data_bounds=[0.95*10**7 1.2#1.2*10**7 2]# # To see the vertical line hiddden by the y axis
xlabel("Frequency")
ylabel("Phase")
title("Phase response")
show()
```

In [1]:

```
from math import log10
# To determine the analog bandwidth, output SNR improvement if modulation index is increased from 3 to 5 and tradeoff bandwidth for this improvement.
# Given data
fm=5*10**3# # Audio bandwidth of FM signal
betaf1=3# # Initial modulation index
betaf2=5# # Final modulation index
# To determine analog bandwidth
BT1=2*(betaf1+1)*fm# # The analog bandwidth
BT2=2*(betaf2+1)*fm# # The analog bandwidth
# To determine output SNR improvement factor
SNR1=3*betaf1**3+3*betaf1**2# # Output SNR factor for modulation index=3
SNR1=10*log10(SNR1)# # Output SNR factor for modulation index=3 in dB
SNR2=3*betaf2**3+3*betaf2**2# # Output SNR factor for modulation index=3
SNR2=10*log10(SNR2)# # Output SNR factor for modulation index=3 in dB
# To determine improvement in output SNR by increasing modulation index
improvedSNR=SNR2-SNR1# # Improvement in output SNR by increasing modulation index
# Displaying the result in command window
print '\n Using Carson rule, the analog bandwidth at 3 modulation index occupied by FM signal = %0.0f KHz'%(BT1*10**-3)#
print '\n Using Carson rule, the analog bandwidth at 5 modulation index occupied by FM signal = %0.0f KHz'%(BT2*10**-3)#
print '\n Improvement in output SNR by increasing modulation index = %0.1f dB'%(improvedSNR)#
print '\n \n This improvement is achieved at the expenses of bandwidth. For modulation index = 3, a bandwidth of 40kHz is needed,\n while for modulation index = 5 requires bandwidth = 60kHz.'
```

In [2]:

```
from math import log10
# To determine the maximum theoretical datarate and to compare this rate to US digital cellular standard
# Given data
SNR=20# # Signal to noise ratio of wireless communication link in dB
B=30*10**3# # RF bandwidth in Hz
SNR=10**(SNR/10)# # Signal to noise ratio of wireless communication link
# To determine the maximum theoretical datarate
C=B*(log10(1+SNR)/log10(2))# # The maximum theoretical datarate in bps
# Displaying the result in command window
print '\n The maximum theoretical datarate = %0.2f kbps'%(C*10**-3)#
print '\n The USDC data rate is 48.6 kbps, which is only about one fourth the theoretical limit under 20dB SNR condition.'
```

In [3]:

```
from math import log10
# To determine the maximum theoretical datarate and to compare this rate to GSM standard
# Given data
SNR1=10# # Signal to noise ratio in dB
SNR2=30# # Signal to noise ratio in dB
B=200*10**3# # RF bandwidth of channel in Hz
SNR1=10**(SNR1/10)# # Signal to noise ratio
SNR2=10**(SNR2/10)# # Signal to noise ratio
# To determine the maximum theoretical datarate
C1=B*(log10(1+SNR1)/log10(2))# # The maximum theoretical datarate for SNR=10dB
C2=B*(log10(1+SNR2)/log10(2))# # The maximum theoretical datarate for SNR=30dB
# Displaying the result in command window
print '\n The maximum theoretical datarate for 10dB SNR = %0.3f kbps'%(C1*10**-3)#
print '\n The maximum theoretical datarate for 30dB SNR = %0.2f Mbps'%(C2*10**-6)#
print '\n \n The GSM data rate is 270.833 kbps, which is only about 40 percent of the theoretical limit of 10dB SNR condition\n and about 14 percent of theoretical limit of 30dB SNR condition'
```

In [4]:

```
# To find the first zero-crossing RF bandwidth of rectangular pulse and compare to raised cosine filter pulse
# Given data
RectTs=41.06*10**-6# # Symbol period of rectangular pulse
cosineTs=41.06*10**-6# # Symbol period of cosine filter pulse
alpha=0.35# # Rolloff factor of cosine filter pulse
# To find the first zero-crossing RF bandwidth of rectangular pulse
B1=2/RectTs# # The first zero-crossing RF bandwidth of rectangular pulse
# The first zero-crossing RF bandwidth of cosine filter pulse
B2=(1/cosineTs)*(1+alpha)# # The first zero-crossing RF bandwidth of cosine filter pulse
# Displaying the result in command window
print '\n The first zero-crossing RF bandwidth of rectangular pulse = %0.2f kHz'%(B1*10**-3)#
print '\n The first zero-crossing RF bandwidth of cosine filter pulse = %0.2f kHz'%(B2*10**-3)#
```

In [5]:

```
from math import pi,sin,cos
# To determine phase and values of Ik and Qk during transmission of bit stream 001011 using pi/4 DQPSK.
# Given data
theta0=0# # Initial phase in rad
phi1=pi/4# # Carrier phase shift for the input bit pair 11 [Feh91], [Rap91b]
phi2=(3*pi)/4# # Carrier phase shift for the input bit pair 01 [Feh91], [Rap91b]
phi3=(-3*pi)/4# # Carrier phase shift for the input bit pair 00 [Feh91], [Rap91b]
phi4=-pi/4# # Carrier phase shift for the input bit pair 10 [Feh91], [Rap91b]
# For transmission of first pair of bits 00
theta1=theta0+phi3# # Phase of signal during transmission of first bit pair 00
I1=cos(theta1)# # In-phase pulse produced at the output of signal mapping
Q1=sin(theta1)# # Quadrature pulse produced at the output of signal mapping
# For transmission of second pair of bits 10
theta2=theta1+phi4# # Phase of signal during transmission of second bit pair 10
I2=cos(theta2)# # In-phase pulse produced at the output of signal mapping
Q2=sin(theta2)# # Quadrature pulse produced at the output of signal mapping
# For transmission of third pair of bits 11
theta3=theta2+phi1# # Phase of signal during transmission of third bit pair 11
I3=cos(theta3)# # In-phase pulse produced at the output of signal mapping
Q3=sin(theta3)# # Quadrature pulse produced at the output of signal mapping
# Displaying the result in command window
print '\n Phase of signal during transmission of first bit pair 00 = %0.0f degree'%(theta1*(180/pi))#
print '\n In-phase pulse produced during transmission of first bit pair 00 = %0.3f'%(I1)#
print '\n Quadrature pulse produced during transmission of first bit pair 00 = %0.3f'%(Q1)#
print '\n \n Phase of signal during transmission of second bit pair 10 = %0.0f degree'%(theta2*(180/pi))#
print '\n In-phase pulse produced during transmission of second bit pair 10 = %0.0f'%(I2)#
print '\n Quadrature pulse produced during transmission of second bit pair 10 = %0.0f'%(Q2)#
print '\n \n Phase of signal during transmission of third bit pair 11 = %0.0f degree'%(theta3*(180/pi))#
print '\n In-phase pulse produced during transmission of third bit pair 11 = %0.3f'%(I3)#
print '\n Quadrature pulse produced during transmission of third bit pair 11 = %0.3f'%(Q3)#
```

In [6]:

```
# To demonstrate how the received signal is detected properly using baseband differential detector.
# Given data
x1=-0.707#
y1=-0.707#
x2=0.707#
y2=-0.707#
x3=0.707#
y3=0.707#
if x1<0:
print 'S1 = 0'
else:
print '\n S1 = 1'
if y1<0:
print '\n S2 = 0'
else:
print '\n S2 = 1'
if x2<0 :
print '\n S3 = 0'
else:
print '\n S3 = 1'
if y2<0:
print '\n S4 = 0'
else:
print '\n S4 = 1'
if x3<0:
print '\n S5 = 0'
else:
print '\n S5 = 1'
if y3<0 :
print '\n S6 = 0'
else:
print '\n S6 = 1'
```

In [7]:

```
from __future__ import division
# To find 3-dB bandwidth for gaussian low pass filter to produce 0.25GMSK, 90% power bandwidth.
# Given data
Rb=270*10**3# # Channel data rate in bps
BT=0.25# # 3-dB bandwidth-bit duration product
T=1/Rb# # Time
B=BT/T# # 3-dB bandwidth in Hz
# Answer is varrying due to round-off error
# 90% power bandwidth
B1=0.57*Rb# # The 90% power bandwidth
# Answer is varrying due to round-off error
# Displaying the result in command window
print '\n The 3-dB bandwidth-bit duration product = %0.3f kHz'%(B*10**-3)#
print '\n The 90 percent power bandwidth = %0.1f kHz'%(B1*10**-3)#
```

In [8]:

```
from __future__ import division
# To find 3-dB bandwidth for gaussian low pass filter to produce 0.25GMSK, 90% power bandwidth.
# Given data
Rb=190*10**3# # Channel data rate in bps
BT=0.35# # 3-dB bandwidth-bit duration product
T=1/Rb# # Time
B=BT/T# # 3-dB bandwidth in Hz
# Answer is varrying due to round-off error
# 90% power bandwidth
B1=0.57*Rb# # The 90% power bandwidth
# Answer is varrying due to round-off error
# Displaying the result in command window
print '\n The 3-dB bandwidth-bit duration product = %0.3f kHz'%(B*10**-3)#
print '\n The 90 percent power bandwidth = %0.1f kHz'%(B1*10**-3)#
```