#Example 9.1
#The FLT-U2 is to be used as a second order inverting Butterworth low pass filter
#with a dc gain of 5,cutoff frequency of 2 kHz and Q=10. Determine the values
#of the external components.
from __future__ import division #to perform decimal division
import math
#Variable declaration
dc_gain=5
f1=2*10**3 # Cutoff freq in Hz
Q=10 # Figure of merit
#calculation
R2=(316*10**3)/10 #Resistance R2
R3=(100*10**3)/((3.16*Q)-1)
R4=(5.03*10**7)/f1
R5=R4
R6=1.8*10**3 # Assumption
R7=dc_gain*R6
R8=(R6*R7)/(R6+R7)
#result
print "Resistance R2 is",round(R2/10**3,2),"kilo ohm"
print "Resistance R3 is",round(R3/10**3,2),"kilo ohm"
print "Resistance R1 is Open"
print "Resistance R4 is",round(R4/10**3,2),"kilo ohm"
print "Resistance R5 is",round(R5/10**3,2),"kilo ohm"
print "Resistance R6 is",round(R6/10**3,2),"kilo ohm"
print "Resistance R7 is",round(R7/10**3,2),"kilo ohm"
print "Resistance R8 is",round(R8/10**3,2),"kilo ohm"
#Example 9.2
#Using the FLT-U2, design a second order inverting Butterworth bandpass filter
#with centre frequency f1=5 kHz and Q=10.
from __future__ import division #to perform decimal division
import math
#Variable declaration
f1=5*10**3 # Center freq in Hz
Q=10 # Figure of merit
R2=100*10**3 # Constant for band-pass filter
#calculation
R3=(100*10**3)/((3.48*Q)-1)
R4=(5.03*10**7)/f1
R5=R4
#result
print "Resistance R2 is",round(R2/10**3,2),"kilo ohm"
print "Resistance R3 is",round(R3/10**3,2),"kilo ohm"
print "Resistance R1 is Open","ohm"
print "Resistance R4 is",round(R4/10**3),"kilo ohm"
print "Resistance R5 is",round(R5/10**3),"kilo ohm"
#Example 9.3
#Using the FLT-U2, design a notch filter with 5 kHz notch out frequency and
#Q=10.
from __future__ import division #to perform decimal division
import math
#Variable declaration
f1=5*10**3 # Center freq in Hz
Q=10 # Figure of merit
R2=100*10**3 # Constant for band-pass filter
#calculation
R3=(100*10**3)/((3.48*Q)-1)
R4=(5.03*10**7)/f1
R5=R4
R6=10*10**3 #Assumption
R7=R6
R8=R6
R9=(R6*R7*R8)/(R6*R7+R6*R8+R7*R8) #Since R6||R7||R8
#result
print "Resistance R2 is",round(R2/10**3,2),"kilo ohm"
print "Resistance R3 is",round(R3/10**3,2),"kilo ohm"
print "Resistance R1 is Open","ohm"
print "Resistance R4 is",round(R4/10**3,2),"kilo ohm"
print "Resistance R5 is",round(R5/10**3,2),"kilo ohm"
print "Resistance R6 is",round(R6/10**3),"kilo ohm"
print "Resistance R7 is",round(R7/10**3),"kilo ohm"
print "Resistance R8 is",round(R8/10**3),"kilo ohm"
print "Resistance R9 is",round(R9/10**3,2),"kilo ohm"
#Example 9.4
#Using the MF5,design a second order Butterworth lowpass filter with a cutoff
#frequency of 500Hz and a passband gain of -2. Assume that a 5,-5 V power supply
#and a CMOS clock are used.
from __future__ import division #to perform decimal division
import math
#Variable declaration
f1=500 #Cut-off freq in Hz
Holp=-2 #Passband gain
R1=10*10**3 #Assumption
Q=0.707 #Figure of merit Q is fixed for second order butterworth LPF
#calculation
R2=-R1*Holp #Using Holp=-R2/R1;
R3=Q*R2 #Using Q=R3/R2
#result
print "Resistance R2 is",round(R2/10**3),"kilo ohm"
print "Resistance R3 is",round(R3/10**3,2),"kilo ohm"
#Example 9.5
#In the circuit of figure 9-16(a), Ra=10 Kilo ohm, the output pulse width
#tp=10 ms. Determine the value of C.
from __future__ import division #to perform decimal division
import math
#Variable declaration
Ra=10*10**3 #Resistance in ohm
tp=10*10**-3 #Output pulse width
C=tp/(1.1*Ra)
#calculation
C=tp/(1.1*Ra)
#result
print "Capacitance C is",round(C*10**6),"micro Farad"
#Example 9.6
#The circuit of figure 9-16 (a) is to be used as a divide-by-2 network.
#The frequency of the input trigger signal is 2 kHz.If the value of C=0.01 uF
#What should be the value of Ra.
from __future__ import division #to perform decimal division
import math
#Variable declaration
f=2*10**3 #Freq of input trigger signal in Hz
C=0.01*10**-6
#calculation
tp=1.2/f
Ra=tp/(1.1*C)
#result
print "Resistance Ra is",round(Ra/10**3,2),"kilo ohm"
#Example 9.7
#In the astable multivibrator of figure 9-21(a), Ra=2.2 kilo ohm, Rb=3.9 kilo ohm
#and C=0.1 uF. Determine the pulse width tc, negative pulse width td and free
#running frequency fo.
from __future__ import division #to perform decimal division
import math
#Variable declaration
Ra=2.2*10**3 # Resistance in ohm
Rb=3.9*10**3 # Resistance in ohm
C=0.1*10**-6 # capacitance in farad
#calculation
tc=0.69*(Ra+Rb)*C # Charging time of the capacitor
td=0.69*Rb*C # Discharging time of the capacitor
T=tc+td
fo=1/T # Freq of oscillation
#result
print "Charging time of the capacitor is",round(tc*10**3,2),"ms"
print "Discharging time of the capacitor is",round(td*10**3,2),"ms"
print "Freq of oscillation is",round(fo/10**3,1),"kHz"
#Example 9.8
#Referring to the circuit of figure 9-24(a),determine the frequency of the free-
#running ramp generator if R is set at 10 kHz.
#Assume that Vbe=Vd1=0.7 V.
from __future__ import division #to perform decimal division
import math
#Variable declaration
R=10*10**3 #Resistance in ohm
Vcc=5 #Supply voltage in volt
Vbe=0.7 #Base to emitter voltage in volt
C=0.05*10**-6 #Capacitance in farad
#calculation
Ic=(Vcc-Vbe)/R #Collector current in ampere
fo=(3*Ic)/(Vcc*C)
#result
print "Freq of free running ramp generator is",round(fo/10**3,2),"kHz"
#Example 9.9
#Referring to the circuit of figure 9-33(a),determine the free-running frequency
#fout, the lock range fl and the capture range fc.
from __future__ import division #to perform decimal division
import math
#Variable declaration
R1=12*10**3 # Resistance in ohm
V_plus=10 # Supply voltage in volt
V_minus=-10 # Supply voltage in volt
C1=0.01*10**-6 # Capacitance in farad
C2=10*10**-6 # Capacitance in farad
#calculation
fout=1.2/(4*R1*C1)
V=V_plus-V_minus
fl=(8*fout)/V
fc=math.sqrt(fl/(2*math.pi*3.6*10**3*C2))
#result
print "Free running frequency of VCO is",round(fout/10**3,1),"kHz"
print "Lock range frequency of VCO is",round(fl/10**3),"kHz"
print "Capture range frequency of VCO is",round(fc,2),"Hz"
#Example 9.10
#Using the 7805C voltage regulator , design a current source that will deliver
#a 0.25 A current to a 48 ohm, 10 W load.
from __future__ import division #to perform decimal division
import math
#Variable declaration
Vr=5 #Voltage in volt
Il=0.25 #Load current in ampere
Rl=48 #Load resistance in ohm
dropout_volt=2 #Constant for IC7805C
#calculation
R=Vr/Il #Approximate result sice Iq is negligible in the eq. Il=(Vr/Il)+Iq where Iq is quiescent current
Vl=Rl*Il
Vo=Vr+Vl
Vin=Vo+dropout_volt
#result
print "Resistance R is",R,"ohm"
print "Output voltage Vo is",Vo,"Volt"
print "Min input voltage Vin is",Vin,"Volt"
#Example 9.11
#Design an adjustable voltage regulator to satisfy the following specifications
#Output voltage Vo= 5 to 12 V
#Output current Io= 1 A.
#Voltage regulator is LM317.
from __future__ import division #to perform decimal division
import math
#Variable declaration
Vo_min=5 #Min output voltage in volt
Vo_max=12 #Max output voltage in volt
Vref=1.25 #Reference voltage in volt
Iadj=100*10**-6 #Adjustment pin current in ampere
R1=240 #Assumption
C2=1*10**-6 #Added to the circuit to improve transient response
C3=1*10**-6 #Added to the circuit to obtain high ripple rejection ratios
#calculation
R2_min=R1*(Vo_min-Vref)/(Vref+Iadj*R1) #Using Vo_min=Vref*(1+R2/R1)+Iadj*R2
R2_max=R1*(Vo_max-Vref)/(Vref+Iadj*R1) #Using Vo_max=Vref*(1+R2/R1)+Iadj*R2
#result
print "Resistance R2_min is",round(R2_min/10**3,2),"kilo ohm"
print "Resistance R2_max is",round(R2_max/10**3,2),"kilo ohm"
print "Therefore resistance should be varied from R2_min to R2_max values"
print "To do this we take R2 as 3kohm potentiometer"
#Example 9.12
#Design a step down switching regulator according to the following
#specifications.
#Input voltage Vin= 12 V dc.
#Output voltage Vo= 5V at 500 m A maximum.
#Output ripple voltage Vripple= 50 mV or 1% of Vo
#Switching regulator :uA78S40.
from __future__ import division #to perform decimal division
import math
#Variable declaration
Iomax=500*10**-3 # Max output current in ampere
Vo=5 # Output voltage in volt
Vd=1.25 # Voltage drop across the power diode in volt
Vin=12 # Input voltage in volt
Vs=1.1 # Output saturation voltage in volt
Vripple=50*10**-3 # Output ripple voltage in volt
Vref=1.245 # Reference voltage in volt
Vr2=1.2 # Voltage across resistance R2 in volt
#calculation
Ipk=2*Iomax # Sense current in ampere
Rsc=0.33/Ipk # Sense resistance in ohm
K=(Vo+Vd)/(Vin-Vs-Vo) # K= ton/toff
f=20*10**3 # Assuming operating freq in Hz
T=1/f
toff=T/2.06 # Using ton+toff=T and substituting for ton
ton=1.06*toff
Ct=45*10**-5*toff # Oscillator timing capacitance in farad
L=((Vo+Vd)/Ipk)*toff # Inductance in henry
Co=Ipk*((ton+toff)/(8*Vripple)) # Output capacitance in farad
I2=0.1*10**-3 # Assuming the current through R2
R2=Vref/I2 # Resistance R2 in ohm
R2=12*10**3 # Taking approximate value
R1=(R2*(Vo-Vr2))/Vr2 # Using Vr2=(R1*Vo)/R1+R2, voltage divider rule
efficiency=((Vin-Vs+Vd)/Vin)*(Vo/(Vo+Vd))*100
#result
print "Sense current,Ipk is",Ipk,"A"
print "Sense resistance,Rsc is",Rsc,"ohm"
print "Constant K is",round(K,2)
print "i.e, ton is K times of toff"
print "OFF time period,toff is",round(toff*10**6,2),"us"
print "ON time period,ton is",round(ton*10**6,2),"us"
print "Inductance,L is",round(L*10**6,2),"uH"
print "Output capacitance,Co is",round(Co*10**6,3),"uF"
print "Resistance R2 is",R2/10**3,"kilo ohm"
print "Resistance R1 is",R1/10**3,"kilo ohm"
print "efficiency is",efficiency
#Example 9.13
#Upgrade the switching regulator in Example 9-12 to provide +5V at 3A.
#Use the same specifications given in example 9-12,except the output ratings.
from __future__ import division #to perform decimal division
import math
#Variable declaration
Iomax=3 #Max output current in ampere
Vo=5 #Output voltage in volt
Vd=1.25 #Voltage drop across the power diode in volt
Vin=12 #Input voltage in volt
Vs=1.1 #Output saturation voltage in volt
Vripple=50*10**-3 #Output ripple voltage in volt
Vref=1.245 #Reference voltage in volt
Vr2=1.2 #Voltage across resistance R2 in volt
#calculation
Ipk=2*Iomax #Sense current in ampere
Rsc=0.33/Ipk #Sense resistance in ohm
K=(Vo+Vd)/(Vin-Vs-Vo) #K= ton/toff
f=20*10**3 #Assuming operating freq in Hz
T=1/f
toff=T/2.06 #Using ton+toff=T and substituting for ton
ton=1.06*toff
Ct=45*10**-5*toff #Oscillator timing capacitance in farad
L=((Vo+Vd)/Ipk)*toff #Inductance in henry
Co=Ipk*((ton+toff)/(8*Vripple)) #Output capacitance in farad
#result
print "Sense current,Ipk is",Ipk,"A"
print "Sense resistance,Rsc is",Rsc,"ohm"
print "Constant K",round(K,2)
print "i.e, ton is K times of toff"
print "OFF time period,toff is",round(toff*10**6,2),"us"
print "ON time period,ton is",round(ton*10**6,2),"us"
print "Oscillator timing capacitance,Ct is",round(Ct*10**9,1),"nF"
print "Inductance,L is = %.8f H",round(L*10**6,2),"uH"
print "Output capacitance,Co is = %.7f F",round(Co*10**3,5),"milli Farad"