Chapter6: A/D, D/A Converters

Ex6.1:pg-311

In [4]:
#Ex 6.1 
n=8  #no. of bits
V1=0  #V
V2=5.12  #V
Res=2**n  #resolution
print Res," =(a) Resolution" 
delVo=(V2-V1)/Res*1000  #mV/bit
print int(delVo)," =(b) Output change per bit(mV/bit)  " 
VFS=V2*(1-1/2**n)  #V
print round(VFS,1)," =(c) Full scale Output voltage(V)  " 
256  =(a) Resolution
20  =(b) Output change per bit(mV/bit)  
5.1  =(c) Full scale Output voltage(V)  

Ex6.2:pg-312

In [8]:
#Ex 6.2
import math
step=10.3  #mV
reading='101101111'  #reading
Vo=step*int(reading,2)/1000  #V
print round(Vo,2)," = Output voltage(V)  " 
3.78  = Output voltage(V)  

Ex6.3:pg-312

In [19]:
 #Ex 6.3
n=8.0 #no. of bits
V=10 #volts
LSB=V*1/2**n  #V
MSB=V*1/2**0  #V 
VFS=MSB-LSB  #V
print int(LSB*1000)," = LSB(mV)  " 
print MSB," = MSB(V)  " 
print round(VFS,3)," = VFS(V)  " 
39  = LSB(mV)  
10  = MSB(V)  
9.961  = VFS(V)  

Ex6.4:pg-312

In [25]:
 #Ex 6.4
import math
  #(i)2-bit DAC
n=2.0  #no. of bits
V=10.0 #max Voltage
step=V/2**n  #V
reading='10'  #input in binary
Vo=step*int(reading,2)  #V
print Vo," =(i) Output Voltage(V)  " 
 #(ii)4-bit DAC
n=4.0  #no. of bits
step=V/2**n  #V
reading='0110'  #input in binary
Vo=step*int(reading,2)  #V
print Vo," =(ii) Output Voltage(V)  " 
 #(i)8-bit DAC
n=8.0  #no. of bits
step=V/2**n  #V
reading='10111100'  #input in binary
Vo=step*int(reading,2)  #V
print round(Vo,2)," =(iii) Output Voltage(V)  " 
5.0  =(i) Output Voltage(V)  
3.75  =(ii) Output Voltage(V)  
7.34  =(iii) Output Voltage(V)  

Ex6.5:pg-313

In [27]:
 #Ex 6.5
import math
n=8.0  #no. of bits
Res=20.0  #mV/bit(Resolution)
reading='00010110'  #input in binary
Vo=Res*int(reading,2)  #V
print Vo/1000," =(a) Output Voltage(V)  " 
reading='10000000'  #input in binary
Vo=Res*int(reading,2)  #V
print Vo/1000," =(b) Output Voltage(V)  " 
0.44  =(a) Output Voltage(V)  
2.56  =(b) Output Voltage(V)  

Ex6.6:pg-313

In [29]:
 #Ex 6.6 
n=12  #no. of bits
Eoff=0.05  #% #maximum offset error
Vref=10.24  #V
Voffset=Eoff/100*Vref  #V
print int(Voffset*1000)," =(a) Offset voltage(mV)  " 
delVo=Vref/2**n  #V/bit
Voff_dash=Voffset/delVo  #in terms of LSB
print int(Voff_dash)," =(b) Offset voltage in terms of LSB  " 
5  =(a) Offset voltage(mV)  
2  =(b) Offset voltage in terms of LSB  

Ex6.7:pg-313

In [30]:
 #Ex 6.7  
n=8  #no. of bits
E=0.2  #% #maximum gain error
Vref=5.1  #V
V11=(100-E)*Vref/100  #V
print V11," =Minimum output voltage(V)  " 
5.0898  =Minimum output voltage(V)  

Ex6.8:pg-326

In [45]:
 #Ex 6.8
n=8.0  #no. of bits
V=10.0  #V maximum
Vin=5.2  #V
oneLSB=V/2**n  #V
print round(oneLSB*1000,1)," =(a) Minimum voltage for 1 LSB in mV  " 
Vifs=round(V-oneLSB,3)  #V

print Vifs," =(b) For all ones input voltage should be (V)  " 
D=Vin/oneLSB  #Digital output in decimal 
print int(D)," =(c) Digital Output  " 
39.1  =(a) Minimum voltage for 1 LSB in mV  
9.961  =(b) For all ones input voltage should be (V)  
133  =(c) Digital Output  

Ex6.9:pg-326

In [52]:
 #Ex 6.9
n=8 #no. of bits
f=1   #MHz(Clock frequency) 
TC=1/f*(n+1)  #seconds
print TC," = time in micro seconds  " 
9  = time in micro seconds