# Chapter10 - Comparators¶

## Ex 10.1 - page : 334¶

In [4]:
from __future__ import division
from math import pi, sin
t=range(0,5) #sec(Assumed)
Vin=5*sin(2*pi*t[0]) #V
VCC=15 #V
R2=1 #kohm
R1=6.8 #kohm
VEE=-15 #V
Vsat=13 #V
Vref=R2*VCC/(R1+R2) #V
print "Reference Voltage = %0.2f V " %Vref
print "If Vin>Vref , Vout = %0.2f V " %Vsat
print "If Vin<Vref , Vout = %0.2f V " %-Vsat

Reference Voltage = 1.92 V
If Vin>Vref , Vout = 13.00 V
If Vin<Vref , Vout = -13.00 V


## Ex 10.2 - page 340¶

In [5]:
from __future__ import division
Vsat=7 #V
R1=68 #kohm
R2=82 #kohm
VUTP=R2*Vsat/(R1+R2) #V
VLTP=R2*-Vsat/(R1+R2) #V
print "Upper trip point = %0.2f V " %VUTP
print "Lower trip point = %0.2f V " %VLTP

Upper trip point = 3.83 V
Lower trip point = -3.83 V


## Ex 10.3 - page : 340¶

In [14]:
from __future__ import division
from numpy import arcsin, pi
#Vin=5*sin(omega*t)
Vm=5 #V
Vsat=7 #V
R1=68 #kohm
R2=82 #kohm
VUTP=R2*Vsat/(R1+R2) #V
fi=arcsin(VUTP/Vm)*180/pi #degree
print "Phase shift = %0.2f degree " %fi

Phase shift = 49.94 degree


## Ex 10.4 - page : 344¶

In [15]:
from __future__ import division
VZ1=4.7 #V
VZ2=4.7 #V
R1=68 #kohm
R2=15 #kohm
Vout=VZ1+0.7 #V(As one zener diode is always forward biased)
VR1=Vout #V
IR1=VR1/R1*1000 #micro A
IR2=IR1 #micro A
VR2=IR2*10**-3*R2 #V
Vout=VR1+VR2 #V
VUTP=(R2/(R1+R2))*Vout #V
VLTP=(R2/(R1+R2))*(-Vout) #V
print "VUTP = %0.2f V " %VUTP
print "VLTP = %0.2f V " %VLTP

VUTP = 1.19 V
VLTP = -1.19 V


## Ex 10.5 - page : 346¶

In [16]:
from __future__ import division
Vsat=12.5 #V
Vref=-12.5 #V
R1=80 #kohm
R2=20 #kohm
Beta=R2/(R1+R2) #unitless
UTP=Beta*Vsat+(1-Beta)*Vref #V
LTP=-Beta*Vsat+(1-Beta)*Vref #V
VH=UTP-LTP #V
R3=R1*R2/(R1+R2) #kohm
print "UTP = %0.2f V " %UTP
print "LTP = %0.2f V " %LTP
print "Hysteresis Voltage, VH = %0.2f V " %VH
print "Use R3 = %0.2f kohm " %R3

UTP = -7.50 V
LTP = -12.50 V
Hysteresis Voltage, VH = 5.00 V
Use R3 = 16.00 kohm