# Chapter 7: Switiching Power Supplies¶

### Example 7.1,Page 326¶

In [2]:
#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"

duty cycle is 0.25
average voltage is 3.0 V


### Example 7.2,Page 238¶

In [3]:
#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
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 "peak inductor current is",round(Ip*1000,3), "mA"

duty cycle is 42.0 %
time is 10.0 microsec
on time is 4.167 microsec
ripple current is 133.636 mA
peak inductor current is 566.818 mA


### Example 7.3,Page 335¶

In [4]:
#finding rms current

#initialisation of variable
from math import pi,tan,sqrt,sin,cos,acos,atan
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'

rms current is 325.01 mA
by trapezium method
rms current is 324.04 mA
by rectangle method

rectangle method gives good result than trapezium method


### Example 7.4,Page 336¶

In [5]:
#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"

voltage is 0.3 V
dissipated power is 63.0 mW


### Example 7.5,Page 341¶

In [7]:
#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 "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"

duty cycle is 42.0 %
time period is 6.667 microsec
on time is 2.778 microsec
ripple current is 125.0 mA
inductor voltage is 7.0 V
inductor is 155.556 microH
inductor current is 562.5 mA
minimum capacitor current is 250.0 mA
minimum capacitor voltage is 18.0 V
Rf/Ri is 3.07
power of LM2595 is 0.33 W
thermal resistance is 210.998 degreeC/W


### Example 7.6,Page 349¶

In [9]:
#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 "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"

load power is 15.4 W
supply power is 17.11 W
dc current is 1.4 A
inductor current is 1.57 A
duty cycle is 0.45
inductor is 154.29 microH
transistor power is 352.8 mW
diode power is 385.0 mW
capacitor is 157.5 microF


### Example 7.7,Page 355¶

In [11]:
#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"

Rf/Ri is 16.886
pick Rf=22; Ri=1.3;
rms current is 1.4 A
switch power is 132.3 mW
IC power is 151.2 mW
total power is 283.5 mW
IC temperature is 98.43 degreeC


### Example 7.8,Page 359¶

In [13]:
#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
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"

maximum voltage is 18.25 V
diode voltage is 20.0 V
duty cycle is 0.34
power delivered is 5.0 W
average current is 466.67 mA
mid primary current is 1.37 A
rms current is 800.33 mA
ramp current is 480.0 mA
maximum transistor current is 1.61 A
minimum transistor current is 1.13 A
diode peak current is 2.02 A
secondary rms current is 1.23 A
capacitor is 170.0 microF