Chapter 16: Oscillators

Example 16.1, Page Number: 524

In [1]:
%matplotlib inline
Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].
For more information, type 'help(pylab)'.
In [2]:
import math
R1=10*10**3;
R2=R1;
R=R1;
C1=0.01*10**-6;
C2=C1;
C=C1;
R3=1*10**3;
r_ds=500;
f_r=1/(2*math.pi*R*C);
print('resonant frequency of the  Wein-bridge oscillator in Hertz = %.4f'%f_r)
#closed loop gain A_v=3 to sustain oscillations
A_v=3;
#A_v=(R_f+R_i)+1 where R_i is composed of R3 and r_ds
R_f=(A_v-1)*(R3+r_ds);
print('value of R_f in ohms = %d'%R_f)
resonant frequency of the  Wein-bridge oscillator in Hertz = 1591.5494
value of R_f in ohms = 3000

Example 16.2, Page Number: 525

In [3]:
import math
A_cl=29;    #A_cl=R_f/R_i;
R3=10*10**3;
R_f=A_cl*R3;
print('value of R_f in ohms = %d'%R_f)
#let R1=R2=R3=R and C1=C2=C3=C
R=R3;
C3=0.001*10**-6;
C=C3;
f_r=1/(2*math.pi*math.sqrt(6)*R*C);
print('frequency of oscillation in Hertz = %f'%f_r)
value of R_f in ohms = 290000
frequency of oscillation in Hertz = 6497.473344

Example 16.3, Page Number: 530

In [4]:
import math
C1=0.1*10**-6;
C2=0.01*10**-6;
L=50.0*10**-3;    #in Henry
C_T=C1*C2/(C1+C2);    #total capacitance
f_r=1/(2*math.pi*math.sqrt((L*C_T)));
print('frequency of oscillation in Hertz when Q>10 is \n\t %f'%f_r)
Q=8.0;    #when Q drops to 8
f_r1=(1/(2*math.pi*math.sqrt((L*C_T))))*math.sqrt((Q**2/(1+Q**2)));
print('frequency of oscillation in hertz when Q=8 is \n \t %f'%f_r1)
frequency of oscillation in Hertz when Q>10 is 
	 7465.028533
frequency of oscillation in hertz when Q=8 is 
 	 7407.382663

Example 16.4, Page Number: 535

In [5]:
R1=10.0*10**3;
R2=33.0*10**3;
R3=10.0*10**3;
C=0.01*10**-6;
f_r=(1/(4*R1*C))*(R2/R3);
print('frequency of oscillation in hertz is \n\t%d'%f_r)
#the value of R1 when frequency of oscillation is 20 kHz
f=20.0*10**3;
R1=(1/(4*f*C))*(R2/R3);
print('value of R1 in ohms to make frequency 20 kiloHertz is \n\t%d'%R1)
frequency of oscillation in hertz is 
	8250
value of R1 in ohms to make frequency 20 kiloHertz is 
	4125

Example 16.5, Page Number: 537

In [6]:
import pylab
import numpy
V=15.0;
C=0.0047*10**-6;
R3=10.0*10**3;
R4=R3;
R2=10.0*10**3;
R1=68.0*10**3;
R_i=100.0*10**3;
V_G=R4*V/(R3+R4);    #gate voltage at which PUT turns on
V_p=V_G;    #neglecting 0.7V, this the peak voltage of sawtooth wave
print('neglecting 0.7V,  the peak voltage of sawtooth wave = %.1f V'%V_p)
V_F=1.0;    #minimum peak value of sawtooth wave
V_pp=V_p-V_F;
print('peak to peak amplitude of the sawtooth wave = %.1f V'%V_pp)
V_IN=-V*R2/(R1+R2);
f=(abs(V_IN)/(R_i*C))*(1/(V_pp));
print('frequency of the sawtooth wave = %.1f Hz'%f)

#############PLOT###############################

t = arange(0.0, 2.0, 0.0005)
t1= arange(2.0, 4.0, 0.0005)
t2= arange(4.0, 6.0, 0.0005)
k=arange(0.1,7.5, 0.0005)
t3=(2*k)/k
t4=(4*k)/k
t6=(6*k)/k

subplot(111)
plot(t, (6.5/2)*t+1)
plot(t1, (6.5/2)*t+1,'b')
plot(t2, (6.5/2)*t+1,'b')
plot(t3,k,'b')
plot(t4,k,'b')
plot(t6,k,'b')

ylim( (1,8) )
ylabel('Vout')
xlabel('ms')
title('Output of the Circuit')
neglecting 0.7V,  the peak voltage of sawtooth wave = 7.5 V
peak to peak amplitude of the sawtooth wave = 6.5 V
frequency of the sawtooth wave = 629.5 Hz
Out[6]:
<matplotlib.text.Text at 0xa046eec>

Example 16.6, Page Number: 542

In [7]:
R1=2.2*10**3;
R2=4.7*10**3;
C_ext=0.022*10**-6;
f_r=1.44/((R1+2*R2)*C_ext);
print('frequency of the 555 timer in hertz = %f'%f_r)
duty_cycle=((R1+R2)/(R1+2*R2))*100;
print('duty cycle in percentage = %f'%duty_cycle)
frequency of the 555 timer in hertz = 5642.633229
duty cycle in percentage = 59.482759