# Chapter 6 Applications of Operational Amplifier¶

## Example 6.1 Pg 140¶

In [1]:
# Design an inverting amplifier
Av = -5 #
#V1 = 0.1 sin wt #
V1 = 0.1   # # *sin wt #
i = 5*10**-6 #

# the input resistance
R1 = V1/i / 1000 # kohm
print 'the input resistance is = %0.2f'%R1,'kohm'#

# The resistance R2
#Av = -(R2/R1)#
R2 = -(Av*R1)#
print 'The resistance R2 is = %0.2f'%R2,'kohm'#

the input resistance is = 20.00 kohm
The resistance R2 is = 100.00 kohm


## Example 6.2 Pg 141¶

In [2]:
# Design an non inverting amplifier
Av = 5 #
#V1 = 0.1 sin wt #
V1 = 0.1 #
i = -5*10**-6 #

# the input resistance
R1 = -V1/i/1000 # kohm
print 'the input resistance is = %0.2f'%R1,'kohm'#

# The resistance R2
#Av = 1+(R2/R1)#
R2 = (Av-1)*R1#
print 'The resistance R2 is = %0.2f'%R2,'kohm'#

the input resistance is = 20.00 kohm
The resistance R2 is = 80.00 kohm


## Example 6.3 Pg 146¶

In [3]:
from math import atan ,degrees,pi
# To calculate phase shift between two extremes
C = 0.22*10**-6 #
R = 1*10**3 #
f = 1*10**3 #

# the cut off frequency of phase shifter
fc = 1/(2*pi*R*C) #
print 'the cut off frequency of phase shifter is = %0.2f'%fc,'Hz'#
f
# the phase shift
f = 1 # # KHz
fc = 7.23 #  # KHz
PS = -2*degrees(atan(f/fc))
print 'The phase shift is = %0.2f'%PS

the cut off frequency of phase shifter is = 723.43 Hz
The phase shift is = -15.75


## Example 6.4 Pg 146¶

In [4]:
# To design a phase shifter
f = 2*10**3 #
PS = -135 #
# the phase shift
# PS = -2*atand(2*pi*R*C)#
#RC = 192.1*10**-6 #
C = 0.1*10**-6 #
R = (192.1*10**-6)/C/1000 # kohm
print 'The value of resistance is = %0.2f'%R,'kohm'#

The value of resistance is = 1.92 kohm


## Example 6.5 Pg 153¶

In [5]:
# Design a difference amplifier
Ri = 50 # kohm

R1 = Ri/2 #
print 'The value of resistance R1 is = %0.2f'%R1,'kohm'#
R3 = R1 #
print 'The value of resistance R3 is = %0.2f'%R3,'kohm'#

# the differential gain
R2 = 30*R1 #
print 'The value of resistance R2 is = %0.2f'%R2,'kohm'#

R4 = R2 #
print 'The value of resistance R4 is = %0.2f'%R4,'kohm'#

The value of resistance R1 is = 25.00 kohm
The value of resistance R3 is = 25.00 kohm
The value of resistance R2 is = 750.00 kohm
The value of resistance R4 is = 750.00 kohm


## Example 6.6 Pg 154¶

In [6]:
from math import log10
# Calculate CMRR ratio
Acm = 0.48 #

# the common mode rejection ratio CMRR is defined as
print 'The common mode rejection ratio is = %0.2f'%CMRRdB,' dB'

The common mode rejection ratio is = 26.58  dB


## Example 6.7 Pg 156¶

In [7]:
from __future__ import division
# Design current to voltage converter
Vo =-10 #
Is = 100*10**-6 #

# the output voltage of current to voltage converter is defined as
#Vo =-1s*R2
R2 = -Vo/Is/1000 #kohm
print ' The feedback resistance is = %0.2f'%R2,'kohm'#

R1 = R2 #
print ' The value of resistance R1 is = %0.2f'%R1,'kohm'#

 The feedback resistance is = 100.00 kohm
The value of resistance R1 is = 100.00 kohm


## Example 6.8 Pg 157¶

In [8]:
from __future__ import division
# Design high sensitivity current to voltage converter
R1 = 5 # kohm
Is = 1 #
KR = 0.01/10**9 #  #    V / nA

# the output voltage of high sensitivity current to voltage converter
Vo =-KR*Is #
KR = 10*10**6 #
R = 1*10**6 #   #we assume   then
K = 10 #
#1 + (R2/R1)+(R2/R) = 10 #
# solving above equation we get

R2 = 9*((5*10**6)/(10**3+5))/1000 # kohm
print 'The value of resistance R2 is = %0.2f'%R2,'kohm'#

The value of resistance R2 is = 44.78 kohm


## Example 6.9 Pg 160¶

In [9]:
from __future__ import division
# Determine a load current in a V to I converter
R1 = 10 # kohm
R2 = 10  # koohm
R3 = 1 # kohm
R4 = 1 # kohm
VI = -5 #

iL = -VI/R3 #
print 'The load current iL is = %0.2f'%iL,'mA'#

VL = 0.5 #
# The  Current i3 and iA
i3 = VL/R3 #
print 'The current i3 is = %0.2f'%i3,'mA'#

iA = i3+iL #
print 'The current iA is = %0.2f'%iA,'mA'#

