# Chapter5 - Linear applications of op-amps¶

## Ex 5.1 - page : 121¶

In [1]:
from __future__ import division
V1=2 #V
V2=3 #V
V3=4 #V
V4=5 #V
R1=10 #kohm
R2=15 #kohm
R3=22 #kohm
R4=50 #kohm
Rf=10 #kohm
Vout=-Rf/R1*V1-Rf/R2*V2-Rf/R3*V3-Rf/R4*V4 #V
print "Output voltage of the circuit is %0.2f V " %Vout

Output voltage of the circuit is -6.82 V


## Ex 5.2 - page : 129¶

In [3]:
from __future__ import division
Rf=240 #kohm
#Vout=-4*Vx+3*Vy
#case 1st
Vy=0 #V(But Vx is not=0)
#Vox=-Rf/R1*Vx=-4*Vx
R1=Rf/4 #kohm
#case 2nd
Vx=0 #V(But Vy is not=0)
#Voy=(1+Rf/R1)*R2*Vy/(R1+R2)=3*Vy
R2=3/(1+Rf/R1)*R1/((1-3/(1+Rf/R1)))
print "Resistance R1 is %0.f kohm " %R1
print "Resistance R2 is %0.f kohm " %R2

Resistance R1 is 60 kohm
Resistance R2 is 90 kohm


## Ex 5.3 - page : 130¶

In [5]:
from __future__ import division
V1=-2 #V
V2=3 #V
R1=50 #kohm
R2=100 #kohm
Rf=250 #kohm
#I1+I2=If with IB=0 & Vx=0
Vout=-(V1/R1+V2/R2)*Rf #V
print "Output Voltage is %0.1f V " %Vout

Output Voltage is 2.5 V


## Ex 5.4 - page : 130¶

In [7]:
from __future__ import division
V1=-2 #V
V2=3 #V
R1=12 #kohm
R2=12 #kohm
R3=10 #kohm
Rf=12 #kohm
Ri=12 #kohm
Rt=2 #kohm
Vyx=200*10**-6 #V
Vout=Rf/Ri*(1+2*R3/Rt)*Vyx #V
Vout*=1000 #mV
print "Output Voltage is %0.1f mV " %Vout

Output Voltage is 2.2 mV


## Ex 5.5 - page : 131¶

In [9]:
from __future__ import division
R1max=50 #kohm(Potentiometer)
R4=10 #kohm
R3=10 #kohm
R1=R1max #kohm
print "Resistance R2 is %0.f kohm " %R2
print "Minimum value of resistance R1 is %0.f kohm " %R1min

Resistance R2 is 100 kohm
Minimum value of resistance R1 is 1 kohm


## Ex 5.6 - page : 132¶

In [14]:
from __future__ import division
R3=1 #kohm
Rt=5 #kohm
Ri=1.8 #kohm
R1=1.8 #kohm
Rf=18 #kohm
R2=18 #kohm
Vs=15 #V
AoL=2*10**5 #Gain(for 741C)
Rio=2#Mohm
Ro=75#Mohm
fo=5 #Hz
fBW=1 #MHz
print "Differential gain is %0.2f " %Ad
Beta=(R3+Rt)/(2*R3+Rt) #unitless
Rix=Rio*10**6*(1+AoL*Beta) #ohm
print "Input impedence, Rix is %0.2e ohm " %Rix
print "Output impedence is %0.1e Rof ohm " %Rof
#Answer in the book is wrong for Rix.

Differential gain is 14.00
Input impedence, Rix is 3.43e+11 ohm
Output impedence is 5.2e-03 Rof ohm


## Ex 5.8 - page : 134¶

