Chapter 9 : Digital communication I Binary Systems

Example 9.1 Page No : 304

In [1]:
# Calculations and Results
bits = 4;
print 'a) M = %i values'%(2**bits);
bits = 8;
print 'b) M = %i values'%(2**bits);
bits = 16;
print 'c) M = %i values'%(2**bits);
a) M = 16 values
b) M = 256 values
c) M = 65536 values

Example 9.2 Page No : 304

In [4]:
import math
# Calculations and Results
N = math.log(100);
print 'a) N = %.2f bits'%(N);
a) N = 4.61 bits

Example 9.3 Page No : 309

In [5]:
%matplotlib inline
from numpy import zeros,concatenate,array,arange,ones,linspace,sin
from matplotlib.pyplot import plot,suptitle,xlabel,ylabel,subplot
import math 

#input graph
t = arange(0,15,.1);
y = concatenate(((1./9)*arange(0,1.1,.1)**2, (1./8)*arange(1.1,2.1,.1)**2.1));
y = concatenate((y, (7./8)*sin(2*math.pi*t[21:150]/18.5)));
plot(t,y);
y = 8*y;   
#quantized form
y1 = [];
for i in range(0,150,10):
    for m in range(-7,8,1):
        if y[i] < m+0.5:
            break;
        
    y1 = concatenate((y1, m*ones(10)))

y1 = y1/8;
plot(t,y1)#,[5]);
# Some operations on entities created by plot2d ...
suptitle('Anamath.log and quantized signals')
xlabel('t,ms')
ylabel('Normalised signal level')
Out[5]:
<matplotlib.text.Text at 0x104c4dd10>

Example 9.4 Page No : 310

In [6]:
# Variables
N = 8.;
Vfs = 20.;  #Volts

# Calculations and Results
delta_Xu = 2**-N;
print 'a)  The normalised unipolar step size is %f '%(delta_Xu);
delta_vu = delta_Xu*Vfs;
print 'b)  The actual step size is %.2f mV '%(delta_vu*10**3);
Xumax = 1-delta_Xu;
print 'c)  The normalized maximum quantized level is %f '%(Xumax);
vumax = Xumax*Vfs;
print 'd)  The actual maximum quantized level is %f V '%(vumax);
Eu = delta_Xu/2;
print 'e)  The normalized peak error is %f '%(Eu);
eu = Eu*Vfs;
print 'f)  The actual peak error is %.2f mV '%(eu*10**3);
a)  The normalised unipolar step size is 0.003906 
b)  The actual step size is 78.12 mV 
c)  The normalized maximum quantized level is 0.996094 
d)  The actual maximum quantized level is 19.921875 V 
e)  The normalized peak error is 0.001953 
f)  The actual peak error is 39.06 mV 

Example 9.5 Page No : 311

In [7]:
# Variables
Vfs = 10.;  #Volts
N = 8.;

# Calculations and Results
delta_Xb = 2**(-N+1);
print 'a)  The normalised bipolar step size is %f '%(delta_Xb);
delta_vb = delta_Xb*Vfs;
print 'b)  The actual step size is %.2f mV '%(delta_vb*10**3);
Xbmax = 1-delta_Xb;
print 'c)  The normalized maximum quantized level is %f '%(Xbmax);
vbmax = Xbmax*Vfs;
print 'd)  The actual maximum quantized level is %f V '%(vbmax);
Eb = delta_Xb/2;
print 'e)  The normalized peak error is %f '%(Eb);
eb = Eb*Vfs;
print 'f)  The actual peak error is %.2f mV '%(eb*10**3);
a)  The normalised bipolar step size is 0.007812 
b)  The actual step size is 78.12 mV 
c)  The normalized maximum quantized level is 0.992188 
d)  The actual maximum quantized level is 9.921875 V 
e)  The normalized peak error is 0.003906 
f)  The actual peak error is 39.06 mV 

Example 9.6 Page No : 313

In [9]:
import math 
from numpy import array,log

# Variables
Vimax = 16.;  #Volts
Vomax = 2.;  #Volts
m = 255.;     #meu

# Calculations
vi = array([2, 4, 8, 16]);
vo = Vomax*log(1+m*vi/Vimax)/math.log(1+m);
table = [vi.transpose(), vo.transpose()];
print ' viV    voV';
print (table);
 viV    voV
[array([ 2,  4,  8, 16]), array([ 1.25972975,  1.50420207,  1.75140614,  2.        ])]

Example 9.7 Page No : 319

In [10]:
# Variables
#all time in ms
#all frequencies in kHz
W = 5.;
N = 8.;  #bits
k = 19.+1;  #word

# Calculations and Results
fs = 2*W;
print 'fs = %i kHz'%(fs);
Tf = 1/fs;
print ' Tf = %.1f ms'%(Tf);
Tw = Tf/k;
print ' Tw = %i micro second'%(Tw*10**3);
tau = Tw/N;
print ' tau = %.3f micro second'%(tau*10**3);
Bt = 0.5/tau;
print ' Bt = %ikHz'%(Bt);
fs = 10 kHz
 Tf = 0.1 ms
 Tw = 5 micro second
 tau = 0.625 micro second
 Bt = 800kHz

Example 9.8 Page No : 323

In [11]:
# Variables
#all frequencies in kHz
R = 200;  #kbits/s

# Calculations
Bt = R;   #kHz

# Results
print ' Bt = %ikHz'%(Bt);
 Bt = 200kHz

Example 9.9 Page No : 326

In [12]:
# Variables
#all frequencies in kHz
R = 200;  #kbits/s
delta_f = 150;  #f1-f0

# Calculations
Bt = delta_f+R;   #kHz

# Results
print ' Bt = %ikHz'%(Bt);
 Bt = 350kHz

Example 9.10 Page No : 329

In [13]:
# Variables
#all frequencies in kHz
R = 200;  #kbits/s

# Calculations
Bt = R;   #kHz

# Results
print ' Bt = %ikHz'%(Bt);
 Bt = 200kHz