# the output voltage
Vo = (iA*R3)+VL #
print 'The output voltage is = %0.2f'%Vo,' V'#

ZL =100 #
# The current i1 and i2
#i1 = (VI-iL*ZL)/R1 #
i1 = (iL*ZL-Vo)/R2 #
print 'The current i1 is = %0.2f'%i1,' A'#

i2 = i1 #
print 'The current i2 is = %0.2f'%i2,' A'#

The load current iL is = 5.00 mA
The current i3 is = 0.50 mA
The current iA is = 5.50 mA
The output voltage is = 6.00  V
The current i1 is = 49.40  A
The current i2 is = 49.40  A


## Example 6.10 Pg 163¶

In [10]:
from __future__ import division
# Design an instrumentation amplifier
#A = 5 to 500 #  adjustable gain
VR = 100*10**3 #

# the maximum differential gain of instrumentation amplifier is 500
#Amax = (R4/R3)*(1+(2R2/R1))#
#by solving above equation we get following equation
# 2R2 -249R1f = 0                                                  equation 1

# the minimum differential gain of instrumentation amplifier is 5
# Amin = (R4/R3)*(1+(2R2/R1)) #
#by solving above equation we get following equation
# 2R2 -1.5R1f = 150*10**3                                           equation 2

#by solving equation 1 and 2 we get
print 'The value of resistance R1f is = 0.0606 K ohm '#

print 'The value of resistance R2 is = 75.5 K ohm '#

The value of resistance R1f is = 0.0606 K ohm
The value of resistance R2 is = 75.5 K ohm


## Example 6.11 Pg 164¶

In [11]:
from __future__ import division
# To find the value of resistance R1 for instrumentation amplifier
A =100 #
R2 = 450*10**3 #
R3 = 1*10**3 #
R4 = 1*10**3 #

# The gain of differential amplifier
# A = (R4/R3)*(1+(2R2/R1)) #
#but  R3 = R4  then
# A = 1+(2R2/R1) #
R1 = 2*R2/(A-1)/1000 # kohm
print 'The value of resistane R1 is = %0.2f'%R1,'kohm'#

The value of resistane R1 is = 9.09 kohm


## Example 6.12 Pg 167¶

In [12]:
from __future__ import division
# determine the time constant of an integrator
Vo = 10 #  # at t= 1 m sec
t = 1 # # m sec

# the output of integrator
#Vo = t/RC # when t is from 0 to 1
RC = t/Vo #
print ' At t = 1 msec the time constant RC is = %0.2f'%RC,' m sec'#

print ' if C = 0.01 uF then R of RC time constant is = 10 K ohm '#

print ' if C = 0.001 uF then R of RC time constant is = 100 K ohm '#

 At t = 1 msec the time constant RC is = 0.10  m sec
if C = 0.01 uF then R of RC time constant is = 10 K ohm
if C = 0.001 uF then R of RC time constant is = 100 K ohm


## Example 6.13 Pg 168¶

In [13]:
from __future__ import division
from math import pi
# Design an integrator circuit
A = 10 #
f =20*10**3 #
R = 10*10**3 #  # we assume
Rf =10*R #

print ' The feedback resistance Rf is = %0.2f'%(Rf/1000),'kohm'#

# for proper integration f>= 10fa
fa = f/10/1000 #
print ' The frequency fa is = %0.2f'%fa,'kHz'#

# in practical integrator
#fa = 1/(2*pi*Rf*C)#

C = 1/(2*pi*Rf*fa)*1e6# nF
print ' The value of capacitor C is = %0.1f'%C,'nF '#

 The feedback resistance Rf is = 100.00 kohm
The frequency fa is = 2.00 kHz
The value of capacitor C is = 0.8 nF


## Example 6.1 Pg 185¶

In [14]:
from __future__ import division
# design an inverting amplifier with a closed loop voltage gain of Av = -5
Av = -5 #
Is = 5*10**-6 # # A
Rs = 1*10**3 # # ohm
# input voltage source Vs = sinwt volts

# in an inverting amplifier frequency effect is neglected then i/p volt Vin = 1 V and total resistance equal to Rs+R1

# the input current can be written as Iin=Is
# Is = (Vin/Rs+R1)#
Iin = Is#
Vin = 1 # # V
R1 = (1-(Iin*Rs))/Iin  #
print 'the value of resistance R1 is = %0.3f'%(R1/1e6),'Mohm'#

# closed loop voltage gain of an inverting amplifier
#Av = -(R2/Rs+R1)
R2 = -(Av*(Rs+R1))#
print 'the value of resistance R2 is  = %0.f'%(R2/1e6),'Mohm'#

the value of resistance R1 is = 0.199 Mohm
the value of resistance R2 is  = 1 Mohm


## Example 6.2 Pg 186¶

In [15]:
 # design an inverting amplifier with a closed loop voltage gain of Av = 10
Av = 10 #
Vin = 0.8 #  #V
Iin = 100*10**-6 # # A
# in an non- inverting amplifier the input voltage Vin=V1=V2 because of vortual short effect then the i/p current In = Vin/R1
R1 = Vin/Iin/1e3
print 'the value of resistance R1 is = %0.f'%R1,'kohm'#

# closed loop voltage gain of an non-inverting amplifier
#Av = Vo/Vin =  (1+R2/R1)
R2 = (Av-1)*R1 # kohm
print 'the value of resistance R2 is  = %0.f'%R2,'kohm'#

