# Chapter : 4 - Linear Applications of IC Op-Amps¶

## Example 4.1 : Page No - 131¶

In [1]:
#Given data
R1= 1 # in kΩ
R2= 1 # in kΩ
R3= 1 # in kΩ
RF= 1 # in kΩ
Vin1= 2 # in volt
Vin2= 1 # in volt
Vin3= 4 # in volt
Vout= -(RF/R1*Vin1+RF/R2*Vin2+RF/R3*Vin3)
print "The output voltage = %0.f volts" %Vout

The output voltage = -7 volts


## Example 4.2 : Page No - 131¶

In [2]:
#Given data
RF= 100 # in kΩ
Vout= '-(V1+10*V2+100*V3)' # Given data data expression
# Vout= -(RF/R1*V1+RF/R2*V2+RF/R3*V3)
# Comparing the Vout with the Given data data expression
R1= RF # in kΩ
R2= RF/10 # in kΩ
R3= RF/100 # in kΩ
print "The value of R1 = %0.f kΩ" %R1
print "The value of R2 = %0.f kΩ" %R2
print "The value of R3 = %0.f kΩ" %R3

The value of R1 = 100 kΩ
The value of R2 = 10 kΩ
The value of R3 = 1 kΩ


## Example 4.3 : Page No - 131¶

In [3]:
#Given data
R1= 12 # in kΩ
R2= 2 # in kΩ
R3= 3 # in kΩ
RF= 12 # in kΩ
V1= 9 # in volt
V2= -3 # in volt
V3= -1 # in volt
Vout= -(RF/R1*V1+RF/R2*V2+RF/R3*V3)
print "The output voltage = %0.f volts" %Vout

The output voltage = 13 volts


## Example 4.4 : Page No - 132¶

In [4]:
#Given data
RF= 6 # in kΩ
Vout= '-V1+2*V2-3*V3' # Given data data expression or
Vout= '-(V1-2*V2+3*V3)'
# Vout= -(RF/R1*V1+RF/R2*V2+RF/R3*V3)
# Comparing the Vout with the Given data data expression
R1= RF # in kΩ
R2= RF/2 # in kΩ
R3= RF/3 # in kΩ
print "The value of R1 = %0.f kΩ" %R1
print "The value of R2 = %0.f kΩ" %R2
print "The value of R3 = %0.f kΩ" %R3

The value of R1 = 6 kΩ
The value of R2 = 3 kΩ
The value of R3 = 2 kΩ


## Example 4.5 : Page No - 132¶

In [7]:
from __future__ import division
#Given data
R3= 10 # in kΩ
Vout= '-2*V1+3*V2+4*V3' # Given data data expression or
Vout= '-(2*V1-3*V2-4*V3)'
# Vout= -(RF/R1*V1+RF/R2*V2+RF/R3*V3)
# Comparing the Vout with the Given data data expression, we get
RF= 4*R3 # in kΩ
R2= RF/3 # in kΩ
R1= RF/2 # in kΩ
print "The value of R1 = %0.f kΩ" %RF
print "The value of R2 = %0.2f kΩ" %R2
print "The value of R3 = %0.f kΩ" %R1

The value of R1 = 40 kΩ
The value of R2 = 13.33 kΩ
The value of R3 = 20 kΩ


## Example 4.6 : Page No - 133¶

In [8]:
#Given data
V1= 2 # in V
V2= -1 # in V
R=10 # assuming value in kΩ
R1=R # in kΩ
R2= R # in kΩ
R3= R # in kΩ
R4= R # in kΩ
RF= 2*R # in kΩ
Vin1= V1*(R1*R2/(R1+R2))/(R1+(R2*R3/(R2+R3))) # in V
Vout1= Vin1*(1+RF/R1) # in V
Vin2= V2*(R3*R4/(R3+R4))/(R2+(R3*R4/(R3+R4))) # in V
Vout2= Vin2*(1+RF/R2) # in V
Vout= Vout1+Vout2 # in V
print "The output voltage = %0.f volts" %Vout

