# op-amp series voltage regulator design
import math
#Variable declaration
Vin_min = 18-3 # min input voltage specification
Vin_max = 18+3 # max input voltage specification
Vout = 9 # output voltage specification
Iout_min = 10*10**-3 # min output current specification
Iout_max = 50*10**-3 # max output current specification
Vz = 5.6 # zener breakdown voltage
Pzmax = 0.5 # Maximum power dissipation in zener
#Calculations
R1 = 10*10**3 # assumed
R2 = R1/((Vout/Vz)-1)
R3 = (Vin_min-Vz)/Iout_max
Iz = (Vin_max-Vz)/R3
Pd = Iz*Vz
beta = 30 # assumed
Ib = Iout_max/(beta+1)
#Result
print("Element values for designed circuit are as follows:\nR1 = %d k-ohm\nR2 = %.2f k-ohm"%(R1/1000,R2/1000))
print("R3 = %.3f k-ohm\nIB = %.2f mA"%(R3/1000,Ib*1000))
#Answer for R3 is wrong in the book
# Regulator using IC 723
import math
#Variable declaration
Vout = 5 # Required output voltage
Iout = 100*10**-3 # Required output current
Vin_min = 15-(0.2*15) # Min input voltage
Vin_max = 15+(0.2*15) # Max input voltage
Isc = 150*10**-3 # Short circuit current requirement
Vsense = 0.7 # short circuit voltage
Vref = 7.15 # reference votage for IC 723
Id = 1*10**-3 # potential divider current
#Calculation
Rsc = Vsense/Isc
R1 = (Vref-Vout)/Id
R1std = 2.2*10**3
R2 = R1std/((Vref/Vout)-1)
R2std = 5.1*10**3
R3 = R1std*R2std/(R1std+R2std)
R3std = 1.5*10**3
#Result
print("R1 = %.3f k-ohm\t We use %.1f k-ohm as standard resistor."%(R1/1000,R1std/1000))
print("R2 = %.3f k-ohm\t We use %.1f k-ohm as standard resistor."%(R2/1000,R2std/1000))
print("R3 = %.3f k-ohm\t We use %.1f k-ohm as standard resistor."%(math.floor((R3/1000)*1000)/1000,R3std/1000))
# Ic 723 based positive voltage regulator
import math
#Variable declaration
Vout = 12.0 # output voltage
Il = 500*10**-3 # load current
Isc = 600*10**-3 # short circuit current
Vref = 7.0 # IC 723 reference voltage
Vsense = 0.6 # voltage at short circuit
#Calculation
R1 = 4.7*10**3 # assumed
R2 = Vref*R1/(Vout-Vref)
R2std = 6.8*10**3
Rsc = Vsense/Isc
R3 = R2std*R1/(R2std+R1)
Psc = Isc**2*Rsc*1000
I = Vout/(R1+R2std)
I= math.floor(I*10**6)/10**6
P1 = I**2*R1*1000
P2 = I**2*R2std*1000
#Result
print("R1 = %.1f k-ohm\nR2 = %.2f k-ohm = %.1f k-ohm(standard value)\nRsc = %.1f ohm"%(R1/1000,R2/1000,R2std/1000,Rsc))
print("\nPower wattage:\nPsc = %.0f mW\nP1 = %.3f mW\nP2 = %.3f mW"%(Psc,math.floor(P1*1000)/1000,P2))
print("Hence, both R1 and R2 may be selected safely of 1/16th watt power rating.")
# Regulator design using IC 723(refer to fig. 11.26)
import math
#Variable declaration
Vout = 6 # output voltage
Il = 1 # load current
Isc = 0.250 # short circuit
Vref = 7 # reference voltage
Vbe = 0.7 # base-emitter junction voltage
#Calculations
R1 = 2.7*10**3 # assumed
R2 = Vout*R1/(Vref-Vout)
kRsc = Vbe/Isc
k =1-(((Il-Isc)*kRsc)/Vout)
R4 = 10*10**3 # assumed
R3 = (1-k)*R4
Rsc = kRsc/k
R = (R1*R2)/(R1+R2)
#Result
print("R1 = %.1f k-ohm\nR2 = %.1f k-ohm\nR3 = %.1f k-ohm\nR4 = %.1f k-ohm\nR = %.2f k-ohm"%(R1/1000,R2/1000,R3/1000,R4/1000,R/1000))
# Current source design using IC7812
import math
#Variable declaration
RL = 25.0 # load resistance
P = 10.0 # power
I = 0.5 # current required
V = 12.0 # rated voltage
#Calculations
R = V/I
Vout = V+(I*RL)
Vin = Vout+2
#Result
print("R = %d ohm\nVout = %.1f V\nVin = %.1f V"%(R,Vout,Vin))
# min and max voltage of regulator(refer fig.11.34)
import math
#variable declaration
Iq = 10*10**-3 # quiescent current
Vreg = 15.0 # regulated output voltage
R2 = 0 # min value of potentiometer
R1 = 40.0 # R1 resistor
#Calculations
Vout = (1+(R2/R1))*Vreg+(Iq*R2)
#Result
print("Vout = %d V"%Vout)
# current source using 7805
import math
#Variable declaration
Il = 0.2 # required load current
RL = 22.0 # load resistance
P = 10.0 # required power
Iq = 4.2*10**-3 # quiescent current
Vr = 5 # regulated output voltage
#Calculation
R = Vr/(Il-Iq)
Vout = Vr+Il*RL
Vin = Vout+2
#Result
print("R = %f ohm\nVout = %.1f V\nVin = %.1f V"%(R,Vout,Vin))
# Answer for R is wrong in the book
# Regulated outpuut voltage(refer fig. 11.38)
import math
#Variable declaration
R1 = 220.0 # resistance R1
R2 = 1500.0 # Resistance R2
Iadj = 100*10**-6 # adj. current
#Calculartions
Vout = (1.25*(1+(R2/R1)))+(Iadj*R2)
#Result
print("Vout = %.2f V"%Vout)
# Output voltage range
import math
#Variable declaration
R1 = 820.0 # resistance R1
R2min = 0 # min potentiometer resistance
R2max = 10*10**3 # max potentiometer resistance
Iadj = 100*10**-6 # adj. current
#calculations
Vmin = 1.25*(1+(R2min/R1))+(Iadj*R2min)
Vmax = 1.25*(1+(R2max/R1))+(Iadj*R2max)
#Result
print("The output can be varied in the range %.2f V to %.2f V"%(Vmin,Vmax))
# Maximum load current
import math
#Variable declaration
Vbe = 1.0 # base emitter junction voltage
beta = 15.0 # current gain
R1 = 7.0 # resistance R1
Iout = 1.0 # max output current from IC
#Calculations
Il = ((1+beta)*Iout) - beta*(Vbe/R1)
Il = math.floor(Il*100)/100
#Result
print("IC which can supply maximum 1A can supply maximum load of %.2f A, with the help of the current boosting arrangements"%Il)