the value of resistance R1 is = 8 kohm
the value of resistance R2 is  = 72 kohm


## Example 6.3 Pg 187¶

In [16]:
# design an non-inverting amplifier with colsed loop gain of 5 limited voltage of -5 V <= Vo <= 5 V  and maximum i/p c/n 50 uA
R1 = 8*10**3 # # ohm
R2 = 72*10**3 # # ohm
Iin = 50*10**-6 # # A
Vo = 5 # # V

# closed loop gain
#Av = Vo/Vin = (1+R2/R1)
Av = 1+(R2/R1)#
# but
Av = 5 #
# then
# (R2/R1) = 4 #

# the output voltage of the amplifier is Vo = 5 V
#i.e
Vin = 1 # # V
# Iin = Vin/R1 #
R1 = Vin/Iin/1e3
print 'the value of resistance R1 is  = %0.2f'%R1,'kohm'#

R2 = 4*R1 #
print 'the value of resistance R2 is  = %0.2f'%R2,'kohm'#

# the output current I2 is given as
I2 = (Vo-Vin)/R2*1e3 # uA
print 'the output current I2 is  = %0.f'%I2,'uA'#

the value of resistance R1 is  = 20.00 kohm
the value of resistance R2 is  = 80.00 kohm
the output current I2 is  = 50 uA


## Example 6.4 Pg 188¶

In [17]:
# Design a op-amp circuit to provide the output voltage Vo = -2(3 V1 +4 V2 +2 V3)
# Vo = -2(3 V1 + 4 V2+ 2 V3)#      equation 1
# the output of the summer circuit is given as
# Vo = -R2((Via/Ria)+(Vib/Rib)+(Vic/Ric))    equation 2

# compare equation 1 and 2  of Vo we get

#  (R2/Ria)= 6 #
#  (R2/Rbi=8 #
#  (R2/Ric)=4 #

R2 = 120*10**3/1e3 #   # we choose then

Ria = R2/6 #
print 'the value of resistance Ria is  = %0.2f'%Ria,'kohm'#

Rib = R2/8 #
print 'the value of resistance Rib is  = %0.2f'%Rib,'kohm'#

Ric = R2/4 #
print 'the value of resistance Ric is  = %0.2f'%Ric,'kohm'#

the value of resistance Ria is  = 20.00 kohm
the value of resistance Rib is  = 15.00 kohm
the value of resistance Ric is  = 30.00 kohm


## Example 6.5 Pg 188¶

In [18]:
 # Design a summing amplifier circuit to provide the output voltage Vo = -(7 V11 + 15 V12 + 10 V13 + 3 V14)
R2 = 630# kohm # Assume feedback resistance
# Vo = -(7 V11 + 15 V12 + 10 V13 + 3 V14)#                    equation 1
# the output of the summer circuit is given as
# Vo = -R2((Via/Ria)+(Vib/Rib)+(Vic/Ric)+(Vid/Rid))           equation 2

# compare equation 1 and 2  of Vo we get

#  (R2/Ria)= 7 #
#  (R2/Rbi= 15 #
#  (R2/Ric)= 10 #
#  (R2/Rid)= 3 #

Ria = R2/7 #
print 'the value of resistance Ria is  = %0.2f'%Ria,' kohm'#

Rib = R2/15 #
print 'the value of resistance Rib is  = %0.2f'%Rib,' kohm'#

Ric = R2/10 #
print 'the value of resistance Ric is  = %0.2f'%Ric,' kohm'#

Rid = R2/3 #
print 'the value of resistance Rid is  = %0.2f'%Rid,'kohm'#

the value of resistance Ria is  = 90.00  kohm
the value of resistance Rib is  = 42.00  kohm
the value of resistance Ric is  = 63.00  kohm
the value of resistance Rid is  = 210.00 kohm


## Example 6.6 Pg 190¶

In [19]:
# Design a op-amp circuit to provide the output voltage Vo = V2 - 3 V1 with Ri1 =Ri2 = 100*10**3
Ri1 = 100 # # kohm
Ri2 = 100  # # kohm
# the i/p resistance
R1 = Ri1 #
R3 = Ri2 #

# Vo = V2 - 3 V1#                                    equation 1
# the output of the summer circuit is given as
# Vo = [(R4/(R3+R4)*(1+(R2/R1))*Vi2-(R2/R1)*Vi1]        equation 2

# compare equation 1 and 2  of Vo we get
# (R4/(R3+R4)*(1+(R2/R1)) = 1 #                           equation  3
# R2/R1 = 3 #                                           equation 4

# by subsituting the value of R1 and R3 in equation 3 and 4

# from equation  4
R2 = 3*R1 #
print 'the value of resistance R2 is  = %0.2f'%R2,'kohm'#

# from equation  3
R4 = (100*10**3)/3 #
print 'the value of resistance R4 is  = %0.2f'%R4,'kohm'#

the value of resistance R2 is  = 300.00 kohm
the value of resistance R4 is  = 33333.33 kohm


## Example 6.7 Pg 191¶

In [20]:
from __future__ import division
# determine the load current and output voltage
Vin = -5 #  # V
ZL = 200 # # ohm
R1 = 10*10**3 # # ohm
R2 = 10*10**3 # # ohm
R3 = 1*10**3 # # ohm
R4 = 1*10**3 # # ohm

