Chapter-8 : Comparators And Converters

Example : 8.2 - Page No 256

In [20]:
# Given data
A= 92 # in dB
A= 10**(92.0/20) 
V_CC= 15 # in volt
Vout= 30 # in volt
InputOffsetVoltage= 0 # in V
InputVoltage= Vout/A # in V
print "Input Voltage = %0.4f mV" %(InputVoltage*10**3)
Input Voltage = 0.7536 mV

Example : 8.3 - Page No

In [23]:
# Given data
R1= 2 # in kohm
Rf= 390.0 # in kohm
V_sat= 12 # in V
Bita= R1/(R1+Rf) 
UTP= Bita*V_sat # in volt
LTP= -Bita*V_sat # in volt
print "Value of UTP = %0.1f mv" %(UTP*10**3)
print "Value of LTP = %0.1f mv" %(LTP*10**3)

# Note : In the book, there is an error to convert the value of UTP from volts to milli volts.
Value of UTP = 61.2 mv
Value of LTP = -61.2 mv

Example : 8.5 - Page No 260

In [3]:
from math import exp
# Given data
t=0 
Vc=0 
Vo=5 #in volt
# V1= 2*R/(2*R+3*R)= 2/5*Vo
# Vco= 1/5*VR +4/5*Vo = 1/5*(VR+4*Vo)
# Req= R||4*R= 4/5*R
# Vct= Vco*(1-%e**(-t/(Req*C)))= 1/5*(VR+4*Vo)*(1-%e**(-t/(4*R*C/5)))= 1/5*(VR+4*Vo)*(1-%e**(-1.25*t/(R*C)))
# T= 2*Rf*C*log(1+2*R3/R2)= 2*R*C*log(7/3)= 1.7*R*C
# t= T/2= .85*R*C, Hence
Vct=2 #in volt
# Vct= 1/5*(VR+4*Vo)*(1-%e**1.0625)
VR= Vct*5/(1-exp(-1.0625))-4*Vo 
print "Value of VR = %0.2f volt" %VR
Value of VR = -4.72 volt

Example : 8.6 - Page No 260

In [44]:
from numpy import pi
from math import asin
# Given data
omega= 200*pi # in radians/seconds
f=omega/(2*pi) # in Hz
T=1/f # in sec
T=T*10**3 #in ms
Vin= 7 #in volt
t1= 1/omega*asin(6.0/Vin) # in sec
t1=t1*10**3 # in ms
# The output of the schmitt trigger is at -10 volt
t1= T/2+t1 # in ms
# The output of the schmitt trigger is at +10 volt
t2= 10-t1 # in ms
print "The output of the schmitt trigger is at -10 volt = %0.2f ms" %t1
print "The output of the schmitt trigger is at +10 volt = %0.2f ms" %t2
The output of the schmitt trigger is at -10 volt = 6.64 ms
The output of the schmitt trigger is at +10 volt = 3.36 ms

Example : 8.7 - Page No 261

In [45]:
# Given data
R1= 150 # in ohm
R2= 68.0 # in kohm
R2=R2*10**3 # in ohm
Vin= 500 # in mv
V_sat= 14 #in volt
V_pos= R1/(R1+R2)*V_sat # in volt
V_UT= V_pos #in volt
# In the same way when output is -14 volts and starts increasing in negative direcition 
V_sat=-14 #in volt
V_pos= R1*V_sat/(R1+R2) # in volt
V_LT= abs(V_pos) #in volt
print "Value of V_UT = %0.4f volts" %V_UT
print "Value of V_LT = %0.4f volts" %V_LT
Value of V_UT = 0.0308 volts
Value of V_LT = 0.0308 volts

Example : 8.8 - Page No 262

In [46]:
# Given data
V_UT= 5 # in V
V_LT= -5 # in V
V_sat= 10 # in V (Assume)
# V_UT= (R1/(R1+R2))*V_sat = 5
# V_LT= (-R1/(R1+R2))*V_sat = -5
# 10*R1/(R+R2)= 5
V_hy= V_UT-V_LT # in volt
print "Hysteresis voltage = %0.f volt" %V_hy
Hysteresis voltage = 10 volt

Example : 8.9 - Page No 268