The output voltage = 1 volts


## Example 4.7 : Page No - 143¶

In [10]:
from numpy import pi
#Given data
R1= 10 # in kΩ
CF= 0.1 # in micro F
CF= CF*10**-6 # in F
RF= 10*R1 # in kΩ
RF= RF*10**3 # in Ω
fa= 1/(2*pi*RF*CF) # in Hz
print "Limiting frequency = %0.2f Hz" %fa

Limiting frequency = 15.92 Hz


## Example 4.8 : Page No - 145¶

In [17]:
#Given data
f=10 # in kHz
f=f*10**3 # in Hz
dcGain= 10
fa= f/10 # in Hz
R1= 10 # in kΩ
# Formula dcGain= RF/R1
RF= R1*dcGain # in kΩ
RF=RF*10**3 # in Ω
R1= R1*10**3 # in Ω
# Formula fa= 1/(2*pi*RF*CF)
CF= 1/(2*pi*RF*fa) # in F
CF=CF*10**10 # in nF
Rcomp= R1*RF/(R1+RF) # in Ω
print "The value of CF = %0.f nF" %CF
print "The value of Rcomp = %0.2f kΩ" %(Rcomp*10**-3)

The value of CF = 16 nF
The value of Rcomp = 9.09 kΩ


## Example 4.9 : Page No - 145¶

In [19]:
#Given data
Vin=5 # in V
R1= 1 # in kΩ
R1= R1*10**3 # in Ω
CF= 0.1 # in µF
CF= CF*10**-6 # in F
f= 1 # in kHz
f= f *10**3 # in Hz
T= 1/f # in sec
delta_Vout= Vin*T/(2*R1*CF) # in V
print "The maximum change in output voltage = %0.f volts" %delta_Vout
S= 2*pi*f*Vin # in V/sec
print "The minimum slew rate required = %0.5f V/micro-sec" %(S*10**-6)

The maximum change in output voltage = 25 volts
The minimum slew rate required = 0.03142 V/micro-sec


## Example 4.10 : Page No - 146¶

In [21]:
from math import log10, sqrt
#Given data
R_F = 1.2 # in M ohm
R_F = R_F * 10**6 # in ohm
C_F = 10 # in nF
C_F = C_F * 10**-9 # in F
f_a = 1/(2*pi*R_F*C_F) # in Hz
print "The safe frequency = %0.2f Hz" %f_a
R1 = 120 # in k ohm
R1 = R1 * 10**3 # in ohm
A = R_F/R1
AindB= 20*log10(A) # in dB
print "The d.c gain = %0.f dB" %AindB
f = 10 # in kHz
f = f * 10**3 # in Hz
A = (R_F/R1)/(sqrt( 1+ ((f/f_a)**2) ))
V_in_peak = 5 # in V
V_out_peak = V_in_peak*A # in V
print "The peak of output voltage = %0.f mV" %(V_out_peak*10**3)

The safe frequency = 13.26 Hz
The d.c gain = 20 dB
The peak of output voltage = 66 mV


## Example 4.11 : Page No - 147¶

In [22]:
#Given data
Vrms= 10 # in mV
f= 2*10**3 # in kHz
C= 2*10**-6 # in F
R= 50*10**3 # in ohm
SF= -1/(C*R) # scale factor
#Vout= -1/(R*C)*sqrt(2)*Vrms*integrate('sind(2*pi*f*t)','t',0,t) # in mV
#Vout= 1/(R*C)*sqrt(2)*Vrms/(2*pi*f)*(cos(4000*t)-1) # in mV
V= 1/(R*C)*sqrt(2)*Vrms/(2*pi*f) # (assumed)
print "Output voltage in mV is : ",round(V,4),"*(cos(4000 *t)-1) mV"

Output voltage in mV is :  0.0113 *(cos(4000 *t)-1) mV


## Example 4.12 : Page No - 147¶

