# Chapter 1 - Operational Amplifiers¶

## Exa 1.1 - page 11¶

In :
# Given data
G= -100
R1= 2.2 # in kohm
R1=R1*10**3 # in ohm
# Formula G=-Rf/R1
Rf= -G*R1
print "The value of Rf = %0.f kohm " %(Rf*10**-3)

The value of Rf = 220 kohm


## Exa 1.2 - page 11¶

In :
# Given data
Rf= 200 # in kohm
R1= 2 # in kohm
vin=2.5 # in mV
vin=vin*10**-3 # in volt
G= -Rf/R1
vo= G*vin # in V
print "The output voltage = %0.2f Volt " %vo

The output voltage = -0.25 Volt


## Exa 1.3 - page 12¶

In :
# Given data
G=-10
Ri= 100 # in kohm
R1= Ri # in kohm
R1=R1*10**3 # in ohm
# Formula G=-R2/R1
R2= R1*abs(G) # ohm
print "Value of R1 = %0.f kohm " %(R1*10**-3)
print "and value of R2 = %0.f Mohm " %(R2*10**-6)

Value of R1 = 100 kohm
and value of R2 = 1 Mohm


## Exa 1.4 - page 37¶

In :
# Given data
R1= 100 # in kohm
R2= 500 # in kohm
V1= 2 # in volt
Vo= (1+R2/R1)*V1 # in volt
print "Output voltage for noninverting amplifier = %0.f Volt" %Vo

Output voltage for noninverting amplifier = 12 Volt


## Exa 1.5 - page 38¶

In :
from __future__ import division
# Given data
Rf= 1 # in Mohm
Rf=Rf*10**6 #in ohm

# Part(a)
V1=1 #in volt
V2=2 #in volt
V3=3 #in volt
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
Vo= -Rf*(V1/R1+V2/R2+V3/R3) # in volt
print "(a) Output voltage = %0.f Volt " %Vo

# Part(b)
V1=-2 #in volt
V2=3 #in volt
V3=1 #in volt
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
Vo= -Rf*(V1/R1+V2/R2+V3/R3) # in volt
print "(b) Output voltage = %0.f Volt" %Vo

(a) Output voltage = -7 Volt
(b) Output voltage = 3 Volt


## Exa 1.6 - page 38¶

In :
from __future__ import division
# Given data
print "Minimum closed loop voltage gain for R2=0 and R1= 2 kohm"
R2=0
R1=2 # in kohm
R1=R1*10**3 # in ohm
Av_min= (1+R2/R1)
print "Av(min) =",Av_min

print "Maximum closed loop voltage gain for maximum value of R2=100 kohm and R1= 2 kohm"
R2=100 # in kohm
R1=2 # in kohm
Av_max= (1+R2/R1)
print "Av(max) =",Av_max

Minimum closed loop voltage gain for R2=0 and R1= 2 kohm
Av(min) = 1.0
Maximum closed loop voltage gain for maximum value of R2=100 kohm and R1= 2 kohm
Av(max) = 51.0


## Exa 1.7 - page 39¶

In :
from __future__ import division
# Given data
V1= 745 # in µV
V2= 740 # in µV
V1=V1*10**-6 # in volt
V2=V2*10**-6 # in volt
CMRR=80 # in dB
Av=5*10**5
# (i)
# (ii)
print "Output voltage = %0.2f Volt" %Vo

# Note:- In the book, there is calculation error to evaluate the value of Ac,
#so the value of Ac is wrong ans to evaluate the output voltage there is also calculation error

Output voltage = 2.54 Volt


## Exa 1.8 - page 40¶

In :
from __future__ import division
# Given data
R1= 1 # in Mohm
Ri=R1 # in Mohm
Rf=1 # in Mohm
A_VF= -Rf/R1
print "Voltage gain = %0.f" %A_VF

Voltage gain = -1


## Exa 1.10 - page 41¶

