Chapter 7 : Digital Communication

Example 1 : pg 285

In [1]:
 
#page no 285
#prob no 7.1
#calculate the max data rate in both cases
from math import log
# In the given problem a signal is transmitted using a four level code
#given
M=4.;
B=3.2;# in KKz
SNR=35.;#in dB
#calculations and results
#By using Shannon-Hartley theorem, ignoring noise we have
c=2*B*log(M) / log(2);
print 'maximum data rate for four-level code in the available bandwidth',c,'kb/s'
#Now we have to use Shannon limit to find the maximum data rate for any code
#SNR in power ratio is 
SNR1=10**(35./10.);
C=B*log(1+SNR1) /log(2);
print 'maximum data rate for four-level code in the available bandwidth',round(C,2),'kb/s'
# Both results are maxima, we have to choose lesser of the two.
# Therefore we choose c=12.8kp/s
maximum data rate for four-level code in the available bandwidth 12.8 kb/s
maximum data rate for four-level code in the available bandwidth 37.21 kb/s

Example 2 : pg 289

In [2]:
 
#page no. 289
# prob no. 7.2
# In the given problem
#calculate the audible frequency 
#given
fm = 30.# in KHz
fs = 44.1#sampling rate in KHz
#calculations
fa = fs - fm# audible frequency
#results
print 'The audible frequency is',fa,'KHz'
The audible frequency is 14.1 KHz

Example 3 : pg 291

In [3]:
 
#page no 291
#prob no 7.3
#calculate the number of levels in both cases
#part a: no of samples,
#given
m=8.;
#calculations and results
N=2**m;# the number of levels
print 'a) The number of levels with m=8 are',N,'levels'
# part b:
m=16;
N=2**m;# the number of levels
print 'b) The number of levels with m=16 are',N,'levels'
a) The number of levels with m=8 are 256.0 levels
b) The number of levels with m=16 are 65536 levels

Example 4 : pg 292

In [4]:
 
# page no 292
# prob no 7.4
#calculate the dynamic range
#In the given problem
#given
m=16.;
#calculations
DR=1.76 +6.02*m ; #Dynamic range for a linear PCM in dB
#results
print 'Dynamic range for a linear PCM',DR,'dB'
Dynamic range for a linear PCM 98.08 dB

Example 5 : pg 295

In [5]:
 
#page no 295
# prob no 7.5
#calculate the min data rate required
# in the given problem
#given
fs=40.; m=14;
#calculations
# the minimum data rate needed to transmit audio is given by
D=fs*m;
#results
print 'The minimum data rate needed to transmit audio is ',D,'Kb/s'
The minimum data rate needed to transmit audio is  560.0 Kb/s

Example 6 : pg 294

In [6]:
 
# page no 294
# prob no 7.6
#calculate the max output voltage required
# In the given problem, input to a mu-law compresser is +ve,
# with its voltage one-half the max value
from math import log
#given
u=255.;
Vi=1.;#maximum input value is considered as unity volts
vi=0.5;
V0=1.;#consider maximum output voltage as unity volts
#calculations
vo=V0* log(1+u*vi/Vi)/log(1+u);
#results
print 'The maximum output voltage produced is',round(vo,3),'volts'
The maximum output voltage produced is 0.876 volts