%matplotlib inline
from numpy import zeros,concatenate,array,arange,ones,linspace
from matplotlib.pyplot import plot,suptitle,xlabel,ylabel,subplot
import math
t = linspace(0,20);
def theta(t): #function for insmath.tanmath.tanious phase
return 3*math.pi*t**2;
def frequency(t): #function for insmath.tanmath.tanious phase
Ws = 6*math.pi*t;
return Ws/(2*math.pi);
subplot(2,1,1)
plot(t,theta(t))#,1);
suptitle('Plot1:Insmath.tanmath.tanious signal phase')
xlabel('t')
ylabel('theta')
fs = frequency(t);
subplot(2,1,2)
plot(t,fs)
suptitle('Plot2:Frequency')
xlabel('t')
ylabel('fs')
# Variables
#v(t) = 80*math.cos[(2*math.pi*10**8*t)+20*math.sin(2*math.pi*10**3*t)] --eq
#v(t) = A*math.cos[Wc*t+Bmath.sin(Wm*t)] --eq7-27
#comparing the above 2 equations we get
A = 80.; #volts
fc = 10.**8; #Hz
fm = 10.**3; #Hz
B = 20.;
# Calculations and Results
print '(a) The carrier cyclic frequency is ',fc,"Hz"
print '(b) The modulating frequency is ',fm,'Hz'
print '(c) The modulation index is ',B
delta_f = B*fm;
print '(d) The frequency deviation is ',delta_f,'Hz'
R = 50.; #ohm
P = A**2/(2*R);
print '(e) The average power is ',P,'W'
# Variables
#from ex 7.2
#v(t) = 80*math.cos[(2*math.pi*10**8*t)+20*math.sin(2*math.pi*10**3*t)] --eq
B = 20.;
# Calculations
delta_theta = B; #for PM
# Results
print 'The maximum phase deviation for PM is ',delta_theta
# Results
print ('The equation becomes');
print ('v(t) = 80*math.cos[(2*math.pi*10**8*t)+10*math.sin(4*math.pi*10**3*t)]');
# Results
print ('The equation becomes');
print ('v(t) = 80*math.cos[(2*math.pi*10**8*t)+20*math.sin(4*math.pi*10**3*t)]');
# Variables
delta_f = 12.; #kHz
fm = 4.; #kHz
# Calculations
B = delta_f/fm; #modulating index for FM
# Results
print ('The expression is');
print '(vt) = A*math.cos[2*pi*10**8*t)+%i*math.sin%i*2*pi*10**3*t)]'%(B,fm);
# Variables
delta_theta = 6.; #kHz
fm = 5.; #kHz
# Results
print ('The expression is');
print '(vt) = A*math.cos[2*pi*10**8*t)+%i*math.sin%i*2*pi*10**3*t)]'%(delta_theta,fm);
# Variables
delta_f = 400.; #Hz
fm = 2000.; #Hz
# Calculations and Results
B = delta_f/fm; #
print 'The modulation index is',B
print ('(For B< = 2.5 , the signal is NBFM)');
Bt = 2*fm;
print 'The transmission bandwidth Bt = %i Hz '%(Bt)
# Variables
delta_f = 8000; #Hz
fm = 100.; #Hz
# Calculations and Results
B = delta_f/fm; #
print 'The modulation index is',B
print ('(For B> = 50 , the signal is VWBFM)');
Bt = 2*delta_f;
print 'The transmission bandwidth Bt = %i Hz '%(Bt)
# Variables
delta_f = 6.; #kHz
W = 2.; #kHz
# Calculations and Results
D = delta_f/W; #deviation ratio
print 'The deviation ratio is',D
Bt = 2*(delta_f+W); #carsom's rule is applicable
print 'The transmission bandwidth Bt = %i kHz '%(Bt)
# Variables
W = 2.; #kHz (as in ex 7.10)
delta_theta = 3.;
# Calculations
Bt = 2*(1+delta_theta)*W; #applying carsom's rule
# Results
print 'The transmission bandwidth Bt = %i kHz '%(Bt)
%matplotlib inline
from numpy import zeros,concatenate,array,arange,ones,linspace
from matplotlib.pyplot import plot,suptitle,xlabel,ylabel,subplot
import math
delta_f = 75; #kHz
fm = array([.025, .075, .75, 1.5, 5, 10, 15]) #in kHz
def Beta(fm,delta_f):
return delta_f *(1/fm);
def Bandwidth(fm,delta_f):
Bt = zeros(7)
Bt[0:3] = 2 *delta_f;
for i in range(3,7):
Bt[i] = 2 *(delta_f + fm[i]);
return Bt
B = Beta(fm,delta_f);
Bt = Bandwidth(fm,delta_f); #applying carsom's rule
print ('Table - 7.2');
print ('fm(kHz) Beta Bt(kHz)');
for i in range(7):
print '%4.3f '%(fm[i]),
print '%4.1f '%(B[i]),
print '%i'%(Bt[i]);
plot(fm,Bt);
suptitle('Bandwidth of FM')
xlabel('fm,kHz')
ylabel('Bt,kHz')
%matplotlib inline
from matplotlib.pyplot import plot,suptitle,xlabel,ylabel
from numpy import array
# Variables
delta_f = 75; #kHz
fm = array([.025, .075, .75, 1.5, 5, 10, 15]) #in kHz (From prob-7.12)
# Calculations and Results
delta_theta = delta_f/fm[6];
Bt = 12*fm; #applying carsom's rule
print 'Delta theta = ',delta_theta
plot(fm,Bt);
suptitle('Bandwidth of PM')
xlabel('fm,kHz')
ylabel('Bt,kHz')
# Variables
delta_f1 = 2.; #kHz
fc1 = 100.; #kHz
W = 5.; #kHz
# Calculations and Results
fc2 = 3*fc1;
print '(a) The output center frequency = ',fc2
delta_f2 = 3*delta_f1;
print '(b) The output frequency deviation = ',delta_f2
D1 = delta_f1/W;
D2 = 3*D1;
print '(c) The output deviation ratio = ',D2
# Variables
Kf = 4.; #kHz/V
f0 = 100.; #kHz
# Calculations and Results
# Part a
vm = 2.; #Volts
delta_f = Kf*vm; #kHz
f = f0+delta_f; #kHz
print '(a) The change in frequency is',delta_f,'Corresponding frequwncy to this input is',f
#Part b
vm = -3; #Volts
delta_f = Kf*vm; #kHz
f = f0+delta_f; #kHz
print '(b) In this case,the change in frequency is',delta_f,'Corresponding frequwncy to this input is',f
import math
from numpy import array,concatenate,zeros
#All frequencies in kHz
fci = 100.; #basic center frequency
fco = 100000.; #output center frequency
delta_f = (3000./3072)*0.025; #maximum frequency deviation at modulator
W = 15.;
D = delta_f/W;
Bt = 2*W;
table_row1 = array([fci ,delta_f, D, Bt]); #At point A
def table(table_row,multiplier):
return concatenate((table_row[0:3]*multiplier ,[table_row[3]]))
table_row2 = table(table_row1,4); #at point B
table_row3 = table(table_row2,4); #at point C
table_row4 = table(table_row3,4); #at point D
def table1(table_row,multiplier):
table1 = zeros(4)
table1[0:3] = table_row[0:3]*multiplier;
Bt = 2*(table1[1]+W); #Applying carsons rule Bt = 2*(delta_f+W)
table1[3] = Bt;
return table1
table_row5 = table1(table_row4,3); #at point E ,carsons rule applied from here
table_row6 = concatenate(([(fco/16)], table_row5[1:4])); #at point F ,center frequency after mixer
table_row7 = table1(table_row6,4); #at point G
table_row8 = table1(table_row7,4); #at point H
table_row9 = table_row8; #at point I
print ('Point fc delta_f D Bt');
def lay(Point,t_row):
print " %c %8.0i"%(Point,t_row[0]),
for i in range(1,4):
print " %3.4f"%(t_row[i]),
print ""
lay('A',table_row1);
lay('B',table_row2);
lay('C',table_row3);
lay('D',table_row4);
lay('E',table_row5);
lay('F',table_row6);
lay('G',table_row7);
lay('H',table_row8);
lay('I',table_row9);
# Variables
#All frequencies in kHz
Kd = 2.; #V/kHz
fc = 100.;
# Calculations and Results
# part a
f = 102.5;
delta_f = f-fc;
vd = Kd*delta_f; #V
print '(a) The first case result is',vd
# part b
f = 98.5;
delta_f = f-fc;
vd = Kd*delta_f; #V
print '(a) The second case result is',vd
%matplotlib inline
from numpy import zeros,concatenate,array,arange,ones,linspace
from matplotlib.pyplot import plot,suptitle,xlabel,ylabel,subplot
import math
#All frequencies in Hz
D = 5.; #deviation ratio
fc = array([400., 560., 730., 960.]); #Center frequency
delta_f = 0.075*fc; #frequency deviation
W = delta_f/D ; #modulating frequency
Bt = 2 *(delta_f + W); #Bandwidth
fl = fc - Bt/2; #Lower frequency
fh = fc + Bt/2; #Higher frequency
x = arange(301,1108,1);
y = [1.5];
y = concatenate((y ,zeros(len(arange(302,fl[0]+1)))))
for i in range(3):
y = concatenate((y ,ones(len(arange(fl[i],fh[i]+1)))));
y = concatenate((y ,zeros(len(arange(fh[i]+1,fl[i+1]+1)))));
y = concatenate((y, ones(len(arange(fl[3],fh[3]+1)))));
y = concatenate((y, zeros(len(arange(fh[3],1101)))));
print len(x),len(y)
plot(x,y);
suptitle('Composite baseband spectrum')
xlabel('f,Hz');
delta_frt = D*1046;
Brt = 2*(delta_frt+1046);
print '(b) The RF transmission bandwidth is ',Brt,'Hz'