In :
from __future__ import division
# Given data
V1=2 # in V
V2=3 # in V
Rf=3 # in kohm
R1=1 # in kohm
Vo1= (1+Rf/R1)*V1
print "Output voltage when only 2V voltage source is acting is %0.f Volt" %Vo1
Vo2= (1+Rf/R1)*V2
print "Output voltage due to 3V voltage source is %0.f Volt" %Vo2
Vo= Vo1+Vo2 # in volts
print "Total output voltage is %0.f Volts" %Vo

Output voltage when only 2V voltage source is acting is 8 Volt
Output voltage due to 3V voltage source is 12 Volt
Total output voltage is 20 Volts


## Exa 1.11 - page 42¶

In :
from __future__ import division
# Given data
Rf=500 # in kohm
min_vvs= 0 # minimum value of variable resistor in ohm
max_vvs= 10 # maximum value of variable resistor in ohm
Ri_min= 10+min_vvs # in kohm
Ri_max= 10+max_vvs #in kohm
# Av= Vo/Vi= -Rf/Ri
Av=-Rf/Ri_min
print "Closed loop voltage gain corresponding to Ri(min) is",Av
Av=-Rf/Ri_max
print "and closed loop voltage gain corresponding to Ri(max) is",Av

Closed loop voltage gain corresponding to Ri(min) is -50.0
and closed loop voltage gain corresponding to Ri(max) is -25.0


## Exa 1.12 - page 43¶

In :
# Given data
Rf=200 # in kohm
R1= 20 # in kohm
# Av= Vo/Vi= -Rf/Ri
Av= -Rf/R1
Vi_min= 0.1 # in V
Vi_max= 0.5 # in V
# Vo= Av*Vi
Vo_min= Av*Vi_min # in V
Vo_max= Av*Vi_max # in V
print "Output voltage ranges from",Vo_min,"V to",Vo_max,"V"

Output voltage ranges from -1.0 V to -5.0 V


## Exa 1.13 - page 43¶

In :
from __future__ import division
# Given data
Rf= 250 # in kohm
# Output voltage expression, Vo= -5*Va+3*Vb
# and we know that for a difference amplifier circuit,
# Vo= -Rf/R1*Va + [R2/(R1+R2)]*[1+Rf/R1]*Vb
# Comparing both the expression, we get
# -Rf/R1*Va= -5*Va, or
R1= Rf/5 # in kohm
print "The value of R1 = %0.2f kohm" %R1
# and
R2= 3*R1**2/(R1+Rf-3*R1)
print "The value of R2 = %0.2f kohm" %R2

# Note : Answer in the book is wrong

The value of R1 = 50.00 kohm
The value of R2 = 50.00 kohm


## Exa 1.14 - page 44¶

In :
# Given data
Vi_1= 150 # in µV
Vi_2= 140 # in µV
Vd= Vi_1-Vi_2 # in µV
Vd=Vd*10**-6 # in V
Vc= (Vi_1+Vi_2)/2 # in µV
Vc=Vc*10**-6 # in V

# (i) For Ad=4000 and CMRR= 100
CMRR= 100
print "(a) Output voltage = %.1f mV" %(Vo*10**3)

# (ii) For Ad=4000 and CMRR= 10**5
CMRR= 10**5
print "(b) Output voltage = %0.1f mV" %(Vo*10**3)

(a) Output voltage = 45.8 mV
(b) Output voltage = 40.0 mV


## Exa 1.15 - page 45¶

In :
from __future__ import division
# Given data
Rf=470 # in kohm
R1=4.3 # in kohm
R2=33 # in kohm
R3=33 # in kohm
Vi= 80 # in µV
Vi=Vi*10**-6 # in volt
A1= 1+Rf/R1
A2=-Rf/R2
A3= -Rf/R3
A=A1*A2*A3
Vo= A*Vi # in volt
print "Output voltage = %0.2f Volts" %Vo

Output voltage = 1.79 Volts


## Exa 1.16 - page 46¶

