#finding duty cycle and average voltage
#initialisation of variable
from math import pi,tan,sqrt,sin,cos,acos,atan
T=20.0;#time
Vp=12.0;#voltage
t=5.0;
#calculation
D=t/T;
Vd=(D*Vp);
#result
print "duty cycle is",round(D,3)
print "average voltage is",round(Vd,3), "V"
#finding on time ripple,load,peak inductor current
#initialisation of variable
from math import pi,tan,sqrt,sin,cos,acos,atan
Vd=12.0;#voltage
Vl=5.0;#load voltage
Rl=10.0;#load resistance
f=100.0;#frequency
L=220.0;#inductor
#calculation
D=Vl/Vd;
T=1/f;
t=D*T;
Vr=Vd-Vl;
I=Vr*round(t*10000)/10/L;
Il=Vl/Rl;
Ip=Il+I/2;
#result
print "duty cycle is",round(D*100), "%"
print "time is",round(T*1000,3), "microsec"
print "on time is",round(t*10000,2)/10, "microsec"
print "ripple current is",round(I*1000,3),"mA"
print "load current is",round(Il*1000,3), "mA"
print "peak inductor current is",round(Ip*1000,3), "mA"
#finding rms current
#initialisation of variable
from math import pi,tan,sqrt,sin,cos,acos,atan
Id=500.0;#load current
i=134;#mA
D=.42;#duty cycle
#calculation
Ip=Id+i/2;
Im=Id-i/2;
I1=((D/3)*(Ip**2+Im*Ip+Im**2))**.5;
I2=D**.5*Id;
#result
print "rms current is",round(I1,2), "mA"
print('by trapezium method')
print "rms current is",round(I2,2), "mA"
print('by rectangle method')
print '\n rectangle method gives good result than trapezium method'
#finding voltage and power
#initialisation of variable
from math import pi,tan,sqrt,sin,cos,acos,atan
Vp=.3;#voltage
I=500.0;#current
D=.42;#duty cycle
T=150.0;#temperature
R=.6;#ohm
#calculation
Vq=I*R;
Pq=D*Vq*I;
#result
print "voltage is",round(Vq/1000,2), "V"
print "dissipated power is",round(Pq/1000,2), "mW"
#finding all componenets
#initialisation of variable
from math import pi,tan,sqrt,sin,cos,acos,atan
R=10.0;#resistance
V1=5.0;#V
V2=12.0;#V
Ta=80.0;#degreeC
Tb=150.0;
f=150.0;#frequency
#calculation
D=V1/V2;
T=1/f;
t=D*T;
Id=V1/R;
i=.25*Id;
Vl=V2-V1;
L=Vl*t/i;
Ip=Id+i/2;
Ic=Id/2;
Vc=1.5*V2;
K=V1/1.23-1;
P=.01*V2+D*Id*1;
Q=(Tb-Ta)/P-2.2;
#result
print "duty cycle is",round(D*100), "%"
print "time period is",round(T*1000,3), "microsec"
print "on time is",round(t*1000,3), "microsec"
print "load current is",round(Id*1000,3), "mA"
print "ripple current is",round(i*1000,3), "mA"
print "inductor voltage is",round(Vl,2), "V"
print "inductor is",round(L*1000,3), "microH"
print "inductor current is",round(Ip*1000,2), "mA"
print "minimum capacitor current is",round(Ic*1000,2), "mA"
print "minimum capacitor voltage is",round(Vc,3), "V"
print "Rf/Ri is",round(K,2)
print "power of LM2595 is",round(P,2), "W"
print "thermal resistance is",round(Q,3), "degreeC/W"
#finding different power,inductor current,inductor value
#initialisation of variable
from math import pi,tan,sqrt,sin,cos,acos,atan
V1=12.0#V
V2=22.0;#V
I=.7;#A
f=100.0;#kHz
R=.4;#ohm
Vd=.5;
#calculation
Pl=V2*I;
Ps=Pl/.9;
Id=round(Ps/V1*10)/10;
i=.25*Id;
Ip=Id+i/2;
D=round((1-V1/V2)*100)/100;
t=D/f;
L=V1*t/i;
Vp=Id*R;
Pq=D*Vp*Id;
Pd=(1-D)*.5*Id;
C=Id*t/2/20;
#result
print "load power is",round(Pl,2), "W"
print "supply power is",round(Ps,2), "W"
print "dc current is",round(Id,2), "A"
print "inductor current is",round(Ip,2), "A"
print "duty cycle is",round(D,2)
print "inductor is",round(L*1000,2), "microH"
print "transistor power is",round(Pq*1000,2), "mW"
print "diode power is",round(Pd*100,2)*10, "mW"
print "capacitor is",round(C*1e6,2), "microF"
#finding feedback resistor,power,current and temperature
#initialisation of variable
from math import pi,tan,sqrt,sin,cos,acos,atan
V1=12.0;#V
V2=22.0;#V
I=.7;#A
Ta=80.0;#degreeC
Ps=17.1#supply power
#calculation
K=V2/1.23-1;
Id=round(Ps/V1*10)/10;
D=round((1-(V1/V2))*100)/100;
Ir=D**.5*Id;
Ps=Ir**2*.15;
Pi=D*Id*V1/50;
P=Ps+Pi;
T=Ta+P*65;
#result
print "Rf/Ri is",round(K,3)
print('pick Rf=22; Ri=1.3;')
print "rms current is",round(Id,2), "A"
print "switch power is",round(Ps*1000,2), "mW"
print "IC power is",round(Pi*1000,2), "mW"
print "total power is",round(P*1000,2), "mW"
print "IC temperature is",round(T,2), "degreeC"
#designing circuit and finding circuit parameter
#initialisation of variable
from math import pi,tan,sqrt,sin,cos,acos,atan
V1=12.0;#V
V2=5.0;#V
Il=1.0;#load current
T=10.0;#microsec
K=1.25;#Npri/Nsec
L=85.0;#microH
#calculation
Vq=V1+V2*K;
Vd=V1*K+V2;
D=round((K*V2)*100/(V1+K*V2))/100;
Po=V2*Il;
Pi=round(Po/.09)/10;
Id=Pi/V1;
Im=Id/D;
Ir=(Im*D**.5);
i=V1*D*T/L;
IM=Im+.24;
Imin=Im-.24;
Ip=K*IM;
Imid=Il/(1-D);
Irms=Imid*(1-D)**.5;
C=D*Il*T/20;
#result
print "maximum voltage is",round(Vq,2), "V"
print "diode voltage is",round(Vd,2), "V"
print "duty cycle is",round(D,2)
print "power delivered is",round(Po,2), "W"
print "average current is",round(Id*1000,2), "mA"
print "mid primary current is",round(Im,2), "A"
print "rms current is",round(Ir*1000,2),"mA"
print "ramp current is",round(i*1000,2), "mA"
print "maximum transistor current is",round(IM,2),"A"
print "minimum transistor current is",round(Imin,2),"A"
print "diode peak current is",round(Ip,2), "A"
print "secondary rms current is",round(Irms,2),"A"
print "capacitor is",round(C*1000,2), "microF"