Chapter 4: Applications of Operational Amplifiers

Example No. 4.1, Page No: 185

In [25]:
%matplotlib inline
Populating the interactive namespace from numpy and matplotlib
WARNING: pylab import has clobbered these variables: ['prod', 'plotting', 'Circle', 'power', 'diag', 'fmax', 'sinh', 'trunc', 'binomial', 'plot', 'eye', 'f', 'det', 'tan', 'product', 'roots', 'sin', 'zeros', 'cosh', 'conjugate', 'take', 'solve', 'trace', 'beta', 'pylab', 'ones', 'transpose', 'vectorize', 'cos', 'interactive', 'diff', 'invert', 'tanh', 'Polygon', 'reshape', 'sqrt', 'floor', 'source', 'add', 'multinomial', 'test', 'poly', 'mod', 'sign', 'gamma', 'log', 'var', 'seterr', 'flatten', 'nan', 'pi', 'exp']
`%pylab --no-import-all` prevents importing * from pylab and numpy
In [26]:
#Variable Declaration:
import math
R1=20.0*10**3             #Resistance in ohm
R=39.0*10**3              #Resistance in ohm
f=2000.0                  #Frequencuy in hertz
Rf=R1                     #Value of Rf is equal to R1 in ohm
C=10**-9                  #Capacitance in farad

#Calculations:
fo=1/(2*math.pi*R*C)      #Calculating output frequency

theta=-2*math.atan(f/fo)  #Calculating phase angle
theta=theta*180/math.pi   #Calculating phase angle

td=theta/(f*360)          #Calculating time delay
td=-td*10**6              #Calculating time delay

#Results:
print('Phase angle=%.1f degree'%theta)
print('\nTime delay td= %.1f us'%td)
Phase angle=-52.2 degree

Time delay td= 72.5 us

Example No. 4.2, Page No: 187

In [27]:
#Variable Declaration:
Vee=12.0            #Volatge Vee in volt
Vcc=5.0             #Voltage Vcc in volt
RL=1000.0           #Resistance RL in ohm

#Calculations:
Vdiff=Vee-Vcc       #Calculating voltage difference
IL=Vdiff/RL         #Calculating current
IL=IL*1000.0        #Calculating current

#Results:
print('Current through RL is IL= %d mA'%IL)
Current through RL is IL= 7 mA

Example No. 4.3, Page NO: 187

In [28]:
#Variable Declaration:
V=5.0               #Voltage in volt
R=1000.0            #Resistance in ohm

#Calculations:
I=V/R               #Calculating current
I=I*1000.0          #Calculating current

#Results:
print('Current= %d mA'%I)
Current= 5 mA

Example No.4.4, Page NO: 187

In [29]:
#Variable Declaration:
Vcc=15.0                #Voltage in volt
Re2=1000.0              #Resistance in ohm
Vc1=5.0                 #Voltage in volt
Ve2=5.0                 #Voltage in volt

#Calculations:
I=(Vcc-Ve2)/Re2         #Calculating current
I=I*1000.0              #Calculating current

#Results:
print('Current= %d mA'%I)
Current= 10 mA

Example No. 4.5, Page No: 189

In [30]:
#Variable Declaration:
R1=22.0*10**3              #Resistance in ohm
Rf=1000.0                  #Feedback Resistance in ohm
RL=10.0*10**3              #Load Resistance in ohm           
Ii=10.0*10**-6             #Current in ampere

#Calculations:
Ai=1+R1/Rf                 #Calculating gain 
Io=Ai*Ii                   #Calculating output current
Io=Io*10**6                #Calculating output current
print('Current Io= %f uA'%Io)

Io=Io/10**6                #Calculating output current 
Vmax=Io*RL + Ii*R1         #Calculating maximum voltage

#Results:
print('\nVmax= %.2f V'%Vmax)
print('\nHence output clipping doesnot occur')
Current Io= 230.000000 uA

Vmax= 2.52 V

Hence output clipping doesnot occur

Example No. 4.6, Page No: 192

In [31]:
#Variable Declaration:
Rf=10.0*10**3      #Feedback resistance in ohm
RL=2000.0          #Load resistance in ohm
Vi=0.5             #Input voltage in volt

#Calculations:
IL=Vi/Rf           #Calculating current
IL=IL*10**6        #Calculating current
print('Current IL= %d uA'%IL)

IL=IL/10**6        #Calculating current
Vmax=IL*RL + IL*Rf #Calculating maximum voltage