In :
from sympy import symbols, simplify, sin
t = symbols('t')
# Given data
R1= 33 # in kΩ
R2= 10 # in kΩ
R3= 330 # in kΩ
V1 = simplify(50*sin(1000*t)) # in mV
V2 = simplify(10*sin(3000*t)) # in mV
Vo = -(R3/R1*V1+R3/R2*V2)/1000  # in V
print "Output voltage is",Vo

Output voltage is -0.5*sin(1000*t) - 0.33*sin(3000*t)


## Exa 1.17 - page 47¶

In :
from __future__ import division
# Given data
R1=10 # in kohm
R2=150 # in kohm
R3=10 # in kohm
R4=300 # in kohm
V1= 1 # in V
V2= 2 # in V
Vo= ((1+R4/R2)*(R3*V1/(R1+R3))-(R4/R2)*V2)
print "Output voltage = %0.2f Volts" %Vo

Output voltage = -2.50 Volts


## Exa 1.18 - page 47¶

In :
from __future__ import division
# Given data
R1=12 # in kohm
Rf=360 # in kohm
V1= -0.3 # in V
Vo= (1+Rf/R1)*V1 # in V
print "(a) Output voltage result in %0.2f Volts" %Vo

# Part(b)
Vo= 2.4 # in V
# We know, Vo= (1+Rf/R1)*V1
V1= Vo/(1+Rf/R1)
print "(b) To result in an output of 2.4 Volt, Input voltage = %0.2f mV" %(V1*10**3)

(a) Output voltage result in -9.30 Volts
(b) To result in an output of 2.4 Volt, Input voltage = 77.42 mV


## Exa 1.19 - page 48¶

In :
from __future__ import division
# Given data
Rf=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
Vo= -Rf/R1*V1 + (-Rf/R2)*V2 + (-Rf/R3)*V3 # in volts
print "Output voltage = %0.3f Volts" %Vo
#Answer in the textbook is not accurate.

Output voltage = -3.400 Volts


## Exa 1.20 - page 48¶

In :
from __future__ import division
# Given data
Rf=100 # in kohm
R1=20 # in kohm
V1= 1.5 # in V
Vo1= V1
Vo= -Rf/R1*Vo1 # in volts
print "Output voltage = %0.2f Volts" %Vo

Output voltage = -7.50 Volts


## Exa 1.22 - page 50¶

In :
from __future__ import division
# Given data
vo= -10 # in V
i_f= 1 # in mA
i_f= i_f*10**-3 #in A
# Formula vo= -i_f*Rf
Rf= -vo/i_f # in Ω
# The output voltage, vo= -(v1+5*v2)       (i)
# vo= -Rf/R1*v1 - Rf/R2*v2                     (ii)
# Comparing equations (i) and (2)
R1= Rf/1 # in Ω
R2= Rf/5 # in Ω
print "The value of Rf = %0.2f kΩ" %(Rf*10**-3)
print "The value of R1 = %0.2f kΩ" %(R1*10**-3)
print "The value of R2 = %0.2f kΩ" %(R2*10**-3)

The value of Rf = 10.00 kΩ
The value of R1 = 10.00 kΩ
The value of R2 = 2.00 kΩ


## Exa 1.24 - page 52¶

In :
from __future__ import division
from sympy import symbols
v1,v2 = symbols('v1 v2')
# Given data
R1= 9 # in kΩ
R2= 1 # in kΩ
R3= 2 # in kΩ
R4= 3 # in kΩ
# for node 1
va = R4/(R4+R3)*v1
vo1 = (1+R1/R2)*va
# for node 2
va=R3/(R3+R4)*v2
vo2 = (1+R1/R2)*va
vo = vo1+vo2
print "Total voltage is, vo =",vo

Total voltage is, vo = 6.0*v1 + 4.0*v2


## Exa 1.25 - page 54¶

In :
from __future__ import division
from sympy import symbols
v1,v2,v3 = symbols('v1 v2 v3')
# Given data
R1= 9 # in kΩ
R2= 1 # in kΩ
R3= 2 # in kΩ
R4= 3 # in kΩ
# Voltage at node 1
va= R4*v1/(R3+R4)
vo1= (1+R1/R2)*va
# Voltage at node 2
va= R3*v2/(R3+R4)
# From (i) and (ii)
vo2= (1+R1/R2)*va
# Voltage at node 3
va= R3*v2/(R3+R4)
vo3= (-R1/R2)*v3
vo = vo1+vo2+vo3
print "Total voltage is",vo