# the load c/n of the given voltage to c/n converter circuit is given by
iL =-Vin/(R1*R4)*R2*1e3 # m
print 'The load current iL is  = %0.f'%iL,'mA'#

# the voltage across the load
VL = iL/1e3*ZL#
print 'The voltage across load VL is  = %0.2f'%VL,' V'#

# the non-inverting current across i3 and i4 are
i3 = VL/R3*1000 #mA
print 'The non-inverting current across i3 is = %0.2f'%i3,'mA'#

i4 = iL+i3 # mA
print 'The non-inverting current across i4 is  = %0.2f'%i4,'mA'#

# the output voltage of given voltage to current converter is given by
Vo = (iL/1e3*R3)+VL #
print 'The output voltage of given voltage to current converter is  = %0.2f'%Vo,' V'#

The load current iL is  = 5 mA
The voltage across load VL is  = 1.00  V
The non-inverting current across i3 is = 1.00 mA
The non-inverting current across i4 is  = 6.00 mA
The output voltage of given voltage to current converter is  = 6.00  V


## Example 6.8 Pg 192¶

In [21]:
from __future__ import division
from math import log10
# determine the common mode rejection ratio CMRR
# R2/R1 = 10 #
# R4/R3 = 11 #

# the output of the difference amplifier is given by
# Vo = (((R4)/(R3+R4))*(((1+(R2/R1))*VI2))-((R2/R1)*VI1))#

# putting R1 R2 R3 R4 value in above equation we get Vo as

# Vo =(121/12)*VI2-10VI1 #                                 equation 1

# the differential mode input of difference amplifier is given by
# Vd = VI2-VI1 #                                               eqution 2

# the common mode input of difference amplifier is given by
# VCM = (VI2+VI1)/2 #                                         equation 3

# from equation 2 and 3

# VI1 = VCM-Vd/2 #                                          equation 4

# VI2 = VCM+Vd/2 #                                          equation 5

# substitute equation 4 and 5 in 1  we get
# Vo = (VCM/12)+(241Vd/24)#                               equation6

# Vd = Ad*Vd+ACM*VCM #                                  equation 7

#equation from equation 6 and 7 we get

ACM = 1/12 #

# the common mode rejection ratio CMRR is
print 'The common mode rejection ratio CMRR is  = %0.2f'%CMRR,' '#

# in decibal it can be expressed as

CMRR = 20*log10(CMRR)#
print 'The common mode rejection ratio CMRR in decibel is  = %0.2f'%CMRR,' dB '#

The common mode rejection ratio CMRR is  = 120.50
The common mode rejection ratio CMRR in decibel is  = 41.62  dB


## Example 6.9 Pg 194¶

In [22]:
from __future__ import division
from math import log10
# determine Vo when 1) VI1 = 2 V VI2 = -2 V and 2) VI1 = 2 V VI2 = 2 V
#                                      and common mode rejection ratio CMRR
R1 = 10*10**3 # # ohm
R2 = 20*10**3 # # ohm
R3 = 10*10**3 # # ohm
R4 = 22*10**3 # # ohm

# the output of the difference amplifier is given by
# Vo = (((R4)/(R3+R4))*(((1+(R2/R1))*VI2))-((R2/R1)*VI1))#

# Case 1 when VI1 = 2 V VI2 = -2 V
VI1 = 2 #
VI2 = -2 #

Vo = (((R4)/(R3+R4))*(((1+(R2/R1))*VI2))-((R2/R1)*VI1))#
print 'The output of the difference amplifier is  = %0.2f'%Vo,' V '#

# case 2 when VI1 = 2 V VI2 = 2 V
VI1 = 2 #
VI2 = 2 #

Vo = (((R4)/(R3+R4))*(((1+(R2/R1))*VI2))-((R2/R1)*VI1))#
print 'The output of the difference amplifier is  = %0.2f'%Vo,' V '#

# the common mode input of difference amplifier is given by
VCM = (VI2+VI1)/2 #
print 'the common mode input of difference amplifier is = %0.2f'%VCM,' '#

# the common mode gain ACM of difference amplifier is given by
ACM = Vo/VCM
print 'the common mode gain ACM of difference amplifier is = %0.2f'%ACM,' '#

# the differential gain of the difference amplifier is given
print 'the differential gain of the difference amplifier is = %0.2f'%Ad,' '#

# the common mode rejection ratio CMRR is
print 'The common mode rejection ratio CMRR is  = %0.2f'%CMRR,' '#

# in decibal it can be expressed as
CMRR = 20*log10(CMRR)#
print 'The common mode rejection ratio CMRR in decibel is  = %0.2f'%CMRR,' dB '#

The output of the difference amplifier is  = -8.12  V
The output of the difference amplifier is  = 0.12  V
the common mode input of difference amplifier is = 2.00
the common mode gain ACM of difference amplifier is = 0.06
the differential gain of the difference amplifier is = 2.00
The common mode rejection ratio CMRR is  = 32.00
The common mode rejection ratio CMRR in decibel is  = 30.10  dB


## Example 6.10 Pg 195¶

In [23]:
# To determine the range of the differential voltage gain
#R1 = 1 K ohm to 25 K ohm #
R2 = 50 # # K ohm
R3 = 10 #  # K ohm
R4 = 10 # # K ohm