In [15]:
from __future__ import division
Ri=10 #kohm
Rf=15 #kohm
Vs=9 #V
#Part (a)
Ra=120 #ohm
Rb=120 #ohm
Rc=120 #ohm
Rd=120 #ohm
Vx=0 #V
Vy=0 #V (as Bridge is balanced)
Vout=(Vy-Vx)*Rf/Ri #V
print "(a) Output Voltage is %0.2f V " %Vout
#Part (b)
Ra=120 #ohm
Rb=120 #ohm
Rc=120 #ohm
Rd=150 #ohm
Vx=Rb*Vs/(Ra+Rb) #V
Vy=Rc*Vs/(Rc+Rd)#V
Vyx=Vy-Vx #V
Vout=(Vy-Vx)*Rf/Ri #V
print "(b) Output Voltage is %0.2f V " %Vout

(a) Output Voltage is 0.00 V
(b) Output Voltage is -0.75 V


## Ex 5.9 - page : 135¶

In [17]:
from __future__ import division
Vin=2 #V
Rf=2*2/(2+2)+2 #kohm
R1=1 #kohm
Vout=-Rf/R1*Vin #V
print "Output Voltage is %0.f V " %Vout

Output Voltage is -6 V


## Ex 5.11 - page : 144¶

In [21]:
from __future__ import division
import math
G=20 #dB(Gain)
f3dB=2 #kHz
Cf=0.05 #micro F
Rf=1/(f3dB*1000*2*math.pi*Cf/1000000)/1000 #kohm
G=10**(G/20) #Gain(unitless)
Ri=Rf*1000/G #ohm
print "Resistance Rf is %0.1f kohm " %Rf
print "Resistance Ri is %0.f ohm " %Ri
# Answer in wrong in thetextbook.

Resistance Rf is 1.6 kohm
Resistance Ri is 159 ohm


## Ex 5.13 - page : 146¶

In [19]:
%matplotlib inline
import matplotlib.pylab as plt
import numpy as np
from __future__ import division
t2=50 #ms(After open the switch)
R=40 #kohm
C=0.2 #micro F
V2=3 #V
Vin=5 #V
#For Ideal op-amp V1=V2
t1=0 #s
Vout1=V2 #V
V1=V2 #V
t2=t2*10**-3 #s
f=lambda T:(Vin-V1)
def integrate(a,b,f):
# def function before using this
# f=lambda t:200**2*t**2
#a=lower limit;b=upper limit;f is a function
import numpy
N=1000 # points for iteration
t=numpy.linspace(a,b,N)
ft=f(t)
ans=numpy.sum(ft)*(b-a)/N
ans/=3
ans**=1.0/2
return ans
Vout2=-1/(R*10**3*C*10**-6)*integrate(0,t2,f)+Vout1 #V
#Here we have t=0 switch closed Vout=3V
t=np.array([t1*1000,t2*1000]) #ms
Vout=np.array([Vout1,Vout2]) #V
plt.plot(t, Vout)
plt.title('Vout Vs time after switch is opened')
plt.xlabel('t(ms)')
plt.ylabel('Vout(V)')
plt.show()
#Plot in the textbook is not accurate.


## Ex 5.14 : page - 147¶

In [4]:
from __future__ import division
R1=1 #kohm
R2=1 #kohm
R3=1 #kohm
Rf=R2+R3 #kohm
Vin=1 #V
#Capacitor remains open circuited for steady state in both cases.
Vout=-Rf/R1*Vin #V
print "Output Voltage is %0.2f V " %Vout

Output Voltage is -2.00 V


## Ex 5.16 - page : 148¶

In [6]:
from __future__ import division
#From the given equationVout=-integrate('5*Vx+2*Vy+4*Vz','t',0,t) :
R1Cf=1.0/5 #ratio
R2Cf=1.0/2 #ratio
R3Cf=1.0/4 #ratio
print "Various design parameters are : "
Cf=10 #micro F##Chosen for the design
print "Capacitance is %0.2f micro F " %Cf
R1=R1Cf/(Cf*10**-6)/1000 #kohm
R2=R2Cf/(Cf*10**-6)/1000 #kohm
R3=R3Cf/(Cf*10**-6)/1000 #kohm
print "Resistance R1 is %0.2f kohm " %R1
print "Resistance R2 is %0.2f kohm " %R2
print "Resistance R3 is %0.2f kohm " %R3