In [36]:
# Given data
V_REF= 10 # in V
V_REF= float(V_REF) # converting into float
MSB2= V_REF/2 # in volt
print "The second MSB weight = %0.f volt" %MSB2
MSB3= V_REF/4 # in volt
print "The third MSB weight = %0.1f volt"%MSB3
MSB4= V_REF/8 # in volt
print "The forth MSB (or LSB) weight = %0.2f volt" %MSB4
DAC= MSB4 
print "The resolution of the DAC = %0.2f volt" %DAC
FullScaleOutput= V_REF+MSB2+MSB3+MSB4 #in volt
print "Full scale output = %0.2f volt" %FullScaleOutput
print "IF Rf is reduced to one-forth then the value of full scale output =" ,round(FullScaleOutput/4,4)," volt"
The second MSB weight = 5 volt
The third MSB weight = 2.5 volt
The forth MSB (or LSB) weight = 1.25 volt
The resolution of the DAC = 1.25 volt
Full scale output = 18.75 volt
IF Rf is reduced to one-forth then the value of full scale output = 4.6875  volt

Example : 8.10 - Page No 268

In [38]:
# Given data
V_REF= -5 # in V
V_B= 0 # in volt
V_A= -5 # in volt
V_A= float(V_A) # converting into float
V_C=V_A 
V_D=V_C 
Vout= -1*(V_A+V_B/2+V_C/4+V_D/8) # in volt
print "Output voltage = %0.3f volt" %Vout
Output voltage = 6.875 volt

Example : 8.11 - Page No 269

In [41]:
# Given data
Dn=16 # in volt
Dn= float (Dn) #converting into float
MSB1= Dn/2 # in volt
print "The first MSB output = %0.f volt" %MSB1
MSB2= Dn/4 # in volt
print "The second MSB output = %0.f volt" %MSB2
MSB3= Dn/8 # in volt
print "The third MSB output = %0.f volt" %MSB3
MSB4= Dn/16 # in volt
print "The forth MSB output = %0.f volt" %MSB4
MSB5= Dn/32 # in volt
print "The fifth MSB output = %0.1f volt" %MSB5
MSB6= Dn/64 # in volt
print "The sixth MSB (LSB) output = %0.2f volt" %MSB6
resolution= MSB6 # in volt
print "The resolution = %0.2f volt" %resolution
fullScaleOutput= MSB1+MSB2+MSB3+MSB4+MSB5+MSB6 
print "Full scale output occurs for digital input of 111111 = %0.2f volt" %fullScaleOutput
# For digital input 101011
D0=16 
D1=16 
D2=0 
D3=16 
D4=0 
D5=16 

Vout= float(D0*2**0 + D1*2**1 + D2*2**2 + D3*2**3 + D4*2**4 + D5*2**5)/2**6 # in volt
print "The voltage output for a digital input of 101011 = %0.2f volt" %Vout
The first MSB output = 8 volt
The second MSB output = 4 volt
The third MSB output = 2 volt
The forth MSB output = 1 volt
The fifth MSB output = 0.5 volt
The sixth MSB (LSB) output = 0.25 volt
The resolution = 0.25 volt
Full scale output occurs for digital input of 111111 = 15.75 volt
The voltage output for a digital input of 101011 = 10.75 volt

Example : 8.12 - Page No 269

In [43]:
# Given data
# For the word 100100
N=6 # Number of bits
a5= 1 # Value of bits
a4= 0 # Value of bits
a3= 0 # Value of bits
a2= 1 # Value of bits
a1= 0 # Value of bits
a0= 0 # Value of bits
Vo= 3.6 # in volt
# Formula Vo= (2**(N-1)*a5 + 2**(N-2)*a4 + 2**(N-3)*a3 + 2**(N-4)*a2 + 2**(N-5)*a1 + 2**(N-6)*a0 ) * K
K= Vo/(2**(N-1)*a5 + 2**(N-2)*a4 + 2**(N-3)*a3 + 2**(N-4)*a2 + 2**(N-5)*a1 + 2**(N-6)*a0 ) 
# For the word 110011
N=6 # Number of bits
a5= 1 # Value of bits
a4= 1 # Value of bits
a3= 0 # Value of bits
a2= 0 # Value of bits
a1= 1 # Value of bits
a0= 1 # Value of bits
Vo= (2**(N-1)*a5 + 2**(N-2)*a4 + 2**(N-3)*a3 + 2**(N-4)*a2 + 2**(N-5)*a1 + 2**(N-6)*a0 ) * K # in volt
print "(i) : The value of Vo for the word 110011 = %0.1f volt" %Vo

