# Astable multivibrator using IC555
import math
#Variable declaration
C = 0.01*10**-6 # capacitance
RA = 2*10**3 # Resistance RA
RB = 100*10**3 # Resistance RB
#Calculations
T_high = 0.693*(RA+RB)*C
T_low = 0.693*RB*C
T= T_high+T_low
f = 1/T
D = T_high*100/T
#Result
print("Frequency of oscillations, f = %.1f Hz\nDuty cycle = %.1f%%"%(f,D))
# Astable multivibrator using IC555
import math
#Variable declaration
C = 1.0*10**-6 # capacitance
C1 = 0.01*10**-6 # capacitance C1
RA = 4.7*10**3 # Resistance RA
RB = 1.0*10**3 # Resistance RB
#Calculations
Ton = 0.693*(RA+RB)*C
Toff = 0.693*RB*C
T= T_high+T_low
f = 1.4/((RA+2*RB)*C)
D = (RA+RB)*100/((RA+2*RB))
#Result
print("T_on = %.2f ms\nT_off = %.3f ms"%(Ton*1000,Toff*1000))
print("Frequency of oscillations, f = %.1f Hz\nDuty cycle = %.0f%%"%(math.floor(f*10)/10,D))
# Astable multivibrator using IC555
import math
#Variable declaration
f = 1000.0 # frequency
d = 50.0/100.0 # duty cycle
C = 0.01*10**-6 # capacitance
#Calculations
T = 1/f
Ton = d*T
Toff = d*T
RA = 1.44/(2*f*C)
#Result
print("RA = RB = %.0f k-ohm"%(RA/1000))
# IC555 timer as an astable multivibrator
import math
# Variable declaration
f = 700.0 # frequency
d = 0.5 # duty cycle
C = 0.01*10**-6 # capacitor value assumed
#Calculations
Ra = 1.44/(2*f*C)
#Result
print("C = %.2f micro-F\nRA = RB = %.0f k-ohm (100 k-ohm standard value)"%(C*10**6,Ra/1000))
# IC555 timer as an astable multivibrator
import math
# Variable declaration
f = 800.0 # frequency
d = 0.6 # duty cycle
C = 0.01*10**-6 # capacitor value assumed
#Calculations
Ra = 1.44/(5*f*C) # since Rb = 2Ra and f = 1.44/(Ra+2Rb)*C
Rb = 2*Ra
#Result
print("C = %.2f micro-F\nRA = %.0f k-ohm\nRB = %.0f k-ohm"%(C*10**6,Ra/1000,Rb/1000))
# Timer design(refer fig. 5.11)
import math
# Variable declaration
Ton = 5.0 # On timing oof the timer
# Calculations
C = 10*10**-6 # assumed value
R = Ton/(1.1*C)
#Result
print("C = %.0f micro-F\nR = %.2f ohm"%(C*10**6,R))
# Design of astable multivibrator(refer fig. 5.12)
import math
#Variable declaration
Ton = 3.0 # ON time
Toff = 1.0 # OFF time
#Calculations
C = 10*10**-6 # Capacitor assumed value
R2 = Toff/(0.693*C)
R1 = (Ton/(0.693*C))-R2
#Result
print("C = %.0f micro-F\nR1 = %.0f ohm\nR2 = %.0f ohm"%(C*10**6,R1,R2))
# Monostable and astable mode of IC555
import math
#Variable declaration
Ton = 10*10**-3 # ON timing
C = 0.22*10**-6 # Capacitance
V = 1.4 # LED voltage drop
I = 20*10**-3 # current provided by circuit
f = 1000.0 # frequency of astable multivibrator
d = 0.95 # duty cycle of astable multivibrator
#calculations
R = Ton/(1.1*C)
R = math.ceil(R/100)/10
Vcc = 15.0 # standard, assumed
Vbe = 0.7 # standard, assumed
VECsat = 0.2 # standard, assumed
Vo = Vcc -2*Vbe-VECsat
Rled = (Vo-V)/I
C1 = 0.01*10**-6 # capacitor for noise immunity
x = 1.44/(f*C1) # x = R1+2*R2.......(i)
y = (1-d)/(d*2-1) # y = R2/R1.........(ii)
y = math.floor(y*10**4)/10**4
R1 = x/(1+2*y) # using (i) and (ii)
R2 = y*R1
#Result
print("For LED driving circuit:\nCapacitance = %.2f micro-F\nResistancce = %.1f ohm\nVo = %.1f V\nRled = %.0f ohm"%(C*10**6,R,Vo,Rled))
print("\nFor astable multivibrator:\nC = %.2f micro-F\nR1 = %.1f ohm\nR2 = %.2f ohm"%(C1*10**6,R1/1000,R2/1000))
# IC555 as a monostable multivibrator(refer fig. 5.15)
import math
#VAriable declaration
T = 5*10**-3 # output pulse width
#Calculations
C = 0.1*10**-6 # capacitance
R = T/(1.1*C)
#Result
print("R = %.2f k-ohm\nThe value of R should be less than 100 k-ohm, as obtained."%(R/1000))
# IC555 based square wave generator
import math
#Variable declaration
f = 1000.0 # required frequency
Vcc = 12.0 # input voltage
#Calculations
T = 1/f
Td = T/2
C = 0.1*10**-6 # assumed
R2 = Td/(0.69*C)
#Result
print("R2 = %.2f k-ohm\nR1 = 100 ohm + 10 k-ohm pot(With pot, precise squre wave can be obtained)"%(R2/1000))
# Clock with 50% duty cycle
import math
# Variable declaration
f = 2000.0 # required output frequency
#Calculations
T = 1/f
Td = T/2
C = 0.1*10**-6 # assumed
R2 = Td/(0.69*C)
#Result
print("R1 = R2 = %.3f k-ohm"%(R2/1000))
# Rectangular waveform using astable multivibrator
import math
# Variable declaration
T = 1.0*10**-3 # Total time period of output waveform
Ton = 0.6 *10**-3 # Ton time
#Calculations
D = Ton/T
x = (1-D)/(2*D-1) # Rb/Ra
f = 1/T
C = 0.1*10**-6 # assumed
Ra = (1.44/(f*C))/5
Rb = x*Ra
#Result
print("C = %.2f micro-F\nRa = %.2f k-ohm\nRb = %.2f k-ohm"%(C*10**6,Ra/1000,Rb/1000))
# 555 timer in astable mode
import math
# Variable declaration
Ra = 4.0*10**3 # Resistance Ra
Rb = 4.0*10**3 # Resistance Rb
C = 0.01*10**-6 # Capacitance
#Calculations
f = 1.44/((Ra+2*Rb)*C)
D = (Ra+Rb)/(Ra+2*Rb)
#Result
print("frequency = %.0f KHz\nDuty cycle = %.2f%%"%(f/1000,D*100))
# Timer design
import math
# Variable declaration
Ton = 5 # ON time width
# Calculations
C = 10*10**-6 # assumed
R = Ton/(1.1*C)
#Result
print("R = %.2f k-ohm"%(R/1000))
# Astable multivibrator
import math
#Variable declaration
f = 2000.0 # output frequency
D = 0.75 # duty cycle
#Calculations
x = (1-D)/(2*D-1) # Rb/Ra
C = 0.1 *10**-6 # assumed
Ra = (1.44/f)/(C*2)
Rb = x*Ra
#Result
print("C = %.1f micro-F\nRa = %.1f k-ohm\nRb = %.1f k-ohm"%(C*10**6,Ra/1000,Rb/1000))
# 555 as astable mode to generate square wave(refer fig.5.25)
import math
# Variable declarations
f = 1000.0 # output square wave frequency
Vo = 5.0 # output voltage
Ton = 0.5*10**-3 # ON time of suare wave
Toff= 0.5*10**-3 # OFF time of suare wave
Vl = 5.0 # Lamp voltage rating
Il = 50*10**-3 # lamp current rating
#Calculations
C = 0.1*10**-6 # capacitance, assumed
Rb = Toff/(0.69*C)
Rb = Rb/1000.0 #k-ohm
VLed = 0.7 # voltage drop accross LED
R =(Vo-VLed)/(Il)
R = 100 #standard value
P = (Il**2)*R
# Result
print("duty cycle is 50%% hence,\nRa = Rb = %.3f k-ohm\nCurrent limiting Resistance for LED is, R = %.0f ohm\nP = %.2f W"%(Rb,R,P))
# Ramp generator using IC555
import math
#Variable declaration
f = 5000.0 # output frequency
Vcc = 5.0 # input voltage
# Calculations
Vd = 0.7 # = Vbe, assumed
Ic = (Vcc-Vd)
RC = 3*Ic/(Vcc*f)
C = 0.05*10**-6 # assumed
R = RC/C
Ic = Ic/R
#Result
print("C = %.2f micro-F\nR = %.2f k-ohm\nIc = %.3f mA"%(C*10**6,R/1000,math.floor(Ic*10**6)/1000))
# Triangular wave generator
import math
#Variable declaration
f = 5000.0 # output frequency
Vo = 10.5 # output voltage
Vsat = 15 # saturation voltage
#Calculations
x = 2*Vsat/Vo # R3/R2:: this value is wrong in the book
R2 = 10*10**3 # assumed
R3 = 4*R2 # calculationg using value given in book
C1 = 0.01*10**-6 # assumed
R1 = R3/(4*C1*R2*f)
#Result
print("C1 = %.2f micro-F\nR1 = %.0f k-ohm\nR2 = %.0f k-ohm\nR3 = %.0f k-ohm"%(C*10**6,R1/1000,R2/1000,R3/1000))
print("Theoretical example")
print("Theoretical example")
# Oscillation frequency(refer fig 5.21)
import math
#Variable declaration
R = 5.1*10**3 # resistance
C = 0.001*10**-6 # capacitance
R3 = 6.0*10**3 # Resistance of R3
R4 = 2.0*10**3 # Resistance of R4
#Calculations
A = 1+(R3/R4)
f = 1/(2*math.pi*R*C)
#Result
print("A = %d\nAs A > 3, this satisfies the required oscillating condition. Hence, Circuit will work as oscillator.\n"%(A))
print("frequency of oscillations = %.4f kHz"%(f/1000))
# design of wein bridge oscillator(refer fig.5.58)
import math
# Variable declaration
f = 1000.0 # frequency of oscillation
V = 15 # supply voltage
g = 3 # gain of non-inverting op-amp for circuit to be oscillator
#Calculations
C = 0.05*10**-6 # assumed
R = 1/(2*math.pi*C*f)
R4 = 10*10**3 # assumed
R3 = (g-1)*R4
#Result
print("C1 = C2 = C = %.2f micro-F\nR1 = R2 = R = %.3f k-ohm\nR3 = %.0f k-ohm\nR4 = %.0f k-ohm"%(C*10**6,R/1000,R3/1000,R4/1000))
# output frequency range
import math
#Variable declararion
R = 10*10**3 # Resistor R
C = 1.25*10**-9 # Capacitance
Vut = 10.0 # Upper threshold voltage
Vlt = 0.0 # lower threshold voltage
Vmin = 10*10**-3 # minimum voltage
Vmax = 10 # Maximum voltage
#Calculations
Kv = 1/(8*R*C*(Vut-Vlt))
fmin = Vmin*Kv
fmax = Vmax*Kv
#Result
print("Range over whoich output frequency can be varied is %.0f Hz to %.0f KHz."%(fmin,fmax/1000))
# output frequency(refer fig. 5.67 and 5.68)
import math
# Variable declaration
V = 10 # supply voltage
R1 = 10*10**3 # Resistor R1
R2 = 1.2*10**3 # Resistor R2
R3 = 10*10**3 # Resistor R3
C1 = 0.001*10**-6 # Capacitance
Vc1 = 7.7 # Voltage at pin 5
Vc2 = 9.5 # Voltage at pin 5
#Calcualtions
# (a)
Vc = R3*V/(R2+R3)
Vc = math.floor(Vc*1000)/1000
fo = 2*(V-Vc)/(C1*R1*V)
fo = fo/1000 # kHz
# (b)
fo1 = 2*(V-Vc1)/(C1*R1*V)
fo1 = fo1/1000
fo2 = 2*(V-Vc2)/(C1*R1*V)
fo2 = fo2/1000
#Result
print("(a)\nVc = %.3f V\nfo = %.2f kHz\n\n(b)\nfo1 = %.0f kHz\nfo2 = %.0f kHz\nChange in frequency is %.0f kHz"%(Vc,fo,fo1,fo2,fo1-fo2))