# the output of instrumentation amplifier is given by
#Vo = (R4/R3)*(1+(2*R2/R1))*(VI@-VI1)#

# the differential voltage gain of the instrumentation amplifier can be written as
#Av = (Vo/(VI2-VI1)) = (R4/R3)*(1+(2R2/R1))#

# For R1 = 1 K ohm   the maximum differential voltage gain of the instrumentation amplifier is
R1 = 1 # # K ohm
Av = (R4/R3)*(1+(2*R2/R1))#
print 'the maximum differential voltage gain of the instrumentation amplifier is = %0.2f'%Av,' '#

# For R1 = 25 K ohm   the mminimum differential voltage gain of the instrumentation amplifier is
R1 = 25 # # K ohm
Av = (R4/R3)*(1+(2*R2/R1))#
print 'the minimum differential voltage gain of the instrumentation amplifier is = %0.2f'%Av,' '#

print ' the range of the differential voltage gain of the instrumentation amplifier is '#
print '                    5 <= Av <= 101 '#

the maximum differential voltage gain of the instrumentation amplifier is = 101.00
the minimum differential voltage gain of the instrumentation amplifier is = 5.00
the range of the differential voltage gain of the instrumentation amplifier is
5 <= Av <= 101


## Example 6.11 Pg 196¶

In [24]:
# To design an instrumentation amplifier
# 4 <= Av <= 1000 #  gain
Res = 100 #  # K ohm

# we cosider the variable resistance is R1 , the maximum and the minimum range of variable resistance
# R1min = R1 #
# R1max = R1+100 #

# the gain of difference amplifier
#A3 = Ad = Vo/(Vo2-Vo1) = (R4/R3)

# the maximum range of differential voltage gain Avmax = 1000 when R1min = R1
#Avmax = R4/R3*(1+(2*R2/R1min))#

# by solvin we get following equation
#  499*R1-2*R2=0                       equation 1

# the maximum range of differential voltage gain Avmin =4 when R1max = R1+100 K ohm
# Avmin = (R4/R3)*(1+(2R2/R1max))#

# by solving above equation we get
# R1 -2 R2 = -200 K ohm                equation 2

#by solving equation 1 and 2 we get
R1 = 401 # #  ohm
R2 = 100.2 # # ohm
print 'The variable resistance R1 varies is  401 ohm <= R1 <= 100.2 K-ohm ' #

The variable resistance R1 varies is  401 ohm <= R1 <= 100.2 K-ohm


## Example 6.12 Pg 198¶

In [25]:
 # Determine the time constant of the integrator
Vo = 10 #
t = 2*10**-3 #
VI = -1 #  # at t =0 #

# The output voltage of an integrator is define as
RC = t/10*1e3 # ms
print ' The time constant of the given filter is RC = %0.2f'%RC,'msec '#

 The time constant of the given filter is RC = 0.20 msec


## Example 6.13 Pg 198¶

In [26]:
from __future__ import division
# Determine the time constant of the integrator
Vo = 20 #
t = 1*10**-3 #
VI = -1 #  # at t =0 #

# The output voltage of an integrator is define as
RC = t/10 #
print ' The time constant of the given filter is RC = %0.1f'%(RC*1000),'msec '#

R = 1*10**3 #  # we assume
C = RC/R*10**6 #
print 'The capacitor value is = %0.1f'%C,'F'#

 The time constant of the given filter is RC = 0.1 msec
The capacitor value is = 0.1 F


## Example 6.14 Pg 199¶

In [27]:
 # to design a summing amplifier

# the output of the summing amplifier is given by
#Vo = -R2*((VIa/RIa)+(VIb/RIb)+(VIc/RIc)+(VId/RId))#    equation 1

# the equation given is
#Vo = -(3*VIa+12*VIb+15*VIc+18*VId)#               equation 2

# comparing equation 1 and 2
#R2/RIa = 3 #
#R2/RIb = 12 #
#R2/RIc = 15 #
#R2/RId = 18 #

# the feedback resistance R2= 270 K ohm
R2 = 270 #  # K ohm
RIa = R2/3 #
print 'The value of resistance RIa is = %0.2f'%RIa,' K ohm '#

RIb = R2/12 #
print 'The value of resistance RIb is = %0.2f'%RIb,' K ohm '#

RIc = R2/15 #
print 'The value of resistance RIc is = %0.2f'%RIc,' K ohm '#

RId = R2/18 #
print 'The value of resistance RId is = %0.2f'%RId,' K ohm '#

The value of resistance RIa is = 90.00  K ohm
The value of resistance RIb is = 22.50  K ohm
The value of resistance RIc is = 18.00  K ohm
The value of resistance RId is = 15.00  K ohm


## Example 6.15 Pg 200¶

In [28]:
# for the instrumentation amplifier find Vo1 , Vo2 , Vo
# Vi1 = -25 sin wt  #  # mV
# Vi2 = 25 sin wt # # mV
R1 = 10*10**3 #
R2 = 20*10**3 #
R3 = 20*10**3 #
R4 = 10*10**3 #

# the output of first op-amp A1 is given by
# Vo1 = (1+(R2/R1))*Vi1-(R2/R1)*Vi2 #
#by solving above equation we get
print 'The output of first op-amp A1 is = -275*sin wt mV '#