#Results:
print('\nVmax= %.2f V'%Vmax)
print('\nHence output clipping doesnot occur')
Current IL= 50 uA

Vmax= 0.60 V

Hence output clipping doesnot occur

Example No. 4.7, Page No: 194

In [32]:
#Variable Declaration:
V1=2.0                  #Voltage in volt
V2=3.0                  #Voltage in volt
V3=4.0                  #Voltage in volt
Rf=1000.0               #Feedback resistance in ohm
R1=Rf                   #Resistance value of the R1 is equal to Rf in ohm
R2=Rf                   #Resistance value of the R2 is equal to Rf in ohm  
R3=Rf                   #Resistance value of the R3 is equal to Rf in ohm
R=Rf                    #Resistance value of the R is equal to Rf in ohm 

#Calculations:
Vo=-(Rf/R1)*(V1+V2+V3)  #Calculating output voltage

#Results:
print('Vo= %d V'%Vo)
Vo= -9 V

Example No: 4.9, Page NO: 207

In [33]:
#Variable Declaration:
import math
R1=10.0*10**3            #Resistance in ohm
Rf=100.0*10**3           #Resistance in ohm
Cf=10.0*10**-9           #Capacitance in farad

#Calculations:
fa=1/(2*math.pi*Rf*Cf)   #Calculating lower frequency limit

#PART (a)
Vo1=10**4/(2*3.14*2500)     
#PART (b)
Vo2 = -10**4*0.2*10**-3 
#PART (c)
Vo3 = -10**4*0.6*10**-3
#Results:
print('fa= %d Hz'%fa)
print('output voltage for sine wave input is %.3f volt'%Vo1)
print('output voltage for square wave input is %d volt'%Vo2)
print('output voltage for step input is %d volt'%Vo3)

##############(1)#############
t = arange(0.001, 1, 0.005)
k = arange(0.0001, 0.2, 0.0005)
subplot(221)
plot(t, sin(16*t))
plot(t,0.637*cos(16*t))
plot(t,(0*t)/t,'-')
plot(k,(-0.637*k)/k,'--')
ylim( (-1,1) )
text(-0.11,-0.637,'-0.637')
text(0.2,0.2,'Green = Vo')
text(0.07,0.5,'Blue = Vi')
ylabel('Vin')
xlabel('time in ms')
title('Input & output waveforms of integrator')

##############(2)#################
n = arange(0.0001,0.2, 0.0005)
n1= arange(0.2, 2*0.2, 0.0005)
n2= arange(2*0.2, 3*0.2, 0.0005)
n3= arange(3*0.2,4*0.2, 0.0005)
n4= arange(4*0.2,5*0.2, 0.0005)
n5= arange(0.0001,5*0.2, 0.0005)

a=arange(-1,1,0.0005)

x5=(0.2*a)/a
x10=(2*0.2*a)/a
x15=(3*0.2*a)/a
x25=(4*0.2*a)/a

subplot(223)

plot(n5,(0*n5)/n5,'-')
plot(n,1*n/n,'b')
plot(n1,-1*n1/n1,'b')
plot(n2,1*n2/n2,'b')
plot(n3,-1*n3/n3,'b')
plot(n4,1*n4/n4,'b')

plot(x5,a,'b')
plot(x10,a,'b')
plot(x15,a,'b')
plot(x25,a,'b')

plot(n,(-10*n+1),'r')
plot(n1,(10*n-1),'r')
plot(n+0.4,(-10*n+1),'r')
plot(n3,(10*n-1),'r')

ylim( (-1.1,1.1) )
text(0.3,-0.4,'Red = Vo')
text(0.05,0.5,'Blue = Vi')
ylabel('Vin')
xlabel('time in ms')

###############(3)##################
t = arange(0.0001, 1, 0.0005)
t2 = arange(0.0001, 0.6, 0.0005)
a=arange(-6,0.0001,0.0005)
x=(0.6*a)/a
subplot(222)
plot(t,1*t/t,'r')
plot(t,0*t/t,'--')
plot(t2,-6*t2/t2,'--')
plot(x,a,'--')
plot(t,(-10*t),'b')
text(0.4,-4,'Vo')
text(0.3,1.1,'Vi')
xlabel('time in ms')
fa= 159 Hz
output voltage for sine wave input is 0.637 volt
output voltage for square wave input is -2 volt
output voltage for step input is -6 volt
Out[33]:
<matplotlib.text.Text at 0xce594e0>

Example No: 4.10, Page No: 210

In [34]:
#Variable Declaration:
import math
fa=1.0*10**3              #Upper cut off frequency in hertz
C1=1.0*10**-6             #Capacitance in farad

