import math
Vin=10 #ac input(V)
Vs=15 #non-inverting input voltage(V)
R1=200.0*10**3 #non-inverting input resistance R1(Ohm)
R2=100.0*10**3 #non-inverting input resistance R2(Ohm)
C=10*10**-6 #capacitance at non-inverting input(F)
Vref=Vs/3 #reference voltage at trip point(V)
fc=(2*math.pi*((R1**-1+R2**-1)**-1)*C)**-1 #cutoff frequency(Hz)
print 'trip point voltage Vref = ',Vref,'V'
print 'cutoff frequency of bypass circuit fc = ',round(fc,2),'Hz'
import math
Vp=10.0 #sine peak(V)
Vin=5.0 #input voltage(V)
theta=math.ceil((math.asin(Vin/Vp))*180/math.pi) #angle theta (deg)
D=(150-theta)/360.0 #duty cycle
print 'theta = ',theta,'degrees'
print 'duty cycle D = ',round((D*100),2),'%'
R1=1.0 #non-inverting input resistance R1(KOhm)
R2=47.0 #feedback path resistance R2(KOhm)
Vsat=13.5 #saturation voltage(V)
B=R1/(R1+R2) #feedback fraction
UTP=B*Vsat #upper trip point
LTP=-B*Vsat #lower trip point
H=UTP-LTP #hysteresis
print 'lower trip point LTP = ',round(LTP,2),'V'
print 'upper trip point LTP = ',round(UTP,2),'V'
print 'hysteresis is ',round(H,2),'V'
R=2 #inverting input resistance R1(KOhm)
C=1*10**-6 #feedback path capacitance (F)
T=1*10**-3 #time period(s)
Vin=8 #input pulse voltage(V)
AVOL=100000 #open loop voltage gain
V=Vin*T/(R*C)/1000 #output voltage(V)
t=R*C*(AVOL+1)*1000 #time constant(s)
print 'Magnitude of negative output voltage at end of the pulse = ',V,'V'
print 'closed loop time constant = ',t,'s'
R1=1*10**3 #inverting input resistance R1(Ohm)
R2=10*10**3 #feedback path resistance R2(Ohm)
C=10*10**-6 #feedback path capacitance (F)
Vin=5 #input pulse voltage(V)
f=1*10**3 #input frequency(Hz)
Vout=Vin/(2*f*R1*C) #output voltage(V)
print 'peak to peak output voltage = ',Vout,'Vpp'
Vs=15.0 #non-inverting input voltage(V)
Rw=5.0*10**3 #inverting input wiper resistance(Ohm)
R1=10.0*10**3 #inverting input resistance R1(Ohm)
f=1.0 #input frequency(KHz)
Vref=Vs*(Rw/(Rw+R1)) #reference voltage(V)
T=1/f #period of signal(s)
W=2*(T/2)*((Vs/2)-Vref)/Vs #output pulse width
D=W/T #duty cycle
print 'duty cycle D = ',round((D*100),2),'%'
import math
R1=18.0 #non-inverting input resistance R1(KOhm)
R2=2.0 #feedback path resistance R2(KOhm)
R=1.0 #feedback path resistance R(KOhm)
C=0.1*10**-6 #feedback path capacitance (F)
B=R1/(R1+R2) #feedback fraction
T=10**9*2*R*C*math.log((1+B)/(1-B)) #period of output(us)
f=1000*1/T #frequency(KHz)
print 'period T = ',round(T,2),'us'
print 'frequency f = ',round(f,2),'KHz'
Vsat=13.5 #saturation voltage given(V)
R4=10*10**3 #given resistance R4(Ohm)
C2=10*10**-6 #given capacitance C2(F)
T=589*10**-6 #period from preceding example(s)
Vout=Vsat*T/(2*R4*C2) #output voltage (V)
print 'Output voltage = ',round((Vout*1000),2),'mVpp'
R1=1*10**3 #resistance R1(Ohm)
R2=100*10**3 #resistance R2(Ohm)
R3=10*10**3 #resistance R3(Ohm)
C=10*10**-6 #capacitance (F)
UTP=Vsat*R1/R2 #UTP value (V)
Vout=2*UTP #output voltage/hysteresis (V)
f=R2/(4*R1*R3*C) #frequency(Hz)
print 'Vout = H = ',Vout,'V'
print 'frequency f = ',f,'Hz'