Various design parameters are :
Capacitance is 10.00 micro F
Resistance R1 is 20.00 kohm
Resistance R2 is 50.00 kohm
Resistance R3 is 25.00 kohm


## Ex 5.17 - page : 153¶

In [7]:
from __future__ import division
f=10 #kHz
Rf=3.2 #kohm
Ci=0.001 #micro F
dt=5 #micro seconds
dVin=5-(-5) #V(When voltage changes from -5V to +5V)
Vout=-Rf*1000*Ci*10**-6*dVin/(dt*10**-6) #V
print "When voltage changes from -5V to +5V, The output Voltage is %0.2f V " %Vout
dVin=-5-(+5) #V(When voltage changes from +5V to -5V)
Vout=-Rf*1000*Ci*10**-6*dVin/(dt*10**-6) #V
print "When voltage changes from +5V to -5V, The output Voltage is %0.2f V " %Vout

When voltage changes from -5V to +5V, The output Voltage is -6.40 V
When voltage changes from +5V to -5V, The output Voltage is 6.40 V


## Ex 5.18 page : 154¶

In [12]:
from __future__ import division
import math
fmin=200 #Hz
fmax=1 #kHz
fa=fmax #kHz
print "Various design parameters are : "
Ci=0.05 #micro F##Chosen for the design
print "Capacitance Ci is %0.2f micro F " %Ci
fb=10*fa #kHz
Rf=1/(2*math.pi*fa*10**3*Ci*10**-6)/1000 #kohm
print "Resistance Rf is %0.1f kohm " %Rf
Ri=1/(2*math.pi*fb*10**3*Ci*10**-6) #ohm
print "Resistance Ri is %0.f ohm " %Ri
Cf=Ri*Ci/(Rf*10**3) #micro F
print "Capacitance Cf is %0.3f micro F " %Cf
# Answer in the textbook is not accurate.

Various design parameters are :
Capacitance Ci is 0.05 micro F
Resistance Rf is 3.2 kohm
Resistance Ri is 318 ohm
Capacitance Cf is 0.005 micro F


## Ex 5.19 - page : 156¶

In [15]:
from __future__ import division
import math
fmax=100 #Hz
fa=fmax #Hz
print "Various design parameters are : "
Ci=0.1 #micro F##Chosen for the design
print "Capacitance Ci is %0.2f micro F " %Ci
Rf=1/(2*math.pi*fa*Ci*10**-6)/1000 #kohm
print "Resistance Rf is %0.1f kohm " %Rf
print "Use f=15 kohm"
fb=15*fa #kHz
Ri=1/(2*math.pi*fb*Ci*10**-6)/1000 #kohm
print "Resistance Ri is %0.2f ohm " %Ri
print "Use Ri=1 kohm"
Cf=Ri*Ci/Rf #micro F
print "Capacitance Cf is %0.3f micro F " %Cf
#Answer in the book is not accurate for Cf.

Various design parameters are :
Capacitance Ci is 0.10 micro F
Resistance Rf is 15.9 kohm
Use f=15 kohm
Resistance Ri is 1.06 ohm
Use Ri=1 kohm
Capacitance Cf is 0.007 micro F


## Ex 5.20 -page : 157¶

In [17]:
from __future__ import division
f=50 #Hz
T=1/f #s(Period)
Ci=0.05 #micro F
RiCi=0.01*T #Given
Ri=RiCi/(Ci*10**-6)/1000 #kohm
print "Resistance Ri is %0.2f kohm " %Ri
#Vout=-.002*dVin/dt given
#On comparing with Vout=-Rf*Ci*dVin/dt
RfCi=0.002 #on comparing
Rf=RfCi/(Ci*10**-6)/1000 #kohm
print "Resistance Rf is %0.2f kohm " %Rf
Cf=Ri*Ci/Rf #micro F
print "Capacitance Cf is %0.3f micro F " %Cf

Resistance Ri is 4.00 kohm
Resistance Rf is 40.00 kohm
Capacitance Cf is 0.005 micro F