# Chapter - 8 : Operational Amplifiers (OPAMPs)¶

## Example 8.1 : Page No 432¶

In [21]:
from __future__ import division
# Given data
A_V = -100
R1 = 2.2 # in kohm
R1 = R1*10**3 # in ohm
R_f =-( A_V*R1) # in ohm
R_f = R_f * 10**-3 # in kohm
print "The resistance value = %0.f kΩ" %R_f

The resistance value = 220 kΩ


## Example 8.2 : Page No 432¶

In [20]:
# Given data
R_f = 200 # in kohm
R1 = 2 # in kohm
A_V = - (R_f/R1)
V_in = 2.5 # in mV
V_in= V_in*10**-3 # in V
V_o = (A_V * V_in) # in V
print "The output voltage = %0.2f V" %V_o

The output voltage = -0.25 V


## Example 8.3 : Page No 461¶

In [19]:
# Given data
V1 = 2 # in V
R_f = 500 # in kohm
R_f = R_f*10**3 # in ohm
R1 = 100 # in kohm
R1 = R1 * 10**3 # in ohm
V_o = (1+(R_f/R1))*V1 # in V
print "The output voltage = %0.f V" %V_o

The output voltage = 12 V


## Example 8.4 : Page No 461¶

In [18]:
# Given data
R_f = 1 # in Mohm
R_f = R_f * 10**6 # in ohm
print "Part (a)"
V1 = 1 # in V
V2 = 2 # in V
V3 = 3 # in V
R1 = 500 # in kohm
R1 = R1 * 10**3 # in ohm
R2 = 1 # in Mohm
R2 = R2 * 10**6 # in ohm
R3 = 1 # in Mohm
R3 = R3 * 10**6 # in ohm
V_o = -(R_f) * ( (V1/R1)+(V2/R2)+(V3/R3) ) # in V
print "The output voltage = %0.f V" %V_o

print "Part (b)"
V1 = -2 # in V
V2 = 3 # in V
V3 = 1 # in V
R1 = 200 # in kohm
R1 = R1 * 10**3 # in ohm
R2 = 500 # in kohm
R2 = R2 * 10**3 # in ohm
R3 = 1 # in Mohm
R3 = R3 * 10**6 # in ohm
V_o = -(R_f) * ( (V1/R1)+(V2/R2)+(V3/R3) ) # in V
print "The output voltage = %0.f V" %V_o

Part (a)
The output voltage = -7 V
Part (b)
The output voltage = 3 V


## Example 8.6 : Page No 462¶

In [17]:
# Given data
R_f = 0 # in V
R1 = 2 # in kohm
R1 = R1 * 10**3 # in ohm
A_vmin = (1+(R_f/R1))
print "The minimum closed loop voltage gain = %0.f" %A_vmin
R_f1 = 100 # in kohm
R_f1 = R_f1 * 10**3 # in ohm
A_vmax = (1+(R_f1/R1))
print "The maximum closed loop voltage gain = %0.f" %A_vmax

The minimum closed loop voltage gain = 1
The maximum closed loop voltage gain = 51


## Example 8.7 : Page No 463¶

In [16]:
# Given data
V1 = 745 # in µV
V1 = V1 * 10**-6 # in V
V2 = 740 # in µV
V2 = V2 * 10**-6 # in V
Av = 5*10**5
CMRR = 80 # in dB
# Formula CMRR in dB= 20*log(Av/Ac)
Ac= Av/(10**(CMRR/20))
print "The common mode gain = %0.2f" %Ac
V_o = Av*(V1-V2)+Ac*((V1+V2)/2) # in V
print "The output voltage = %0.2f V" %V_o

# Note: In the book the calculation of finding the value of common mode gain  (i.e. Ac) is wrong,
#       so the answer in the book is wrong

The common mode gain = 50.00
The output voltage = 2.54 V


## Example 8.8 : Page No 464¶

In [15]:
# Given data
R_f = 1 # in Mohm
R_f = R_f * 10**6 # in ohm
Ri= 1*10**6 # in ohm
R1 = Ri # in ohm
A_VF = -(R_f/R1)
print "The Voltage gain = %0.f" %A_VF

The Voltage gain = -1


