Chapter 5: Signals and Data Transmission

Example 5.1, Page 71

In [66]:
#Initialisation
n=8                                 #8 bit
n2=16                               #16 bit
n3=32                               #32 bit

#Calculation
c=2**n                               #value for 8 bit
c2=2**n2                             #value for 16 bit
c3=2**n3                             #value for 32 bit

#Result
print'An 8-bit word can take 2^8 = %d values\n'%c
print'An 16-bit word can take 2^16 = %d values\n'%c2
print'An 32-bit word can take 2^32 = %f x 10^9 values\n'%(c3/10**9)
An 8-bit word can take 2^8 = 256 values

An 16-bit word can take 2^16 = 65536 values

An 32-bit word can take 2^32 = 4.000000 x 10^9 values

Example 5.2, Page 71

In [67]:
#Initialisation
n=8                                 #8 bit
n2=16                               #16 bit
n3=32                               #32 bit


#Calculation
c=2**n                               #value for 8 bit
p=(1*c**-1)*100                      #percent
c2=2**n2                             #value for 16 bit
p2=(1*c2**-1)*100                      #percent
c3=2**n3                             #value for 32 bit
p3=(1*c3**-1)*100                      #percent

#Result
print'An 8-bit word resolution = %.2f percent\n'%p
print'An 16-bit word resolution = %.4f percent\n'%p2
print'An 32-bit word resolution = %.9f percent\n'%p3
An 8-bit word resolution = 0.39 percent

An 16-bit word resolution = 0.0015 percent

An 32-bit word resolution = 0.000000023 percent

Example 5.3, Page 73

In [64]:
import numpy as np
import matplotlib.pyplot as plt

#data
x = np.linspace(0, 3, 1)
y=2

#plotting

plt.bar(1, y, 0.001*max(x))


xlabel("Frequency in kHz")
ylabel("Voltage")
title("Frequency Spectrum")
plt.axis([0, 2, 0, 3])
plt.grid()
plt.show()

Example 5.4, Page 73

In [65]:
import numpy as np
import matplotlib.pyplot as plt

#data
x = np.linspace(0, 3, 1)
y=2
y1=1

#plotting
plt.bar(1, y, 0.001*max(x))
plt.bar(1.5, y1, 0.001*max(x))


xlabel("Frequency in kHz")
ylabel("Voltage")
title("Frequency Spectrum")
plt.axis([0, 2, 0, 3])
plt.grid()
plt.show()

Example 5.5, Page 74

In [68]:
#Initialisation
f1=7000                         #Human Speech Frequency Upper limit in HZ
f2=50                         #Human Speech Frequency Lower limit in Hz

#Calculation
B=f1-f2                            #Bandwidth in Hz

#Result
print'Bandwidth = %.1f kHz'%(B*1000**-1)
Bandwidth = 7.0 kHz