Chapter : 12 - D/A and A/D Converters

Example 12.1 : Page No - 444

In [8]:
#Given data
n = 8 
Resolution = 2**n 
print "Part (ii) : The resolution = %0.f" %Resolution 
print "That is, the output voltage can have",int(Resolution),"different values including zero"
V_OFS = 2.55 # in V
Resolution= V_OFS/(2**n - 1)*10**3 
print "\nPart (i) : The resolution =",int(round(Resolution))," mV/1LSB"
print "That is, an input change of 1 LSB causes the output to change by ",round(Resolution)," mV"
Part (ii) : The resolution = 256
That is, the output voltage can have 256 different values including zero

Part (i) : The resolution = 10  mV/1LSB
That is, an input change of 1 LSB causes the output to change by  10.0  mV

Example 12.2 : Page No - 444

In [9]:
#Given data
n = 4 
V_OFS = 15 # in V
digital_input = '0110' # in binary
D= int(digital_input , 2) 
Resolution = V_OFS/((2**n)-1) # in V/LSB
V_out = Resolution*D # in V
print "Final output voltage = %0.f V" %V_out
Final output voltage = 6 V

Example 12.3 : Page No - 445

In [12]:
#Given data
n = 8 
Resolution = 20 # in mV/LSB
digital_input= '10000000' # in binary
D= int(digital_input , 2) # in decimal
Resolution=Resolution*10**-3 # in V/LSB
V_OFS = Resolution * ((2**n)-1) # in V
print "The value of V_OFS = %0.1f V" %V_OFS 
V_out = Resolution*D # in V
print "The value of V_out = %0.2f V" %V_out 
The value of V_OFS = 5.1 V
The value of V_out = 2.56 V

Example 12.4 : Page No - 445

In [15]:
from __future__ import division
#Given data
n = 4 
V_OFS = 5 # in V
digital_input= '1000' # in binary
D= int(digital_input , 2) # in decimal
Resolution = V_OFS/((2**n)-1) 
V_out = Resolution * D # in V
print "When input is 1000 then, the output = %0.4f V" %V_out 
# When
digital_input= '1111' # in binary
D= int(digital_input , 2) # in decimal
V_out= Resolution * D # in V
print "When input is 1111 then , the output  =%0.f V" %V_out
When input is 1000 then, the output = 2.6667 V
When input is 1111 then , the output  =5 V

Example 12.5 : Page No - 445

In [17]:
#Given data
n=12 
digital_input= '010101101101' # in binary
D= int(digital_input , 2) # in decimal
step_size= 8 # in mV
step_size=step_size*10**-3 # in V
VoFS= step_size*(2**n-1) # in V
print "The full scale output voltage = %0.2f V" %VoFS
Per_resolution= step_size/VoFS*100 # in %
print "Percentage resolution is = %0.5f" %Per_resolution
Vout= step_size*D # in V
print "The output voltage in V %0.3f" %Vout
The full scale output voltage = 32.76 V
Percentage resolution is = 0.02442
The output voltage in V 11.112

Example 12.6 : Page No - 450

In [19]:
#Given data
V_R = 10 # in V
n = 4 
Resolution = 0.5 # in V
R_F = 10 # in k ohm
R = (1/2**n)*(V_R/Resolution)*R_F # in k ohm
print "The value of resistor = %0.1f kΩ" %R 
The value of resistor = 12.5 kΩ

Example 12.7 : Page No - 456

In [21]:
#Given data
V_i = 5.1 # in V
n = 8 
Re = 2**n 
Resolution = V_i/(2**n-1) # in V/LSB
print "The Resolution = %0.f mV/LSB" %(Resolution*10**3) 

# When
V_i = 1.28 # in V
D = int(round(V_i/Resolution) )
D_in_binary= bin(D) # in binary
print "The digital output = ",D_in_binary
The Resolution = 20 mV/LSB
The digital output =  0b1000000

Example 12.8 : Page No - 457

In [23]:
#Given data
V_i = 4.095 #input voltage in V
n = 12 
Q_E = V_i/( ((2**n)-1)*2 ) # in V
Q_E = Q_E * 10**3 # in mV
print "The quantizing error = %0.1f mV" %Q_E
The quantizing error = 0.5 mV

Example 12.9 : Page No - 460

In [25]:
#Given data
print "Part (i)"
V_i = 100 # in mV
V_R = 100 # in mV
t1 = 83.33 # in ms
t2 = (V_i/V_R)*t1 # in ms
print "The value of t2 = %0.2f ms" %t2 
print "Part (ii)"
Vi = 200 # in mV
t_2 = (Vi/V_R)*t1 # in ms
print "The value of t_2 = %0.1f ms" %t_2
Part (i)
The value of t2 = 83.33 ms
Part (ii)
The value of t_2 = 166.7 ms

Example 12.10 : Page No - 460

In [26]:
#Given data
C_F = 12 #clock frequency in kHz
C_F = C_F * 10**3 # in Hz
V_i = 100 # in mV
V_R = 100 # in mV
t1 = 83.33*10**-3 # in sec
D = C_F * t1*(V_i/V_R) # in counts
print "The Digital output is : ",int(round(D,1))," counts" 
The Digital output is :  1000  counts

Example 12.12 : Page No - 463

In [28]:
from numpy import pi
#Given data
n = 8 
T_C = 9 #in µsec
T_C = T_C * 10**-6 # in sec
f_max = 1/(2*pi*T_C*(2**n)) # in Hz
print "Maximum frequency = %0.2f Hz" %f_max
Maximum frequency = 69.08 Hz