## Example 8.10 : Page No 465¶

In [14]:
# Given data
R_F = 3 # in kohm
R1 = 1 # in  kohm
V1 = 2 # in V
V2 = 3 # in V
V_o1 = (1+(R_F/R1))*V1 # in V
V_o2 = (1+(R_F/R1))*V2 # in V
V_o = V_o1+V_o2 # in V
print "The output voltage = %0.f V" %V_o

The output voltage = 20 V


## Example 8.11 : Page No 466¶

In [13]:
# Given data
R_i = 10 # in kΩ
R_im = 20 # in kΩ
R_f = 500 # in kΩ
A_vmin = -(R_f/R_i)
print "Closed loop voltage gain corresponding to minimum resistance = %0.f" %A_vmin
A_vmax = -(R_f/R_im)
print "Closed loop voltage gain corresponding to maximum resistance = %0.f" %A_vmax

Closed loop voltage gain corresponding to minimum resistance = -50
Closed loop voltage gain corresponding to maximum resistance = -25


## Example 8.12 : Page No 467¶

In [12]:
# Given data
R_f = 200 # in  kohm
R1 = 20 # in kohm
A_v = -(R_f/R1)
V_i = 0.1 # in V
V_im = 0.5 # in V
V_omin = -10*V_i # in V
print "The minimum output voltage = %0.f V" %V_omin
V_omax = -10*V_im # in V
print "The maximum output voltage = %0.f V" %V_omax
print "Output voltage ranges :  from",int(V_omin,),"to",int(V_omax)

The minimum output voltage = -1 V
The maximum output voltage = -5 V
Output voltage ranges :  from -1 to -5


## Example 8.13 : Page No 467¶

In [11]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
# Given data
R = 133 # in kohm
R = R *10**3 # in ohm
C = 0.1 # in µF
C = 0.1 * 10**-6 # in F
Vi= 15 # in V
plt.subplot(2,1,1)
plt.plot([0,10],[1.5,1.5])
plt.ylabel("Vi in volts")
plt.xlabel("t")
plt.title("Input voltage")
t=np.arange(0,1,0.1)
Vo= -1/(R*C)*t
plt.subplot(2,1,2)
plt.plot(t,Vo)
plt.xlabel("t")
plt.ylabel("Vo in volts")
plt.title("Output voltage")
print ""


## Example 8.14 : Page No 468¶

In [10]:
# Given data
Rf = 250 # in kohm
Vo= '-5*Va+3*Vb' # given expression
# But output voltage of difference amplifier is
# Vo= -Rf/R1*Va+(R2/(R1+R2))*(1+Rf/R1)*Vb      (i)
# By comparing (i) with given expression
R1 = Rf/5 # in kohm
print "The value of R1 = %0.f kΩ" %R1
# (R2/(R1+R2))*(1+Rf/R1)= 3
R2= 3*R1**2/(R1+Rf-3*R1) # in kΩ
print "The value of R2 = %0.f kΩ" %R2

# Note: There is calculation error to find the value of R2 in the book.

The value of R1 = 50 kΩ
The value of R2 = 50 kΩ


## Example 8.15 : Page No 469¶

In [9]:
# Given data
V_i1 = 150 # in µV
V_i2 = 140 # in µV
V_d = V_i1-V_i2 # in µV
V_C = (1/2)*(V_i1+V_i2) # in µV
print "Part (i)"
CMRR = 100
A_d = 4000
V_o = (A_d * V_d)*(1+(1/CMRR)*(V_C/V_d)) # in µV
V_o = V_o * 10**-3 # in mV
print "The output voltage = %0.1f mV" %V_o
print "Part(ii)"
CMRR = 10**5
V_o = (A_d * V_d)*(1+(1/CMRR)*(V_C/V_d)) # in µV
V_o = V_o * 10**-3 # in mV
print "The output voltage = %0.3f mV" %V_o

Part (i)
The output voltage = 45.8 mV
Part(ii)
The output voltage = 40.006 mV


## Example 8.16 : Page No 470¶