# the output of second op-amp A2 is given by
# Vo2 = (1+(R2/R1))*Vi2-(R2/R1)*Vi1 #
#by solving above equation we get
print 'The output of second op-amp A2 is = 275*sin wt mV '#

# the output of third op-amp A3 is given by
# Vo = (R4/R3)-(1+(2R2/R1)*(Vi2-Vi1) #
#by solving above equation we get
print 'The output of third op-amp A3 is = 825*sin wt mV '#

# current through the resistor R1 and R2 is
#i = (Vi1-Vi2)/R1 #
print 'current through the resistor R1 and R2 is = 5 sin wt uA '#

# current through the non-inverting terminal resistor R3 and R4
#i3 = Vo2/(R3+R4)#
print 'current through the non-inverting terminal resistor R3 and R4 = 5.5 sin wt uA '#

# current through the inverting terminal resistor R3 and R4
#i2 = Vo1-(R3/(R3+R4))*Vo2/R3 #
print 'current through the inverting terminal resistor R3 and R4 = 22 sin wt uA '#

The output of first op-amp A1 is = -275*sin wt mV
The output of second op-amp A2 is = 275*sin wt mV
The output of third op-amp A3 is = 825*sin wt mV
current through the resistor R1 and R2 is = 5 sin wt uA
current through the non-inverting terminal resistor R3 and R4 = 5.5 sin wt uA
current through the inverting terminal resistor R3 and R4 = 22 sin wt uA


## Example 6.16 Pg 202¶

In [29]:
from __future__ import division
# for the a current to voltage converter show a) Rin = (Rf/1+Aop)  b) Rf = 10 K ohm Aop = 1000

#a) The input resistance given as
#Rin = (Rf)/(1+Aop) #

# The input resistance of the circuit can be written as
#Rin = (V1/i!)#

#  the feedback current of the given circuit is defined as
#i1 =(V1-Vo)/RF #

# the feedback resistance RF is
#RF =(V1-Vo)/i1 #

# The output voltage Vo is
#Vo = -Aop*V1 #

#by using this output feedback currenty i1 can be reformed as
#i1 = (V1-(-Aop*V1))/RF #

#i1 = V1*(1+Aop)/RF #

# Then Rin Becomes
#Rin =Rf/(1+Aop)#

Rf =10*10**3 #
Aop = 1000 #

# the input current and output voltage of the circuit are defined as
#i1 =(Rs)/(Rs+Rin) #
# Vo = -(Aop*(RF/1+Aop))*i1 #

#the input resistance Rin is
Rin =(Rf/(1+Aop)) #

# subsituting the value of RF Aop Rin and Vo we get
RF = 10 #
Rin = RF/(1+Aop)
print 'The input resistance Rin is = %0.5f'%Rin,' ohm '#

Aop = 1000 #
#(1000/1001)*(Rs/(Rs*0.00999))> 0.99 #
# by solving above equation we get
Rs = 1.099  #  # K ohm
print 'The value of Resistance Rs is = %0.4f'%Rs,' K ohm '#

The input resistance Rin is = 0.00999  ohm
The value of Resistance Rs is = 1.0990  K ohm


## Example 6.17 Pg 204¶

In [30]:
from __future__ import division
# determine the closed loop gain

# the output of the voltage follower is given as
#Vo = Aop(V1-Vo)#

# the closed loop gain of the voltage follower
#A = 1/(1+(1/Aop))#

# for Aop = 10**4 closed loop gain
Aop = 10**4 #
A = 1/(1+(1/Aop))#
print 'for Aop = 10**4 closed loop gain is = %0.4f'%A,' '#

# for Aop = 10**3 closed loop gain
Aop = 10**3 #
A = 1/(1+(1/Aop))#
print 'for Aop = 10**3 closed loop gain is = %0.4f'%A,' '#

# for Aop = 10**2 closed loop gain
Aop = 10**2 #
A = 1/(1+(1/Aop))#
print 'for Aop = 10**2 closed loop gain is = %0.4f'%A,' '#

# for Aop = 10**1 closed loop gain
Aop = 10**1 #
A = 1/(1+(1/Aop))#
print 'for Aop = 10**1 closed loop gain is = %0.4f'%A,' '#

for Aop = 10**4 closed loop gain is = 0.9999
for Aop = 10**3 closed loop gain is = 0.9990
for Aop = 10**2 closed loop gain is = 0.9901
for Aop = 10**1 closed loop gain is = 0.9091


## Example 6.18 Pg 205¶

In [31]:
from __future__ import division
from math import pi
# To determine the output voltage of integrator
Vin = 1 #
R = 150*10**3 ##  ohm
C = 1*10**-9 # # F

# the output voltage of an integrator is given as
#Vo = (fc/f)*Vin #

#fc = 1/(2*pi*R*C)#

#Vo = (1/(2*pi*R*C*f))*Vin#

#for the frequency f = 10 Hz  the output is
f = 10 # # Hz
Vo = (1/(2*pi*R*C*f))*Vin#
print 'for the frequency f = 10 Hz  the output is = %0.2f'%Vo,' V '#

#for the frequency f = 1000 Hz  the output is
f = 1000 # # Hz
Vo = (1/(2*pi*R*C*f))*Vin#
print 'for the frequency f = 1000 Hz  the output is = %0.2f'%Vo,' V '#

