from numpy import pi
# Given data
R1= 5 # in kΩ
R2= 10.0 # in kΩ
V_peak= R1*R2/(R1+R2) # in V
Vav= V_peak/pi # in V
print "Peak value of V1 = %0.2f V" %V_peak
print "Average value of Vo = %0.2f V" %Vav
import math
from __future__ import division
from math import exp
# Given data
t= 0
Vc= 0 # in volts
Vo= 5 # in volts
R= 10 # in 2 Ω (assume)
RC= 1 # (assume)
R3= 2*R # in Ω
R2= 3*R # in Ω
# From equation : T= 2*Rf*C*log[1+2*R3/R2]
T= 2*RC*math.log(1+2*R3/R2)
Vc_t= 2 # in volts
t= T/2
#Voltage across capacitor,
# Vc_t= Vco*[1-%e**(-t/ReqC)]= 1/5*(VR+4*Vo)*[1-%e**(-t/4*RC/5)]
VR= Vc_t*5/(1-exp((-t/(4*RC/5))))-4*Vo
print "The value of VR = %0.2f volts" %VR
from __future__ import division
# Given data
# Part (c)
R1= 150 # in Ω
R2= 68*10**3 # in Ω
Vin= 50*10**-3 # in V
Vsat= 14 # in V
Vpositive= Vsat*(R1/(R1+R2)) # in V
V_UT= Vpositive # in V
Vpositive= -Vsat*(R1/(R1+R2)) # in V
V_LT= Vpositive # in V
print "The value of V_UT = %0.4f V" %V_UT
print "The value of V_LT = %0.4f V" %V_LT
# Given data
V_UT= 5 # in V
V_LT= -5 # in V
# Hysteresis voltage,
Vhy= V_UT-V_LT # in V
print "The hysteresis voltage = %0.f V" %Vhy