# Part(ii)
# For the word 1010
N=4 # Number of bits
a3= 1 # Value of bits
a2= 0 # Value of bits
a1= 1 # Value of bits
a0= 0 # Value of bits
VR= 6 # in volt
Vo= float(VR)/2**N*( 2**(N-1)*a3 + 2**(N-2)*a2 + 2**(N-3)*a1 + 2**(N-4)*a0  ) 
print "(ii) : Value of output voltage = %0.2f volt" %Vo
(i) : The value of Vo for the word 110011 = 5.1 volt
(ii) : Value of output voltage = 3.75 volt

Example : 8.13 - Page No 277

In [44]:
# Given data
R=100 # in kohm
R=R*10**3 # in ohm
C= 1 # in micro F
C=C*10**-6 # in F
V_REF= 5 # in volt
t=0.2 # time taken to read an unknown voltage in second
T=R*C # in second
Vx= T/t*V_REF # in volt
print "Unknown voltage = %0.1f volt" %Vx
Unknown voltage = 2.5 volt

Example : 8.14 - Page No 277

In [49]:
# Given data
f=75 # in MHz
f=f*10**6 # in Hz
# For an 8-bit converter reference voltage
V_REF= 100 # in volt
# For setting D7=1
Vo_7= V_REF*2**7/2**8 #in volt
# For setting D6=1
Vo_6= V_REF*2**6/2**8 #in volt
# For setting D7=1 and D6=1
Vo_76= Vo_7+Vo_6 #in volt
# For setting D5=1 D6=1 and D7=1
Vo_5= float(V_REF*2**5)/2**8+Vo_7+Vo_6 #in volt
print "For setting D7=1 output voltage = %0.f volt" %Vo_7
print "For setting D6=1 output voltage = %0.f volt" %Vo_6
print "For setting D7=1 and D6=1 output voltage = %0.f volt" %Vo_76
print "For setting D5=1, D6=1 and D7=1 output voltage = %0.1f volt" %Vo_5
T=float(1.0/f) # in sec
print "Conversion time = %0.1f ns" %(T*10**9)
For setting D7=1 output voltage = 50 volt
For setting D6=1 output voltage = 25 volt
For setting D7=1 and D6=1 output voltage = 75 volt
For setting D5=1, D6=1 and D7=1 output voltage = 87.5 volt
Conversion time = 13.3 ns

Example : 8.15 - Page No 277

In [52]:
# Given data
f=1 # in MHz
f=f*10**6 # in Hz
f= float(f) # converting into float
T=1/f # conversion time in sec
N=8 # number of bits
tc= N*T # in sec
print "Time of Conversion = %0.f micro sec : " %(tc*10**6)
Time of Conversion = 8 micro sec : 

Example : 8.16 - Page No 277

In [69]:
# Given data
Vin= 2 #in volt
Vout= 10 #in volt
R=100 # in kohm
R=R*10**3 #in ohm
C=0.1 # in  micro F
C=C*10**-6 #in F
# Formula Vout = -1/(R*C)*integrate('Vin','t',0,t) = -Vin*t/(R*C)
t= Vout*R*C/Vin # in sec
print "Maximum time upto which the reference voltage can be integrated,"
print  "t =",round(t,2),"second =",int(round(t*10**3)),"ms"
Maximum time upto which the reference voltage can be integrated,
t = 0.05 second = 50 ms

Example : 8.17 - Page No 280

In [48]:
# Given data
C=0.1 # in  nF
C=C*10**-9 #in F
V=5 #in V
t=1 # in micro S
t=t*10**-6 # in sec
# v= V*(1-%e**(-t/(R*C)))
# Since hold value does not drop by more than 0.5% or by 0.005 V, hold value is 0.995 V, Thus
# 0.995*V= V*(1-%e**(-t/(R*C)))
# or %e**(-t/(R*C))= 1-0.995 = 0.005
R= t/(C*math.log(1/0.005)) # in ohm
I= V/R*(1-exp(-t/(R*C))) # Maximum currnet through R in amphere
print "Maximum permissible leakage current through the hold capacitor = %0.3f mA" %(I*10**3)
Maximum permissible leakage current through the hold capacitor = 2.636 mA