In [24]:
#Given data
Vin=10 # in V
R= 2.2 # in kΩ
R= R*10**3 # in Ω
T= 1 # in ms
T= T*10**-3 # in sec
C= 1 # in µF
C= C*10**-6 # in F
gain= 10**5 # differential voltage gain
I= Vin/R # in A
V= I*T/C # in V
print "The capacitor voltage at the end of the pulse = %0.3f volts" %V
RC_desh= R*C*gain # in sec
print "The closed loop time constant = %0.f sec" %RC_desh

The capacitor voltage at the end of the pulse = 4.545 volts
The closed loop time constant = 220 sec


## Example 4.13 : Page No - 148¶

In [25]:
#Given data
GaindB= 20 # peak gain in dB
Gain= 10**(GaindB/20)
C= 0.01 # in µF
C= C*10**-6 # in F
# Formula omega= 1/(C*RF)
RF= 1/(C*omega) # in Ω
R1= RF/Gain # in Ω
print "The value of RF = %0.f kΩ" %(RF*10**-3)
print "The value of R1 = %0.f kΩ" %(R1*10**-3)

The value of RF = 10 kΩ
The value of R1 = 1 kΩ


## Example 4.14 : Page No - 148¶

In [1]:
%matplotlib inline
import numpy as np
from sympy import symbols
import matplotlib.pyplot as plt
from matplotlib.pylab import plot, show, ylim, xlim, text, subplot
a= symbols('a')
# Given data
R= 40 # in kΩ
R= R*10**3 # in Ω
C= 0.2 # in µF
C= C*10**-6 # in F
Vin= 5 # in V
V1= 3 # in V
t= 50 # in ms
Vout= 3 # in V
# Evaluation the integration
def integrand(x):
return (Vin-V1)
a=1
ans, err = quad(integrand, 0, 50)
# Output voltage when swith is open
vout= -1/(R*C)*ans*10**-3+Vout #in V
plt.plot([0,t],[Vout,vout])
plt.title('Output voltage')
plt.xlabel('Time in milliseconds')
plt.ylabel('Output voltage in volts')
plt.show()
print "The value of Vout = %0.1f" %vout
print "Plot for output voltage shown in figure"

The value of Vout = -9.5
Plot for output voltage shown in figure


## Example 4.15 : Page No - 149¶

In [30]:
from scipy.integrate import quad
import numpy as np
# Given data
R= 500 # in kΩ
R= R*10**3 # in Ω
C= 10 # in µF
C= C*10**-6 # in F
vout= 12 # in V
v= -0.5 # in V
# given output equation : vout= -1/RC * integrate[v(t) * dt + A]
# Evaluation the integration
def integrand(t):
return -t
ans, err = quad(integrand, 0, 1)
vout_by_t= -1/(R*C)*ans #in V/sec
# Time required for saturation of output voltage
t= vout/vout_by_t # in sec
print "The time duration required for saturation of output voltage = %0.f seconds" %t

The time duration required for saturation of output voltage = 120 seconds


## Example 4.16 : Page No - 150¶

In [31]:
#Given data
C_F = 10 # in µF
C_F = C_F * 10**-6 # in F
R1 = 1/C_F # in ohm
R1 = R1 * 10**-3 # in k ohm
print "The value of R1 = %0.f kΩ" %R1
R2 = 1/(C_F*2) # in ohm
R2 = R2 * 10**-3 # in k ohm
print "The value of R1 = %0.f kΩ" %R2
R3 = 1/(C_F*5) # in ohm
R3 = R3 * 10**-3  # in k ohm
print "The value of R1 = %0.f kΩ" %R3

The value of R1 = 100 kΩ
The value of R1 = 50 kΩ
The value of R1 = 20 kΩ


## Example 4.17 : Page No - 158¶

In [33]:
#Given data
f_max = 150 # in Hz
f_a = f_max # in Hz
print "The value of f_a = %0.f Hz" %f_a
C1 = 1 # in µF
C1 = C1 * 10**-6 # in F
R_F = 1/(2*pi*f_a*C1) # in ohm
print "The value of R_F = %0.2f kΩ" %(R_F*10**-3)
f_b = 10*f_a # in Hz
R1 = 1/(2*pi*f_b*C1) # in ohm
C_F = (R1*C1)/R_F # in F
print "The value of C_F = %0.1f µF" %(C_F*10**6)
R_comp = (R1*R_F)/(R1+(R_F)) # in ohm
print "The value of R_comp = %0.2f Ω" %R_comp