#for the frequency f = 10000 Hz  the output is
f = 10000 # # Hz
Vo = (1/(2*pi*R*C*f))*Vin#
print 'for the frequency f = 10000 Hz  the output is = %0.3f'%Vo,' V '#

for the frequency f = 10 Hz  the output is = 106.10  V
for the frequency f = 1000 Hz  the output is = 1.06  V
for the frequency f = 10000 Hz  the output is = 0.106  V


## Example 6.19 Pg 206¶

In [32]:
from __future__ import division
from math import sqrt
# To determine the magnitude gain of the integrator
Vin = 1 #
f = 50*10**3 #
Rf = 120*10**3 #
R = 10*10**3 #
C = 0.1*10**-9 #

# the magnitude gain of the integrator is given by
#A = (Rf/R)/(sqrt(1+(f/fc)**2))#

# the cutoff frequency of the integrator
fc = 1/(2*pi*Rf*C)/1e3
print 'The cutoff frequency of the integrator is = %0.3f'%fc,'kHz'#

A = (Rf/R)/(sqrt(1+(f/fc)**2))*1e3#
print 'The gain of the integrator is = %0.2f'%A

The cutoff frequency of the integrator is = 13.263 kHz
The gain of the integrator is = 3.18


## Example 6.20 Pg 207¶

In [33]:
from __future__ import division
from math import sqrt,pi
# To determine the magnitude gain of the differentiator
Vin = 1 #
f = 50*10**3 #
R = 75*10**3 #
R1 = 50*10**3 #
C = 0.1*10**-9 #

# the magnitude gain of the differentiator is given by
#A = (f/fa)/(sqrt(1+(f/fb)**2))#

# the break frequency fa is defined as
fa = 1/(2*pi*R1*C) / 1e3
print 'the break frequency fa is = %0.2f'%fa,'kHz '#

# the break frequency fb is defined as
fb = 1/(2*pi*R*C) /1e3
print 'the break frequency fb is = %0.2f'%fb,'kHz '#

A = (f/fa)/(sqrt(1+(f/fb)**2))#
print 'The gain of the differentiator is = %0.4f'%A,' '#

the break frequency fa is = 31.83 kHz
the break frequency fb is = 21.22 kHz
The gain of the differentiator is = 0.6667


## Example 6.21 Pg 209¶

In [34]:
from __future__ import division
# to determine the input voltage of an op-amp
Vo = 2 # # V
R1 = 20*10**3 # # ohm
R2 = 1*10**6 #  # ohm

# the input voltage of an op-amp
Vin = -(R1/R2)*Vo *1000 # mV
print 'The input voltage of an op-amp is = %0.f'%Vin,'mV'#

The input voltage of an op-amp is = -40 mV


## Example 6.22 Pg 209¶

In [35]:
from __future__ import division
# To determine the output voltage
Vin = 2 #
R2 = 20*10**3 #
R1 = 2*10**3 #

# the output voltage of follower Vo1 is
Vo1 = Vin #
print 'the output voltage of follower Vo1 is = %0.2f'%Vo1,'  V'#
# the output voltage of an inverting amplifier
Vo = -(R2/R1)*Vo1 #
print 'The output voltage of an inverting amplifier is = %0.2f'%Vo,' V '#

the output voltage of follower Vo1 is = 2.00   V
The output voltage of an inverting amplifier is = -20.00  V


## Example 6.23 Pg 210¶

In [36]:
from __future__ import division
# to determine the output voltage of an op-amp
Vin = 5 # # V
R1 = 25*10**3 # # ohm
R2 = 75*10**3 #  # ohm

# in this problem op-amp A1 perform the voltage follower and op-amp A2 perform inverting amplifier and op-amp A3 perform non-inverting amplifier

# the output voltage of follower op-amp A1
Vo1 = Vin #

# the output of the inverting amplifier A2
Vo2 = -((R2/R1)*Vo1) #
print 'The output of the inverting amplifier is = %0.2f'%Vo2,' V'#

# the output of the non-inverting amplifier A3
Vo =(1+(R2/R1))*Vo1 #
print 'The output of the non-inverting amplifier is = %0.2f'%Vo,' V'#

The output of the inverting amplifier is = -15.00  V
The output of the non-inverting amplifier is = 20.00  V


## Example 6.24 Pg 211¶

In [37]:
from __future__ import division
# To determine the output voltage
Vin = 2.5 #
Rf = 100*10**3 #
R1 = 10*10**3 #
RI1 = 25*10**3 #
RI2 = 10*10**3 #
R2 = 100*10**3 #

# the output voltage of an inverting amplifier
Vo1 = (1+(R2/R1))*Vin # #
print 'The output voltage of an inverting amplifier is = %0.2f'%Vo1,' V '#

# the output voltage of follower Vo2 is
Vo2 = Vin #
print 'the output voltage of follower Vo1 is = %0.2f'%Vo2,'  V'#

# the output of the inverting summing amplifier
R2 = 75*10**3 #
Vo = R2*((Vo1/RI1)+(Vo2/RI2))#
print 'the output of the inverting summing amplifier is = %0.2f'%Vo,' V '#

The output voltage of an inverting amplifier is = 27.50  V
the output voltage of follower Vo1 is = 2.50   V
the output of the inverting summing amplifier is = 101.25  V