#Calculations:
Rf=1/(2*math.pi*fa*C1)    #Calculating value of resistance
Rf=Rf/100.0               #Calculating value of resistance 

#Results:
print('Rf= %.2f kohm'%Rf)
Rf= 1.59 kohm

Example No. 4.11, Page No: 213

In [35]:
#Variable Declaration:
import math
import pylab
import numpy
fa=200.0                  #frequency in hertz
fmax=fa                   #frequency fmax is equal to fa
C1=0.1*10**-6             #Capacitance in farad

#Calculations:
             
Rf=1/(2*math.pi*fa*C1)    #Calcukating resistance value 
Rf=Rf/1000.0              #Calculating resistance value

fb=10.0*fa                #Calculating frequency
R1=1/(2*math.pi*fb*C1)    #Calculating resistance 
R1=R1/1000.0              #Calculating resistance

Cf=R1*C1/Rf               #Calculating capacitance 
Cf=Cf*10**6               #Calculating capacitance

subplot(211)
plot(t,1*sin(2*pi*t))

ylim( (-1,1) )
ylabel('Vin')
title('Input Waveform')


#Results:
print('Rf= %.3f kohm'%Rf)
print('\nR1= %.3f kohm'%R1)
print('\nCf= %.2f uF'%Cf)

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

##########(1)###############
t = arange(0.001, 5*pi, 0.005)
subplot(221)
plot(t, sin(pi*t/4))
plot(t,(0*t)/t,'-')
ylim( (-1,1) )
ylabel('Vin')
title('Input Waveform')

###########(2)#######
subplot(223)
plot(t, cos((pi*t/4-135)))
plot(t,(0*t)/t,'-')
ylim( (-1,1) )
ylabel('Vout')
xlabel('(a)')
title('Output Waveform')

##########(3)#########
k = arange(0.0001, pi, 0.0005)
k1= arange(pi, 2*pi, 0.0005)
k2= arange(2*pi, 3*pi, 0.0005)
k3= arange(3*pi,4*pi, 0.0005)
k4= arange(4*pi,5*pi, 0.0005)
m=arange(-1,1,0.0005)
x5=(pi*m)/m
x10=(2*pi*m)/m
x15=(3*pi*m)/m
x25=(4*pi*m)/m
subplot(222)
plot(t,(0*t)/t,'-')
plot(k,1*k/k,'b')
plot(k1,-1*k1/k1,'b')
plot(k2,1*k2/k2,'b')
plot(k3,-1*k3/k3,'b')
plot(k4,1*k4/k4,'b')
plot(x5,m,'b')
plot(x10,m,'b')
plot(x15,m,'b')
plot(x25,m,'b')
ylim( (-1.1,1.1) )
ylabel('Vin')
title('Input Waveform')

############(4)############
subplot(224)
m1=arange(0.001,13,0.0005)
m2=arange(-13,0.001,0.0005)
y1=(0.01*pi*m2)/m2
y5=(pi*m1)/m1
y10=(2*pi*m2)/m2
y15=(3*pi*m1)/m1
y25=(4*pi*m2)/m2
plot(t,(0*t)/t,'-')
plot(y5,m1,'b')
plot(y10,m2,'b')
plot(y1,m2,'b')
plot(y15,m1,'b')
plot(y25,m2,'b')
plot(y5+0.1,m1,'b')
plot(y10+0.1,m2,'b')
plot(y1+0.1,m2,'b')
plot(y15+0.1,m1,'b')
plot(y25+0.1,m2,'b')
text(-2.5,13,'Vsat')
text(-2.5,-13,'-Vsat')
ylim(-13,13)
ylabel('Vout')
xlabel('(b)')
title('Output Waveform')
Rf= 7.958 kohm

R1= 0.796 kohm

Cf= 0.01 uF
Out[35]:
<matplotlib.text.Text at 0xd0e5c18>

Example No.4.13, Page No: 226

In [42]:
import sympy
from sympy import *
sympy.init_printing()

s = Symbol("s")
H = 4/(s**2+3.3*s+0.9)
print("The given transfer function is:")
display(H.simplify())
print("\n\n\nThe above transfer function can be represented after factoring as given by:")
display(factor(H))
The given transfer function is:
$$\frac{4}{s^{2} + 3.3 s + 0.9}$$


The above transfer function can be represented after factoring as given by:
$$\frac{40.0}{\left(1.0 s + 3.0\right) \left(10.0 s + 3.0\right)}$$