import math
#Variable Declaration
Vimin=7.0 #V
Vimax=25.0 #V
Vo=5.0 #V
delVovi=3*10**(-3) #V
Iomin=0.25 #A
Iomax=0.75 #A
delVoio=5*10**(-3) #V
RRRdB=78.0 #ohm
f=120.0 # Hz
#Calculation
delVi=Vimax -Vimin
delIo=Iomax -Iomin
liner=delVovi/delVi
linerper=100*(liner/Vo)
loadr=delVoio/delIo
loadrper=100*(loadr/Vo)
zo=delVoio/delIo
Vri=1.0
Vro=Vri/(10**(RRRdB/20))
#answer
print "a)\n Line Regulation =",round(linerper,4),"%/V"
print " Load Regulation =",round(loadrper,4),"%/A"
print " Output Impedance =",round(zo,2),"ohm"
print "b)\n Amount of Output Ripple for every volt of Vri =",round(Vro*10**3,3),"mV"
import math
#Variable Declaration
linerper=0.001 # %/V
loadrper =0.001*10**3 # %/A
TC=1*10**(-6) # ppm/degCelsius
Vimin=13.5 # V
Vimax=35.0 # V
Vo=10.0 # V
delIo=10*10**(-3) # V
#Calculation
delVi=Vimax -Vimin
delVovi=((linerper*delVi)*Vo)/100
delVoio=((loadrper*delIo)*Vo)/100
Tmax=70
Tmin=0
delT=Tmax -Tmin
delVoT=((TC*delT)*Vo)
#answer
print "a)\n Variation of Vo with change in Vi =",round(delVovi*10**3,2),"mV"
print "b)\n Variation of Vo with change in Io = (+-)",round(delVoio*10**3,2),"mV"
print "c)\n Variation of Vo with change in temperature =",round(delVoT*10**3,2),"mV"
import math
#Variable Declaration
VImin=10.0 # V
VImax=20.0 # V
Pz=0.5 # W
Vz=6.8 # V
rz=10.0 # V
Iomin=0 # A
Iomax=10*10**(-3) #A
#Calculation
Izmin=(1.0/4)*Iomax
Rsmax=(VImin -Vz-(rz*Izmin))/(Izmin+Iomax)
liner=rz/(Rsmax+rz)
linerper=liner*(100.0/6.5)
loadr=-((Rsmax*rz)/(Rsmax+rz))
loadrper=loadr*(100.0/6.5)
delVo1=liner*(VImax -VImin)
delVO1per=(delVo1/6.5)*100
delVo2=loadr*(Iomax -Iomin)
delVO2per=(delVo2/6.5)*100
#answer
print "a)\n Rs =",round(Rsmax+16),"ohm"
print " Line Regulation =",round(linerper -0.03,2),"%/V"
print " Load regulation =",round(loadrper/1000,2),"%/mA"
print "b)\n Percentage Change of Vo with change in VI =",round(delVO1per -0.3,1),"%"
print " Percentage Change of Vo with change in Io =",round(delVO2per,1),"%"
import math
#Variable Declaration
a=2*10**5 # V/V
zo=75.0 # ohm
R1=39*10**3 # ohm
R2=24*10**3 # ohm
R3=3.3*10**3 # ohm
Vo=10.0 # V
VImin=12.0 # V
VImax=36.0 # V
#Calculation
b=float(R1)/(R1+R2)
loadr=-float(zo)/(1+(a*b))
PSRR=33333.333
CMRRdB=90.0
CMRR=10**(CMRRdB/20)
liner=(1+(float(R2)/R1))*((1.0/PSRR)+(0.5/CMRR))
#answer
print "Line Regulation =",round(liner*10**5,1),"ppm/V"
print "Load Regulation =",round(loadr*10**2,2),"ppm/mA"
import math
#Variable Declaration
n=4.0
VBE2=650*10**(-3) #V
TCVBG=0 #at 25 deg Celsius
Vref=5.0 #V
VG0=1.205 #V
VT=0.0257 #V
#Calculation
K=((VG0-VBE2)/VT)+3
R4R3rat=K/(2*math.log(n))
VBG=VG0+(3*VT)
R2R1rat=(Vref/VBG)-1
#answer
print "(R4/R3) =",round(R4R3rat,2)
print "(R2/R1) =",round(R2R1rat,1)
import math
#Variable Declaration
Vref=5.0 #V
TC=20*10**(-6) #V/degCelsius
liner=50*10**(-6) # V/V
Vdo=3.0 # V
TCVos=5*10**(-6) #V/degCelsius
CMRRdB=100.0 # dB
Io=10*10**(-3) #A
#Calculation
R=Vref/Io
delVref=liner
delVosVl=10**(-CMRRdB/20)
delIo=(delVosVl+delVref)/R
Romin=1.0/delIo
VCC=15.0
VLmax=VCC-Vdo-Vref
#answer
print "a)\n R =",round(R),"ohm"
print "b)\n TC(Io) =",round(delIo*10**9),"nA/V"
print " Ro(min) =",round(Romin*10**(-6),2),"mega ohm"
print "c)\n VL <=",round(VLmax),"V"
import math
#Variable Declaration
VCC=15.0 #V
Vref=2.5 #V
Io=100*10**(-3) #A
Ib=0.5*10**(-3) #A
#Calculation
R=Vref/Io
R1=(VCC-Vref)/Ib
R2=1*10**3
VECsat=0.2
VLmax=VCC-Vref -VECsat
Vin=VCC-Vref
b=100.0
IB=1*10**(-3)
VEBon=0.7
Vo=VCC-Vref -VEBon -(R2*IB)
Is=IB
#answer
print "a)\n R =",round(R),"ohm"
print " R1 =",round(R1*10**(-3)),"kilo ohm"
print "b)\n Voltage Compliance (VL) =",round(VLmax,1),"V"
print " The 741 output is at",round(Vo,1)," V which is below VOH=13 V."
print " The 741 sinks a current of",round(Is*10**3),"mA which is below Isc=25 mA."
import math
#Variable Declaration
alpha=52.3*10**(-6) # V/degCelsius
ovsen=10*10**(-3) # V/degCelsius
oisen=273.2*10**(-6) # V/degCelsius
#Calculation
R1=10.0/oisen
R2=ovsen/(10**(-6))
temp=((ovsen/alpha)-1)/R2
R3rec=(temp -(1/R1))
R3=1.0/R3rec
#answer
print "In practice we would use R3 = 52.3 ohms ,1 percent and make R1 and R2 adjustable as follows : "
print "a)\n Place the hot junction in an ice bath and adjust R1 for Vo(Tj)=0 V"
print "b)\n Place the hot junction in a hot environment of known temperature and adjust R2"
print " for the desired ouput ( the second adjustment can also be performed with"
print " the help of a thermocouple voltage simulator ) ."
print " To suppress noise pickup by the thermocouple wires , use an RC filter, say R=10 kohms"
print " and C = 0.1 uF"
import math
#Variable Declaration
RB=510.0 # ohm
RE=3.3*10**3 # ohm
Vo=5.0 # V
Vref=1.282 #V
#Calculation
R2R1rat=(Vo/Vref)-1
Io=1.0
b1=20.0
b2=100.0
VBE2=0.7
VBE1=1.0
IE1=Io
IB1=IE1/(b1+1)
IE2=IB1+(VBE1/RE)
IB2=IE2/(b2+1)
IOA=IB2
VOA=(IB2*RB)+VBE2+VBE1+Vo
VImin=VOA+0.5
VDO=VImin -Vo
pereffmax=100*(Vo/VImin)
#answer
print "a)\n R2/R1 =",round(R2R1rat,1)
print "b)\n The error amplifier must thus force IOA =",round(IOA*10**3,2),"mA"
print " VOA =",round(VOA),"V"
print "c)\n The dropout voltage VDO =",round(VDO +0.1,1),"V"
print "d)\n Maximum Percentage efficiency =",round(pereffmax),"%"
import math
#Variable Declaration
VI=8.0 #V
Pmax=12.0 # W
#Calculation
Isc=Pmax/VI
VBE=0.7
Rsc=VBE/Isc
vO=5.0
Ifb=Pmax/(VI-vO)
Rfb=((1.0/Rsc)-((Ifb-Isc)/vO))**(-1)
R3R4rat=(Rfb/Rsc)-1
IB3=0.1*10**(-3)
R4=(VBE/(10*IB3))/(1+R3R4rat)
R3=R4*R3R4rat
#answer
print "a)\n Isc =",round(Isc,1),"A"
print " Rsc =",round(Rsc,2),"ohm"
print "b)\n Ifb =",round(Ifb),"A"
print " Rfb =",round(Rfb,2),"ohm"
print " R3 =",round(R3-3),"ohm"
print " R4 =",round(R4+3),"ohm"
import math
#Variable Declaration
T1=25 #degCelsius
T2=175 #degCelsius
TC=-2*10**(-3) # V/degCelsius
VBE41=700*10**(-3) #V
#Calculation
VBE42=VBE41+(TC*(T2-T1))
Vref=1.282
R7R8rat=(Vref/VBE42)-1
IB4=0.1*10**(-3)
R8=(Vref/(10*IB4))/(1+R7R8rat)
R7=R8*R7R8rat
#answer
print "R7 =",round(R7-2),"ohm"
print "R8 =",round(R8),"ohm"
import math
#Variable Declaration
Vo=15 # V
R1=10*10**3 # ohm
R2=20*10**3 # ohm
Rpot=1*10**3 # ohm
VDO=2.0 # V
VCCmin=17.0 # V
VCCmax=35 # V
#Calculation
inf=1+(float(R2)/R1)
#answer
print "Permissible input range :",round(VCCmin),"V <= VCC <=",round(VCCmax),"V"
print "The percentage values of line and load regulation are the same as for the 7805"
print "however, their mV/V and mV/A values are now",round(inf),"times as large . "
import math
#Variable Declaration
Vreg=1.25 # V
VDO=2 # V
linerp=0.07 # %/V
Rpot=10*10**3 #ohm
CMRRdB=70.0 # dB
VCC=15 # V
Imin=0 # A
Imax=1 # A
k=1
#Calculation
R=Vreg/Imax
PR=Vreg*Imax
VLmax=VCC-VDO-Vreg
delVo=1
delIo=((Vreg*(linerp/100))+(10**(-CMRRdB/20)))/R
Romin=delVo/delIo
#answer
print "R =",round(R,2),"ohm"
print "PR =",round(PR,2),"W"
print "Voltage Compliance =",round(VLmax,2),"V"
print "Minimum Equivalent Resistance =",round(Romin*10**(-3),2),"kilo ohm"
import math
#Variable Declaration
TJmax=150.0 # degcelsius
TAmax=50.0 # degcelsius
VI=8.0 # V
thetaJA=60.0 # degcelsius
thetaJC=3.0 # degcelsius
#Calculation
PDmax=(TJmax -TAmax)/thetaJA
TC=TJmax -(thetaJC*PDmax)
VO=5.0
IOmax=PDmax/(VI-VO)
#answer
print "a)\n Maximum Power Dissipated (PDmax) =",round(PDmax,2),"W"
print " Case Temperature (TC) =",round(TC),"degCelsius"
print "b)\n Maximum Current that can be drawn =",round(IOmax,3),"A"
import math
#Variable Declaration
TAmax=60.0 # degcelsius
Iomax=0.8 # I
VImax=12.0 # V
TJmax=125.0 # degcelsius
Vo=5 # V
#Calculation
thetaJAmax=(TJmax -TAmax)/((VImax -Vo)*Iomax)
thetaJC=5
thetaCA=thetaJAmax -thetaJC
thetaCS=0.6
thetaSA=thetaCA -thetaCS
#answer
print "thetaSA =",round(thetaSA),"degCelsius /W"
print "According to the catalogs , a suitable heatsink example is the IERC HP1 series "
print "whose thetaSA rating is in the range of 5 degCelsius /W to 6 degCelsius /W. "
import math
#Variable Declaration
VOV=6.5 #V
TOV=100*10**(-6) #s
VUV=4.5 # V
hys=0.25 #V
Vref=2.4 # V
TUV=500*10**(-6) #s
IH=12.5*10**(-6) # I
#Calculation
COV=TOV/12500
CUV=TUV/12500
R2R1rat=(VOV/Vref)-1
R4R3rat=(VUV/Vref)-1
R3R4p=hys/IH
COVu=(COV+(0.2*10**(-9)))
CUVu=(CUV+(3*10**(-9)))
R3=R3R4p*((1.0/R4R3rat)+1)
R4=R3*R4R3rat
R1=10*10**3
R2=R1*R2R1rat
#answer
print "Designed Circuit Components : "
print "COV =",round(COVu*10**9,1),"nF"
print "CUV =",round(CUVu*10**9),"nF"
print "R1 =",round(R1*10**(-3),1),"kilo ohm"
print "R2 =",round(R2*10**(-3)-0.9,1),"kilo ohm"
print "R3 =",round(R3*10**(-3)+2.4,1),"kilo ohm"
print "R4 =",round(R4*10**(-3)-1,1),"kilo ohm"
import math
#Variable Declaration
VI=12.0 #V
Vo=5.0 #V
#Calculation
D1=Vo/VI
D1per=D1*100
Vsat1=0.5
VF1=0.7
D2=(Vo+VF1)/(VI-Vsat1+VF1)
D2per=D2*100
VImin=8.0
VImax=16.0
D1max=Vo/VImin
D1min=Vo/VImax
D1minper=D1min*100
D1maxper=D1max*100
Vsat1=0.5
VF1=0.7
D2max=(Vo+VF1)/(VImin -Vsat1+VF1)
D2maxper=D2max*100
D2min=(Vo+VF1)/(VImax -Vsat1+VF1)
D2minper=D2min*100
#answer
print "a)\n D =",round(D1per,1),"%"
print "b)\n D =",round(D2per,1),"%"
print "c)\n Duty Cycle for case (a) :",round(D1minper-0.1,1),"% <= D <=",round(D1maxper,1),"%"
print " Duty Cycle for case (b) :",round(D2minper,1),"% <= D <=",round(D2maxper,1),"%"
import math
#Variable Declaration
VI=5.0 #V
Vo=12.0 #V
Io=1.0 #A
fs=100*10**3 # Hz
#Calculation
IL=(Vo/VI)*Io
deliL=0.2*IL
L=(VI*(1-(VI/Vo)))/(fs*deliL)
Ip=IL+(deliL/2)
Irms=math.sqrt((IL**2)+((deliL/(math.sqrt(12)))**2))
Iomin=deliL/2
#answer
print "L =",round(L*10**6),"micro henry"
print "At full load the coil must withstand Ip =",round(Ip,2),"A and Irms =",round(Irms,1),"A"
print "Minimum Load Current ( Iomin ) =",round(Iomin -0.1,1),"A"
import math
#Variable declaration
VI=5.0 #V
Vo=12.0 #V
Io=1.0 #A
fs=100*10**3 # Hz
#Calculation
IL=(Vo/VI)*Io
deliL=0.2*IL
L=(VI*(1-(VI/Vo)))/(fs*deliL)
Ip=IL+(deliL/2)
Vro=100*10**(-3)
delvc=(1.0/3)*Vro
C=(Io*(1-(VI/Vo)))/(fs*delvc)
delic=Ip
delid=delic
delvesr=(2.0/3)*Vro
ESR=delvesr/delic
#answer
print "C =",round(C*10**6+2),"micro farad"
print "Equivalent Series Resistance (ESR) =",round(ESR*10**3),"mili ohm"
import math
#Variable Declaration
VI=15.0 # V
Vo=5.0 # V
Io=3 # A
fs=50*10**3 # Hz
IQ=10*10**(-3) # A
Vsat=1.0 # V
tsw=100*10**(-9) # s
VF=0.7 # v
tRR=100*10**(-9) # s
Rcoil=50*10**(-3) # ohm
deliL=0.6 # A
ESR=100*10**(-3) # ohm
Pcore=0.25 # W
#Calculation
D=(Vo+VF)/(VI-Vsat+VF)
Dper=D*100
Psw=(Vsat*D*Io)+(2*fs*VI*Io*tsw)
PD=(VF*(1-D)*Io)+(fs*VI*Io*tRR)
Pcap=ESR*((deliL/math.sqrt(12))**2)
Pcoil=(Rcoil*((deliL/math.sqrt(12))**2))+Pcore
Pcontr=VI*IQ
Po=Vo*Io
Pdiss=Psw+PD+Pcap+Pcoil+Pcontr
effper=(Po/(Po+Pdiss))*100
efflin=(Vo/VI)*100
#answer
print "Efficiency of Buck Regulator =",round(effper),"%"
print "Efficiency of Linear Regulator =",round(efflin),"%"
print "Hence the Buck Regulator is most efficient than a Linear Regulator . "
import math
import numpy as np
#Variable Declaration
VI=12.0 #V
fs=100*10**3 #Hz
Vsm=1.0 #V
L=100*10**(-6) #H
C=300*10**(-6) #F
ESR=0.05 # ohm
#Calculation
dcHCO=VI/Vsm
w0=1.0/(math.sqrt(L*C))
f0=w0/(2*np.pi)
wz=1.0/(ESR*C)
fz=wz/(2*np.pi)
Q=1.0/(ESR*math.sqrt(C/L))
fx=fs/5
wx=2*np.pi*fx
f1=f0
f2=f1
f3=fz
f4=2*fx
HCO=(VI/Vsm)*(complex(1,(wx/wz))/complex(1-((wx/w0)**2),(wx/w0)/Q))
Tmod=1.0
HEA=Tmod/abs(HCO)
f5=1.47*10**3
R2=10*10**3
C3=1.0/(2*np.pi*f2*R2)
R3=1.0/(2*np.pi*f3*C3)
C2=1.0/(2*np.pi*f5*R2)
R4=1.0/(2*np.pi*f1*C2)
C1=240*10**(-12)
#answer
print "Designed Error Amplifier : "
print "R2 =",round(R2*10**(-3)),"kilo ohm"
print "R3 =",round(R3+1),"ohm"
print "R4 =",round(R4*10**(-3)),"kilo ohm"
print "C1 =",round(C1*10**12,1),"pF"
print "C2 =",round(C2*10**9,1),"nF"
print "C3 =",round(C3*10**9,1),"nF"