## Example 6.25 Pg 212¶

In [38]:
from __future__ import division
# To calculate the output voltage
Vin = 2.5 #
R1 = 10*10**3 #
R2 = 10*10**3 #
R3 = 10*10**3 #
Rf = 30*10**3 #

# the total gain of the circuit
#Av =A1v*A2v*A3v #
Av = (1+(Rf/R1))*(-Rf/R2)*(-Rf/R3)#
print 'the total gain of the circuit is = %0.2f'%Av,' '#

# The  output voltage of the op-amp
Vo = Av*Vin #
print 'The  output voltage of the op-amp is = %0.2f'%Vo,' V'#

the total gain of the circuit is = 36.00
The  output voltage of the op-amp is = 90.00  V


## Example 6.26 Pg 212¶

In [39]:
from __future__ import division
# to calculate the output voltage of op-amp circuit
Rf = 100*10**3 # # ohm
R1 = 10*10**3 # # ohm
R2 = 25*10**3 # # ohm
R3 = 50*10**3 # # ohm

# the output of op-amp A1 is
# VA1 = (-Rf/R1)*V1 #
VA1 = (-Rf/R1)#
print 'The output of op-amp A1 is = %0.2f'%VA1,'V1' #       # *V1 because the output is come from 1 op-amp

# the output of op-amp A2 is
# Vo = -Rf*((VA1/R2)+(V2/R3))#
#Vo = -100*(-0.4*V1+0.02V2)#
print 'The output of op-amp A2 is  Vo = 40V1 - 2V2 '#

print 'The output is equal to the difference between 40V1 and 2V2 '#

The output of op-amp A1 is = -10.00 V1
The output of op-amp A2 is  Vo = 40V1 - 2V2
The output is equal to the difference between 40V1 and 2V2


## Example 6.27 Pg 213¶

In [40]:
from __future__ import division
# to determine the hysteresis width of a schmitt trigger
R1 = 25*10**3 # # ohm
R2 = 75*10**3 # # ohm
VTH = 4 # # V
VTL = -4 # # V

# the upper crossover voltage of schmitt trigger is defined as
VU = (R1/(R1+R2))*VTH#
print 'the upper crossover voltage of schmitt trigger is = %0.2f'%VU,' V'

# the lower crossover voltage of schmitt trigger is defined as
VL = (R1/(R1+R2))*VTL#
print 'the lower crossover voltage of schmitt trigger is = %0.2f'%VL,' V'

# the hysteresis width of schmitt trigger is
HW = VU-VL #
print 'the hysteresis width HW of schmitt trigger is = %0.2f'%HW,' V'

the upper crossover voltage of schmitt trigger is = 1.00  V
the lower crossover voltage of schmitt trigger is = -1.00  V
the hysteresis width HW of schmitt trigger is = 2.00  V


## Example 6.28 Pg 214¶

In [41]:
from __future__ import division
# to determine the hysteresis width of a schmitt trigger
R1 = 15*10**3 # # ohm
R2 = 90*10**3 # # ohm
VTH = 10 # # V
VTL = -10 # # V

# the upper crossover voltage of schmitt trigger is defined as
VU = (R1/(R1+R2))*VTH#
print 'the upper crossover voltage of schmitt trigger is = %0.2f'%VU,' V'

# the lower crossover voltage of schmitt trigger is defined as
VL = (R1/(R1+R2))*VTL#
print 'the lower crossover voltage of schmitt trigger is = %0.2f'%VL,' V'

# the hysteresis width of schmitt trigger is
HW = VU-VL #
print 'the hysteresis width HW of schmitt trigger is = %0.2f'%HW,' V'

the upper crossover voltage of schmitt trigger is = 1.43  V
the lower crossover voltage of schmitt trigger is = -1.43  V
the hysteresis width HW of schmitt trigger is = 2.86  V


## Example 6.29 Pg 214¶

In [42]:
from __future__ import division
# to determine the resistance R1 when low and high saturated output states are given
R2 = 20*10**3 # # ohm
VH = 2 # # V      crossover voltage
VL = -2 #  # V     crossover voltage
VOH = 10 # # V    saturated output states
VOL = -10 # # V    saturated output states

# the upper crossover voltage of schmitt trigger is defined as
# V = (R1/(R1+R2))*VOH#
# solving above equation we get
# 2R1+2R2 = 10R1 #
R1 = (2*R2)/8/1000 # kohm
print 'the value of resistance R1 is = %0.2f'%R1,'kohm'

the value of resistance R1 is = 5.00 kohm


## Example 6.30 Pg 215¶

In [43]:
from __future__ import division
# to determine the value of resistance R1 and R2 when low and high saturated output states are given
VH = 3 # # V      crossover voltage
VL = -3 #  # V     crossover voltage
VOH = 12 # # V    saturated output states
VOL = -12 # # V    saturated output states

# the upper crossover voltage of schmitt trigger is defined as
# V = (R1/(R1+R2))*VOH#
# solving above equation we get
# 3R1+3R2 = 12R1 #

# 3*R1 = R2 #
R1 = 10*10**3 # # ohm  we assume
R2 = 3*R1 / 1e3#
print 'the value of resistance R2 is = %0.2f'%R2,'kohm'

the value of resistance R2 is = 30.00 kohm
`