# Voltage regulation and % change in output voltage per unit of load current
import math
#Variable declaration
Vfl = 24 # full load voltage
Vnl = 24.5 # no load voltage
Ifl = 2 # full load current
#calculations
#(a)
VR = (Vnl-Vfl)/Vfl
#(b)
x = VR*100/Ifl
#Result
print("(a) Voltage regulation = %.4f or %.2f%%\n(b) %%tage change in output voltage per unit load current = %.2f%%"%(VR,VR*100,x))
# Redulation in percent V
import math
Vout = 0.3 # change in output voltage when input change
Vin = 4 # input voltage change
V = 15 # rated ouutput voltage
#calculations
lr = (Vout/V)*100/Vin
print("%% line regulation = %.1f%% V"%lr)
# output voltage, load current, zener curretn
import math
#variable declaration
Vi = 15.0 # input voltage
beta_dc = 50.0 # transistor gain
Rl = 1000.0 # load resistor
Vz = 6.0 # zener voltage
Ri = 500.0 # input voltage
Vbe = 0.7 # voltage drop across transistor base-emitter
#Calculations
Vo = Vz-Vbe
Il = Vo/Rl
Vce = Vi-Vo
I = (V-Vz)/Ri
Ib = Il/beta_dc
Iz = I-Ib
#Result
print("Vo = %.1fV\nLoad current = %.1f mA\nZener current = %.3f mA"%(Vo,Il*1000,Iz*1000))
#output voltage(referring fig.10.2)
import math
Vz = 6.0 # zener voltage
R1 = 10.0*10**3 # resistance 1
R2 = 15.0*10**3 # resistance 2
#Calculations
Vo = (1+(R2/R1))*Vz
#Result
print("Vo = %d V"%Vo)
# finding Vo, Io, Ic (referring fig.10.1)
import math
#variable declaration
Vz = 9.0 # zener voltage
R1 = 1.5*10**3 # resistance 1
R2 = 3.0*10**3 # resistance 2, value used in calculations
Rl = 2.0*10**3 # load resistance
Rs = 200 # source resistance
Vin = 30 # input oltage
#Calculations
Vo = (1+(R2/R1))*Vz
Is =(Vin - Vo)/Rs
Io = Vo/Rl
Ic = Is -Io
#Result
print("Vo = %d V\nIo = %.1f mA\nIc = %.1f mA"%(Vo,Io*1000,Ic*1000))
# Minimum and maximum output voltage
import math
# variable declaration
Iadj = 40*10**-6 # current
Vref = 1.25 # reference voltage
R1 = 2*10**3 # resistance R1
R2min = 0 # minimum value of R2 resistor
R2max = 20.0*10**3 # maximum value of R2 resistor
#calculations
Vo1 = (Vref*(1+(R2max/R1)))+Iadj*R2max
Vo2 = Vref*(1+(R2min/R1))
#Result
print("When R2 = %d k-ohm\nVo = %.2f V"%(R2max/1000,Vo1))
print("\nWhen R2 = %d k-ohm\nVo = %.2f V"%(R2min/1000,Vo2))