# Ripple Factor
import math
#Variable declaration
Rl=2000.0
f=50.0
l=20.0
V1=0.074
#Calculations and Result
#(1)
w=2*math.pi*f
V=Rl/(3*2*math.sqrt(w*2))
print("1.One Inductor Filter,\nV = %.3f\n"%V1)
#(2)
Idc=1
c=16*10**-6
gam=Idc/(4*math.sqrt(3)*f*c*Rl)
print("\n2.Capacitor filter, \nGamma = %.2f\n"%gam)
#(3)
gam2=(math.sqrt(2)/3)*(1.0/4*l*c*(w**2))
print("\n3. L Type filter,\nGamma = %.4f"%(gam2/1000))
# diode as a rectifier
import math
#Variable declaration
vm=110.0 # rms
x=1020.0 # Rf+Rl
rl=1000.0
#Calculations and Results
#(a)
Im=vm*math.sqrt(2)/x
print("(a)\nIm = %.1f mA"%(Im*1000))
#(b)
Idc=Im*1000/math.pi
print("\n(b)\nIdc = %.1f mA"%Idc)
#(c)
Ir=Im*1000/2
print("\n(c)\nIrms = %.1f mA"%Ir)
#(d)
v=-(Im*rl/math.pi)
print("\n(d)\n Vdc = %.1f V"%v)
#(e)
p=Ir*x/1000
print("\n(e)\nPi = %.2f W"%p)
#(f)
rl=1.0
lr=((vm*math.sqrt(2)/math.pi)-(Idc*rl))/(Idc*rl)
print("\n(f)\n%% regulation = %.2f %%"%(lr*100))
# diode as a rectifier
import math
#Variable declaration
Rl=5010.0 # ohm
idc=0.001
#Calculations
Vrms=idc*math.pi*Rl/(2*math.sqrt(2))
#Result
print("Vrms = %.2f V"%Vrms)
# FWR with LC filter
import math
#Variable declaration
rf=0.02
f=60.0
vdc=9.0
idc=0.1
#Calculations
w=2*math.pi*f
lc=math.sqrt(2)/(rf*12*w**2)
Rl=vdc/idc
lc1=Rl/900
vdc=vdc+5
vm=vdc*math.pi/2
vrms=vm/math.sqrt(2)
#Result
print("\nLC=%.1f micro"%(lc*10**6))
print("\nRL = %d Ohm\n\nLC> Rl/3w > Rl/1130\nBut LC should be 25%% larger"%Rl)
print("therefore, for f= 60 Hz,the value of LC should be > Rl/900")
print("\nIf L=0.1H, then C=%.1f micro F, This is high value."%(math.ceil(lc*10**6/lc1)))
print("\nIf L=1H, then C=41.5 micro F.")
print("\n\nTransformer Rating:")
print("Vdc=%.0fV\nVm=%.0fV\nVrms=%.1fV"%(vdc,math.ceil(vm),vrms))
print("Therefore, a 15.5 - 0 -15.5 V, 1OOmA transformer is required\nPIV=%d V"%(2*math.ceil(vm)))
# Ripple Factor
import math
#Variable declaration
vrpp=0.8 # V
r=100.0
f=60.0
c=1050.0*10**-6
#Calculations
vrms=vrpp/(2*math.sqrt(3))
vrms=math.floor(vrms*10)
vrms=vrms/10.0
vm=8.8
vdc=vm-vrpp/2
gam=vrms/vdc
tgam=1/(4*(math.sqrt(3*c*r*f)))
Vdc=(4*f*r*c*vm)/(1+4*f*r*c)
#Result
print("%% regulation, gamma = %.2f%%"%(gam*100))
print("\nTheoretical values, gamma = %.2f%%"%(tgam*100))
print("\nVdc = %.2f V"%(Vdc))
# power supply using pi filter
import math
#Variable declaration
Vdc=25.0
Idc=0.1
#Calculations
R=Vdc/Idc
Vc=Vdc+37.5
vm=Vc+(Idc/(4.0*50))
vrms=vm/math.sqrt(2)
vrms=60.0 # approximated to
print("\nVrms=%.0f V\n\nTherefore, a transformer with 60 - 0 - 60V is chosen."%vrms)
print("The ratings of the diode should be,\ncurrent of 125mA and voltage = PIV = 2Vm = %.1f"%(169.2))
# Diode rating for FWR
import math
#Variable declaration
Vdc=250.0 # V
Idc=0.1
rc=400.0
L=10.0 #Ohm
c=20*10**-6
w=377.0
#Calculations
rl=Vdc/Idc
Vm=(Vdc*math.pi/2)*(1+(rc/rl))
Vrms=Vm/math.sqrt(2)
Ib=2*Vm/(3*math.pi*w*L)
rf=0.47/(4*w**2*c)
#Result
print("Vrms=%d V\n"%Vrms)
print("\nTherefore, the transformer should supply %d V rms on each side of the centre tap."%Vrms)
print("\nIb = %.4f A\nRipple factor = %.4f"%(Ib,rf))
# FWR with C type capacitor filter
import math
#Variable declaration
Idc=0.02 # A
Vdc=16.0 # V
f=50.0
#Calculations
rl=Vdc/Idc
x=4*math.sqrt(3)*f*0.05*rl
C=1/x
vm=Vdc*((1+(4*f*C*rl)))/(4*f*C*rl)
print("C=%d microF"%(C*10**6))
print("Vm=%.2f V"%vm)
# Half Wave Rectifier
import math
#Calculations
Vdc=(100/(2*math.pi))*(-math.cos(5*math.pi/6)+math.cos(math.pi/6))
Vrms=math.sqrt(3.1)*Vdc
#Result
print("Vdc=%.1f V"%Vdc)
print("Vrms=%.1fV"%Vrms)
# FWR with C type capacitor filter
import math
#Variable declaration
vdc=30.0 # V
idc=0.05 # A
f=50.0 # Hz
c=80*10**-6 # F
#Calculations
#(a)
rl=vdc/idc
vm=vdc+(idc/(4*f*c))
#(b)
s=vm*2*math.pi*f*c
#(c)
gam=4*math.sqrt(3)*f*c*rl
gam=1/gam
#Result
print("(a)\nRL=%.0f Ohm\nVm=%.3fV\nVrms=%.1fV"%(rl,vm,vm/math.sqrt(2)))
print("\n(b)\nI_diode swing/I_diode mean = %.2f"%(s/idc))
print("\n(c)\ngamma=%.2f"%gam)
# Full wave rectifier circuit
import math
#Variable declaration
vm=25.0
vp=35.4 # V
rl=25
#Calculations
vdc=2*vp/math.pi # V
vrms=math.sqrt((vm**2)-vdc**2)
im= vp/rl
idc=2*im/math.pi
irms=math.sqrt(1-idc**2)
#Result
print("Vdc=%.1f V\nVrms=%.2f V\nIm=%.2f A\nIdc=%.2f A\nIrms=%.3f A"%(vdc,vrms,im,idc,irms))
# Shunt regulator
import math
#Variable declaration
veb=0.2 # V
hfe=49.0
vz=6.3 # V
i=5*10**-3
vi=8.0
#(1)
y=veb+vz
print("1. The nominal output voltage is the sum of the transistor V_EB and zener voltage.\nV0=%.1f V\n"%y)
#(2)
r1=(vi-vz)/i
print("\n2. R1 must supply 5mA to the zener diode\nR1 = %.0f Ohm"%r1)
#(3)
k=veb/vz
print("\n\n3. The maximum allowable zener current is\nIz = %.3f A"%k)
ibmax=k-i
it=ibmax*(1+hfe)
print("\nTotal current range = %.2f A"%it)
#(4)
pd=y*it
print("\n(4)\nThe maximum power dissipation,\nPd = %.1f W"%pd)
#(5)
rs=(vi-y)/it
pdr=it**2*rs
print("\n(5)\nRs=%.2f Ohm\nPower dissipated by Rs is P = %dW"%(rs,pdr))