In [8]:
# Given data
R_f = 470 # in kΩ
R1 = 4.3 # in kΩ
R2 = 33 # in kΩ
R3 = R2 # in kΩ
A1 = (1+R_f/R1)
A2 = -(R_f/R2)
A3 = -(R_f/R3)
A = A1*A2*A3
V_i = 80 # in µV
V_i= 80*10**-6 # in V
V_o = A*V_i
print "The output voltage = %0.2f V" %V_o

The output voltage = 1.79 V


## Example 8.18 : Page No 472¶

In [7]:
# Given data
R4 = 300 # in kΩ
R2 = 150 # in kΩ
R3 = 10 # in kΩ
R1 = 10 # in kΩ
V1 = 1 # in V
V2 = 2 # in V
V_o = ( (1+(R4/R2))*((R3/(R1+R3))*V1)-((R4/R2)*V2) ) # in V
print "The output voltage = %0.1f V" %V_o

The output voltage = -2.5 V


## Example 8.19 : Page No 472¶

In [6]:
# Given data
V_o = 2 # in V
R_i = 20 # in kΩ
R_f = 1 # in MΩ
V_i = -((V_o*R_i)/R_f) # in mV
print "The input volatge = %0.f mV" %V_i

The input volatge = -40 mV


## Example 8.20 : Page No 473¶

In [5]:
# Given data
R_f = 200 # in kΩ
R_i = 30 # in kΩ
V_i = 0.1 # in V
V_im = 0.5 # in V
Vo_min = -((R_f/R_i)*V_i) # in V
print "The minimum output voltage = %0.2f V" %Vo_min
Vo_max = -((R_f/R_i)*V_im) # in V
print "The minimum output voltage = %0.2f V" %Vo_max
print "The output voltage range is : ",round(Vo_min,2),"V to",round(Vo_max,2),"V"

The minimum output voltage = -0.67 V
The minimum output voltage = -3.33 V
The output voltage range is :  -0.67 V to -3.33 V


## Example 8.21 : Page No 473¶

In [4]:
# Given data
R_f = 360 # in kohm
R_i = 12 # in kohm
V1 = - 0.3 # in V
V_o = (1+(R_f/R_i))*V1 # in V
print "The output voltage = %0.1f V" %V_o
V_o1 = 2.4 # in V
V_i = V_o1/(1+(R_f/R_i)) # in V
print "The input voltage = %0.2f mV" %(V_i*10**3)

The output voltage = -9.3 V
The input voltage = 77.42 mV


## Example 8.22 : Page No 474¶

In [3]:
# Given data
R_f = -68 # in kohm
R1 = 33 # in kohm
R2 = 22 # in kohm
R3 = 12 # in kohm
V1 = 0.2 # in V
V2 = - 0.5 # in V
V3 = 0.8 # in V
V_o = ((R_f/R1)*V1) + ((R_f/R2)*V2) + ((R_f/R3)*V3) # in V
print "The output voltage = %0.3f V" %V_o

The output voltage = -3.400 V


## Example 8.23 : Page No 475¶

In [2]:
# Given data
R_f = 1.8 # in kohm
R_f = R_f * 10**3 # in ohm
R1 = 180 # in ohm
A_v = (R_f/R1)
print "Closed loop gain = %0.f" %A_v
F = 1 # in MHz
F = F * 10**6 # in Hz
f2 = F/A_v # in Hz
print "Closed loop bandwidth = %0.f Hz" %f2
V_in = 25 # in mV
V_in = V_in * 10**-3 # in V
V_o = A_v*V_in # in V
print "The output voltage = %0.2f V" %V_o

Closed loop gain = 10
Closed loop bandwidth = 100000 Hz
The output voltage = 0.25 V


## Example 8.24 : Page No 475¶

In [1]:
from __future__ import division
# Given data
R_f = 3 # in K ohm
R_f = R_f * 10**3 # in ohm
R1 = 150 # in ohm
A_v = (R_f/R1) + 1
print "Close loop gain for inverting amplifier = %0.f" %A_v
f = 1 # in MHz
f = f * 10**6 # in Hz
f2 = f/A_v # in Hz
f2 = f2 * 10**-3 # in KHz
print "The closed loop bandwidth = %0.2f KHz" %f2

Close loop gain for inverting amplifier = 21
The closed loop bandwidth = 47.62 KHz