Total voltage is 6.0*v1 + 4.0*v2 - 9.0*v3


## Exa 1.26 - page 55¶

In :
# Given data
import numpy as np
from __future__ import division
# omega_t= Ao*omega_b
# 2*pi*f_t = Ao*2*pi*f_b
# f_t= Ao*f_b
# Part (i)
Ao1= 10**5
f_b1= 10**2 # in Hz
f_t1= Ao1*f_b1 # in Hz
row1 = np.array([Ao1,f_b1,f_t1])
# Part (ii)
Ao2= 10**6
f_t2= 10**6 # in Hz
f_b2= f_t2/Ao2 # in Hz
row2 = np.array([Ao2,f_b2,f_t2])
# Part (iii)
f_b3= 10**3 # in Hz
f_t3= 10**8 # in Hz
Ao3= f_t3/f_b3
row3 = np.array([Ao3,f_b3,f_t3])
# Part (iv)
f_b4= 10**-1 # in Hz
f_t4= 10**6 # in Hz
Ao4= f_t4/f_b4
row4 = np.array([Ao4,f_b4,f_t4])
# Part (v)
Ao5= 2*10**5
f_b5= 10 # in Hz
f_t5= Ao5*f_b5 # in Hz
row5 = np.array([Ao5,f_b5,f_t5])
print "-"*33
print "Ao           fb(Hz)       ft(Hz)"
print "-"*33
print "%.e        %.e        %.e" %(row1, row1, row1)
print "%.e        %.f           %.e" %(row2, row5, row2)
print "%.e        %.e        %.e" %(row3, row3, row3)
print "%.e        %.e        %.e" %(row4, row4, row4)
print "%.e        %.f           %.e" %(row5, row5, row5)
# Answer for f_b2 is wrong in the textbook.

---------------------------------
Ao           fb(Hz)       ft(Hz)
---------------------------------
1e+05        1e+02        1e+07
1e+06        10           1e+06
1e+05        1e+03        1e+08
1e+07        1e-01        1e+06
2e+05        10           2e+06


## Exa 1.27 - page 56¶

In :
from __future__ import division
from numpy import sqrt
# Given data
Ao= 86 # in dB
A= 40 # in dB
f=100 # in kHz
f=f*10**3 # in Hz
# From  20*log(S) = 20*log(Ao/A), where S, stands for sqrt(1+(f/fb)**2)
S= 10**((Ao-A)/20)
# S= sqrt(1+(f/fb)**2)
fb= f/sqrt(S**2-1) # in Hz
Ao= 10**(Ao/20)
ft= Ao*fb # in Hz
print "The value of Ao = %0.3e" %Ao
print "The value of fb = %0.f Hz" %fb
print "The value of ft = %0.f MHz" %round(ft*10**-6)

The value of Ao = 1.995e+04
The value of fb = 501 Hz
The value of ft = 10 MHz


## Exa 1.28 - page 56¶

In :
from __future__ import division
from numpy import pi, sqrt
# Given data
Ao= 10**4 # in V/V
f_t= 10**6 # in Hz
R2byR1= 20
omega_t= 2*pi*f_t
omega_3dB= omega_t/(1+R2byR1)
f3dB= omega_3dB/(2*pi) # in Hz
print "3-dB frequency of the closed loop amplifier is %0.1f kHz" %(f3dB*10**-3)
f3dB= 0.1*f3dB # in Hz
voBYvi= -R2byR1/sqrt(1+(2*pi*f3dB/omega_3dB)**2)
voBYvi= abs(voBYvi) # in v/v
print "Gain = %0.1f v/v" %(voBYvi)

3-dB frequency of the closed loop amplifier is 47.6 kHz
Gain = 19.9 v/v