from __future__ import division
from numpy import log
#design
#given data :
c1=0.1 #in micro farads
vbb=30 #in volts
n=0.51 #
ip=10 #in micro amperes
vv=3.5 #in volts
iv=10 #in mA
f=50 #in Hz
w=50 #eifth in micro seconds
vd=0.7 #in volts
vp=n*vbb+vd #in volts
vc=vp #in volts
x=log(vv/(vp-vd)) #
r1=-(w*10**-6/(c1*10**-6*x)) #
T=(1/(f))*10**3 #in ms
t1=T-(w*10**-3) # in ms
r=((t1*10**-3)/(c1*10**-6*log(1/(1-n)))) #
r2=(10**4/(n*vbb)) #in ohms
print "Resistance R1 = %0.f ohm" %round(r1)
print "Resistance R = %0.2f kohm" %(r*10**-3)
print "Resistance R2 = %0.1f ohm " %r2
from numpy import exp
#current
#given data :
v=100 #in volts
r=20 #in ohms
t=50 #in micro seconds
l=0.5 #in henry
il=(v/r)*(1-exp(-t*10**-6*(r/l))) #
print "load current = %0.f mA "%(il*10**3)
from math import log
#MINIMUM WIDTH
#given data :
v=100 #in volts
r=20 #in ohms
l=0.5 #in henry
il=50 #in mA
t1=log(1-((il*10**-3)/(v/r)))/(-(r/l)) #
print "minimum pulse width = %0.2f micro seconds " %(t1*10**6)
from math import log
#MINIMUM WIDTH
#given data :
v=207 #in volts
r=10 #in ohms
l=1 #in henry
il=100 #in mA
t1=log(1-((il*10**-3)/(v/r)))/(-(r/l)) #
print "minimum pulse width = %0.2f micro seconds" %(t1*10**6)
from sympy import symbols, solve
from numpy import round, float
#resistance and duty cycle
#given data :
vr=15 #in volts
t=20 #in micro seconds
pd=0.3 #power dissipation in watts
pgm=5 #peak power in watts
Ig=symbols('Ig')
Vg=1+10*Ig
exp = Vg*Ig-pgm # expression for equation
Ig = solve(exp, Ig) # solving equation for Ig
Ig=round(float(Ig[0]),3) # A
Vg=1+10*Ig # V
# Vr = Vg+Ig*Rg
Rg = (vr-Vg)/Ig
print "(a) print Rg =",round(Rg,3), "ohm"
d=(pd/pgm)*100 #duty cycle
print "(b) duty cycle = %0.f %%" %d
tt=(t)/(d/100) #in micro seconds
f=(1/(tt*10**-3)) #triggering frequency in kHz
print "(c) triggering frequency = %0.f kHz" %f
#resistance
#given data :
vg=15.0 #in volys
vgk=0.7 #in volts
pg=0.5 # in watts
ig=pg/vgk #in amperes
rg=(vg-vgk)/ig #in ohms
print "gate source resistance = %0.f ohm " %rg
from numpy import log
#resistance ,frequency
#given data :
li=3.7 #leakage current in mA
c1=0.1 #in micro farads
vp=16 #in volts
vv=1 #in volts
n=0.7 #
ip=0.7 #in milli amperes
iv=6 #in mA
f=1000 #in Hz
rb1=5.5 #in killo ohms
t=(1/f)*10**3 #in ms
tg=50 #in micro seconds
r2=((tg*10**-6/(c1*10**-6))) # in ohms
r1=500 #in ohms assume
vs=(r1+(rb1*10**3)+r2)*(li*10**-3) #in volts
r=((t*10**-3)/(c1*10**-6*log(1/(1-n))))*10**-3 #in killo ohms
rmin=(vs-vv)/iv #minimum resistance in killo ohms
rmax=(vs-vp)/ip #maxium resistance in killo ohms
fmin=(1/(rmax*10**3*c1*10**-6*log(1/(1-n)))) #minimum frequency in Hz
fmax=(1/(rmin*10**3*c1*10**-6*log(1/(1-n))))*10**-3 #minimum frequency in Hz
print "Voltage = %0.f V "%vs
print "charging resistance = %0.3f kohm " %r
print "minimum resistance = %0.3f kohm" %rmin
print "maximum resistance = %0.3f kohm"%rmax
print "minimum frequency = %0.1f Hz" %fmin
print "maximum frequency = %0.3f kHz" %fmax
#mimimum frequency is calculated wrong in the textbook
from __future__ import division
#resistance
#given data :
il=50 #in mA
pw=50 #pulse width in micro seconds
i=10 #in mA
v=100 #in volts
if1=50 #in mA
rmax=(v/(if1-i)) #maximum resistance in killo ohms
print "maximum resistance = %0.1f kohm"%rmax
from __future__ import division
#resistance and gate power dissipation and frequency
#given data :
g=16 #in volts/ampere
vr=15 #in volts
t=4 #in micro seconds
ig=500 #in mA
rg=(vr/(ig*10**-3))-g #resistance in ohms
print "part (a) : "
print "resistance in series with SCR gate = %0.f ohm" %rg
ig=500 #in mA
rg=(vr/(ig*10**-3))-g #resistance in ohms
pg=(ig*10**-3)**2*(g) #
print "part (b) : "
print "gate power dissipation = %0.f Watt" %pg
ogv=0.3 #in watts
d=(ogv/pg)*100 #
t1=(t)/(d/100) #in micro seconds
f1=(1/(t1*10**-3)) #frequency in kHz
print "part (c) : "
print "triggering frequency = %0.2f kHz" %f1
from sympy import symbols, solve
from numpy import round
#series resistance and power dissipation
#given data :
vr=12.0 #in volts
t=50.0 #in micro seconds
d=0.2 #duty cycle
pd=5.0 #power dissipation in watts
Ig=symbols('Ig')
p=-5+1.5*Ig+8*Ig**2 #
x=solve(p, Ig) #
rg=(vr-(1.5+8*x[1]))/(x[1]) #resistance in ohms
pg=d*pd #average power loss in watts
print "resistance Rg = %.f ohm"%rg
print "average power loss = %0.f Watt" %pg
from numpy import log
#design
#given data :
vs=20.0 #in volts
c1=0.1 #in micro farads
vv=2.5 #in volts
n=0.66 #
ip=10.0 #in micro amperes
iv=10.0 #in mA
f=1.0 #in KHz
tg=40.0 #in micro seconds
vd=0.8 #in volts
vp=(n*vs+vd) #in volts
r1=((tg*10**-6/(c1*10**-6))) # in ohms
r=((1)/(f*10**3*c1*10**-6*log(1/(1-n))))*10**-3 #in killo ohms
rmin=(vs-vv)/iv #minimum resistance in killo ohms
rmax=(vs-vp)/ip #maxium resistance in killo ohms
r2=10**4/(n*vs) #in ohms
print "Vp = %0.f Volts" %vp
print "R1 = %0.f ohm" %r1
print "R = %0.3f kohm" %r
print "minimum resistance = %0.2f kohm" %rmin
print "maximum resistance = %0.f kohm" %(rmax*10**3)
print "R2 = %0.f ohm" %round(r2)
from __future__ import division
from math import sqrt, degrees, asin
#trigger angle
#given data :
vm=120*sqrt(2) #in volts
vrb=0.7 #in volts
rb=500 #in ohms
rl=1000 #in ohms
rmin=1000 #in ohms
r=4000 #in ohms
alpha=degrees(asin((0.7*(rl+rmin+r+rb))/(rb*vm))) #in degree
print "triggering angle = %0.2f degree "%alpha
#pulse width
#given data :
v=200 #in volts
il=100 #latch current in mA
l=0.2 #inductance in henry
dit=v/l #in amp/sec
dt=(il*10**-3)/dit #in seconds
print "(a) minimum pulse width required to turn on the SCR = %0.f micro seconds" %(dt*10**6)
r=20 #in ohms
x=(il*10**-3*r)/v #
t=(log(1-x))*(-l/r) #
print "(b) minimum pulse width = %0.f micro seconds"%(round(t*10**6))
#part b answer is calculated wrong in the textbook
from __future__ import division
from numpy import log
#design
vs=30 #in volts
n=0.51 #
vd=0.7 #in volts
vp=(n*vs+vd) #in volts
c=0.1 #in micro farads(taken for design)
vv=3.5 #in volts
x=log(vv/(vp-vd)) #
t2=50 #in micro seconds
r3=-((t2*10**-6)/(x*c*10**-6)) #in ohms
f=50 #in Hz
t=(1/f)*10**3 #in ms
t1=(t-(t2*10**-6)) #inms
x1=log(1-((vp-vv)/(vs))) #
y1=(-t1*10**-3)/(c*10**-6) #
r1=y1/x1 #in ohms
r2=(10**4)/(n*vs) #in ohms
print "R1 = %0.3f ohm" %(r1*10**-3)
print "R2 = %0.1f ohm" %r2
print "R3 = %0.f ohm" %(round(r3))
print "capaictance = %0.1f micro Farad/40 V"%c
#R3 is wrong in the textbook