The value of f_a = 150 Hz
The value of R_F = 1.06 kΩ
The value of C_F = 0.1 µF
The value of R_comp = 96.46 Ω


## Example 4.18 : Page No - 158¶

In [34]:
from sympy import symbols, sin
t , pi = symbols('t pi')
#Given data
Vmax= 10 # in µV
f= 2*10**3 # in kHz
#Vin= Vmax*sin(2*pi*f*t) # in µV
Vin = (Vmax*sin(2*pi*f*t)) # in mV
#print "The input voltage is "+string(Vmax)+"*sin ("+string(2*f)+"pi*t) "
print " The input voltage = ",Vin,"µV"

 The input voltage =  10*sin(4000*pi*t) µV


## Example 4.19 : Page No - 159¶

In [2]:
from __future__ import division
%matplotlib inline
from sympy import symbols, simplify, sin
import matplotlib.pyplot as plt
import numpy as np
# Given data
fa= 1 # in kHz
fa=fa*10**3 # in Hz
Vp=1.5 # in volt
f= 200 # in Hz
C=0.1 # in micro F
C=C*10**-6 # in F
R= 1/(2*np.pi*fa*C) # in ohm
R=R*10**-3 # in k ohm
R=np.floor(R*10)/10 # in k ohm
fb= 20*fa # in Hz
R_desh= 1/(2*np.pi*fb*C) # in ohm
# Let
R_desh= 82 # in ohm
R_OM= R # in k ohm
print "Value of R_OM = %0.1f k ohm" %R_OM
CR= C*R
# Vin= Vp*sin(omega*t)= 1.5*sin(400*t)
# v_out= -CR*diff(v_in) = -0.2827 Cos(400*pi*t)# in micro volt
print "Output Voltage = -0.2827 Cos(400*pi*t)"
t = np.arange(0, .015, 1.0/44100)
v_out=-0.2827*np.sin(400*np.pi*t+np.pi/2)# in micro volt
plot(t,v_out)
plt.title('Output Voltage Waveform')
plt.xlabel('Time in ms')
plt.ylabel('Vout in Volts')
print "Output Voltage waveform is shown in figure."

Value of R_OM = 1.5 k ohm
Output Voltage = -0.2827 Cos(400*pi*t)
Output Voltage waveform is shown in figure.


## Example 4.20 : Page No - 171¶

In [37]:
from __future__ import division
#Given data
R2 = 100 # in ohm
R1 = 200 # in ohm
R_F = 100 # in k ohm
R_F = R_F * 10**3 # in ohm
R_G = 100 # in ohm
Gain_max = ( 1+((2*R_F)/R_G) ) * (R2/R1)
R = 100 # in  k ohm
R_G1 = 0.01+R # in k ohm
R_G1 = R_G1 * 10**3 # in ohm
Gain_min = ( 1+((2*R_F)/R_G1) ) * (R2/R1)
print "The gain can be varied from ",round(Gain_min,1)," to ",round(Gain_max,1)

#Note : In the book the value of maximum gain is not accurate

The gain can be varied from  1.5  to  1000.5


## Example 4.21 : Page No - 172¶

In [38]:
#Given data
R1 = 100 # in k ohm
R2 = 100 # in k ohm
R_F = 470 # in k ohm
Gain = 100
R_G = (2*R_F)/(Gain-1) # in ohm
print "The value of R_G = %0.2f ohm" %R_G

The value of R_G = 9.49 ohm


## Example 4.22 : Page No - 174¶

In [40]:
#Given data
R = 100 # in ohm
T = 25 # in degree C
alpha = 0.00392
R1 = R*(1+(alpha*T)) # in ohm
expression= 'R_T= Ro*[1+alpha*T]'
print "The expression for the resistance at T°C : R_T= Ro*[1+alpha*T]"
print "The transducer resistance at 25°C = %0.1f Ω" %R1
T = 100 # in degree C
R2 = R*(1+(alpha*T)) # in ohm
print "The transducer resistance at 100°C = %0.1f Ω" %R2

The expression for the resistance at T°C : R_T= Ro*[1+alpha*T]
The transducer resistance at 25°C = 109.8 Ω
The transducer resistance at 100°C = 139.2 Ω


## Example 4.23 : Page No - 176¶

In [41]:
#Given data
R3 = 1 # in k ohm
R4 = 1 # in k ohm
R_min = R4/R3
R_4 = 50 # in k ohm
R_max = (R_4+R4)/R3
R2 = 10 # in k ohm
A_F = 5
R1 = (((A_F/R_min)-1)*R2)/2 # in k ohm
print "The value of R1 = %0.f kΩ" %R1
print "The value of R2 = %0.f kΩ" %R2

The value of R1 = 20 kΩ
The value of R2 = 10 kΩ


## Example 4.24 : Page No - 177¶

In [43]:
#Given data
R1= 100 # in kΩ
R2=200 # in kΩ
R3= 20 # in kΩ
R4=40 # in kΩ
#Vout= [1+R2/R1]*[R4/(R3+R4)]*Vin1-R2/R1*Vin2
A=(1+R2/R1)*(R4/(R3+R4)) # (assumed)
print "Output voltage =",int(A),"*(Vin1-Vin2)"

Output voltage = 2 *(Vin1-Vin2)


## Example 4.25 : Page No - 177¶

In [44]:
#Given data
R_F = 5 # in  k ohm
R_G = 1 # in  k ohm
R1 = 10 # in  k ohm
R2 = 20 # in  k ohm
A = (1 + ((2*R_F)/R_G))*(R2/R1)
print "The gain of instrumentaion amplifier = %0.f" %A

The gain of instrumentaion amplifier = 22


## Example 4.27 : Page No - 178¶

In [46]:
#Given data
R_F = 10 # in  k ohm
R_G = 5 # in  k ohm
R1 = 1 # in  k ohm
R2 = 2 # in  k ohm
A = (1+ ((2*R_F)/R_G))*(R2/R1)
V_in2 = 2 # in mV
V_in1 = 1 # in mV
V_out = A*(V_in2-V_in1) # in mV
print "The output voltage = %0.f mV" %V_out

The output voltage = 10 mV


## Example 4.28 : Page No - 178¶

In [47]:
#Given data
V_out = 3 # in V
V_in2 = 5 # in mV
V_in1 = 2 # in mV
V1 = V_in2-V_in1 # in mV
V1 = V1 * 10**-3 # in V
A = V_out/V1
R_F = 15 # in  k ohm
R1 = 1 # in  k ohm
R2 = 2 # in  k ohm
R = R2/R1 # in k  ohm
R_G = (2*R_F)/((A/R)-1) #in  k ohm
R_G = R_G * 10**3 # in ohm
print "The value of R_G = %0.2f Ω" %R_G

The value of R_G = 60.12 Ω


## Example 4.31 : Page No - 182¶

In [48]:
#Given data
A=10000
R1= 100 # in kΩ
A2= 1/5 # (assumed value)
R2= R1/A2 # in kΩ
# A= A1*A2 and A1= 1+2*RF/R_GB
RFbyR_GB= (A/A2-1)/2
# [1+2*RF/RG]*A2= 1 and RG= RGB+100 kΩ
R_G= (1-1/A2)/2*100/((1/A2-1)/2-RFbyR_GB) # in kΩ
R_F= RFbyR_GB*R_G # in kΩ
print "The value of R_G = %0.f Ω" %(R_G*10**3)
print "The value of R_F = %0.f kΩ" %R_F
print "This is the base resistance required in series with the pot of 100 kΩ"

The value of R_G = 8 Ω
The value of R_F = 200 kΩ
This is the base resistance required in series with the pot of 100 kΩ