Chapter 4: Basic Applications of Operational Amplifiers

example 4.1, Page No. 104

In [3]:
# Output voltage of circuit shown in fig. 4.3

import math
#Variable declaration
R1 = R2 = R3 = 1000.0        # input Resistors
Rf = 1000.0                  # feedback resistor
Vin1 = 2                      # input voltage 1
Vin2 = 1                      # input voltage 2
Vin3 = 4                      # input voltage 3

#Calculations
Vout = -((Rf*Vin1/R1)+(Rf*Vin2/R2)+(Rf*Vin3/R3))

#Result
print("Vout = %d V"%Vout)
Vout = -7 V

example 4.2, Page No. 104

In [7]:
# Adder circuit design

import math
#Variable declaration
Rf = 100.0             # feedback resistor in k-ohm
V1 = 1                 # multiplication factor for input 1
V2 = 10                # multiplication factor for input 2
V3 = 100               # multiplication factor for input 3

#Calculations
R1 = Rf/V1
R2 = Rf/V2
R3 = Rf/V3

#Result
print("R1 = %d k-ohm\nR2 = %d  k-ohm\nR3 = %d   k-ohm"%(R1,R2,R3))
R1 = 100 k-ohm
R2 = 10  k-ohm
R3 = 1   k-ohm

example 4.3, Page No. 104

In [12]:
# Determine output voltage

import math
#Variable declaration
Rf = 12.0              # feedback resistor in k-ohm
Rs1 = 12.0             # input resistance 1
Rs2 = 2.0              # input resistance 2
Rs3 = 3.0              # input resistance 3
Vi1 = 9                # corresponding input Voltage 1
Vi2 = -3              # corresponding input Voltage 2
Vi3 = -1               # corresponding input Voltage 3

#Calculations
Vout = -Rf*((Vi1/Rs1)+(Vi2/Rs2)+(Vi3/Rs3))

#Result
print("Vout = %.0f V"%Vout)
Vout = 13 V

example 4.4, Page No. 105

In [16]:
# Summing amplifier design(refer fig. 4.4)

import math
#Variable declaration
Rf = 6                 # Assume,feedback resistor in k-ohm
V1 = 1                 # multiplication factor for input 1
V2 = 2                 # multiplication factor for input 2
V3 = -3                # multiplication factor for input 3

#Calculations
R1 = abs(Rf/V1)
R2 = abs(Rf/V2)
R3 = abs(Rf/V3)

#Result
print("R1 = %d k-ohm\nR2 = %d k-ohm\nR3 = %d k-ohm"%(R1,R2,R3))
R1 = 6 k-ohm
R2 = 3 k-ohm
R3 = 2 k-ohm

example 4.5, Page No. 105

In [22]:
# Summing amplifier design(refer fig. 4.5)

import math
#Variable declaration
Rf = 40.0              # Assume,feedback resistor in k-ohm
V1 = -2.0              # multiplication factor for input 1
V2 = -3.0              # multiplication factor for input 2
V3 = -4.0              # multiplication factor for input 3

#Calculations
R1 = abs(Rf/V1)
R2 =abs(Rf/V2)
R3 = abs(Rf/V3)

#Result
print("R1 = %d k-ohm\nR2 = %.2f k-ohm\nR3 = %d k-ohm"%(R1,R2,R3))
R1 = 20 k-ohm
R2 = 13.33 k-ohm
R3 = 10 k-ohm

example 4.6, Page No. 105

In [28]:
# Output Voltage(refer fig. 4.6)

import math
#Variable declaration
V1 = 2.0                  # V1 input
V2 = -1.0                 # V2 input
R  = 1.0                  # Resistor R, assumed
Rf = 2.0*R                # feedback resistor

#Calculations
Vin1 = (R*R/(R+R))*V1/(R+(R*R/(R+R)))
Vout1 = Vin1*(1+(Rf/R))
Vin2 = (R*R/(R+R))*V2/(R+(R*R/(R+R)))
Vout2 = Vin2*(1+(Rf/R))
Vout = Vout1+Vout2

#Result
print("Output voltage, Vout = %d V"%Vout)
Output voltage, Vout = 1 V

example 4.7, Page No. 116

In [32]:
# Limiting frequency

import math
#Variable declaration
R1 = 10*10**3            # resistor R1
Cf = 0.1*10**-6          # feedback capacitor

#Calculation
Rf = 10*R1
f = 1/(2*math.pi*Rf*Cf)

#Result
print("Limiting frequency = %.2f Hz"%(math.floor(f*100)/100))
Limiting frequency = 15.91 Hz

example 4.8, Page No. 117

In [40]:
# Design of practical integrator circuit

import math
#Variable declaration
A = 10.0                    # DC gain of integrator
f = 10.0*10**3              # frequency of input square wav
#Calculations
fa = f/10                 # break frequency for proper integration
R1 = 10.0*10**3             # selected
Rf = A*R1
Cf = 1/(2*math.pi*Rf*fa)
Rcomp = R1*Rf/(R1+Rf)


#Result
print("R1 = %d k-ohm\nRf = %d k-ohm\nCf = %.4f = %.1f nF\nRcomp = %.2f k-ohm"%(R1/1000,Rf/1000,Cf*10**9,Cf*10**9,Rcomp/1000))
R1 = 10 k-ohm
Rf = 100 k-ohm
Cf = 1.5915 = 1.6 nF
Rcomp = 9.09 k-ohm

example 4.9, Page No.118

In [48]:
# maximum change in output and minimum slew rate required

import math
#Variable declaration
Vin = 5              # input voltage
f = 1000.0           # input frequency
R1 = 1000.0          # Resistor R1
Cf = 0.1*10**-6      # feedback capacitor

#Calculation
Vout = Vin/(2*R1*f*Cf)
S = 2*math.pi*f*Vin

#Result
print("Delta V = %d V.\n\nOutput may saturate at +/- 14V. But %d change means the output will alternate"%(Vout,Vout))
print("between +/- %.1f V. Hence output will not saturate and will be triangular in nature."%(Vout/2))
print("\nMinimum slew rate required is %f V/usec."%(S*10**-6))
Delta V = 25 V.

Output may saturate at +/- 14V. But 25 change means the output will alternate
between +/- 12.5 V. Hence output will not saturate and will be triangular in nature.

Minimum slew rate required is 0.031416 V/usec.

example 4.10, Page No. 118

In [8]:
# Practical integrator circuit

import math
#Variable declaration
R1 = 120*10**3            # Resistor R1
Rf = 1.2*10**6            # feedback resistor
Cf = 10*10**-9            # feedback capacitor
V = 5                     # input sine wave amplitude
f = 10*10**3              # input sine wave frequency


#Calculations
#(ii)
fa = 1/(2*math.pi*Rf*Cf)
fs = 10*fa
#(iii)
A = Rf/R1
A = 20*math.log10(A)
#(iv)
A2 = (Rf/R1)/math.sqrt(1+(f/fa)**2)
Vout = V*A2

#Result
print("(i) Circuit diagram is shown in fig.4.27(a)\n\n(ii) fa = %.2f Hz\t\t Safe frequency = %.1f Hz\n\n(iii)DC gain = %d"%(fa,fs,A))
print("\n(iv) Vout(peak) = %.0f mV\n\n(v) Rough nature of frequency response is shown in fig. 4.27(b)"%(Vout*10**3))
(i) Circuit diagram is shown in fig.4.27(a)

(ii) fa = 13.26 Hz		 Safe frequency = 132.6 Hz

(iii)DC gain = 20

(iv) Vout(peak) = 66 mV

(v) Rough nature of frequency response is shown in fig. 4.27(b)

example 4.11, Page No. 119

In [7]:
# Output voltage

import math
#Variable declaration
f = 2000.0            # frequency of input sin wave
V = 10*10**-3          # amplitude of sin wave
R = 50*10**3          # Resistor R
C = 2*10**-6          # feedback capacitor

#Calculations
sf = -1/(R*C)
Vout = (math.sqrt(2)*V*sf)*1000/(2*math.pi*f)

#Result
print("Vout(t) = %.4f*(cos%dt-1)"%(-Vout,2*f))
Vout(t) = 0.0113*(cos4000t-1)

example 4.12, Page No. 119

In [12]:
# Capacitor voltage and closed loop time constant

import math
Vin = 10.0               # input voltage
R = 2.2*10**3            # Resistor
T = 10**-3               # ON time of the pulse
C = 10**-6               # Capacitance value

#Calculations
I = Vin/R
V = I*T/C
RC = R*C*10**5

#Result
print("I = %.3f mA\nV = %.3f V\nclosed-loop time constant = %.0f"%(I*10**3,V,RC))
I = 4.545 mA
V = 4.545 V
closed-loop time constant = 220

example 4.13, Page No. 120

In [14]:
# Lossyintegrator circuit

import math
#Variable declaration
A = 20.0              # peak gain
w = 10000             # w value when gain is 3dB down
C = 0.01*10**-6       # feedback capacitance

# Calculations
Rf = 1/(C*w)
R1 = Rf/10**(A/20.0)

#Result
print("Rf = %d k-ohm\t\tR1 = %d k-ohm"%(Rf/1000,R1/1000))
Rf = 10 k-ohm		R1 = 1 k-ohm

example 4.14, Page No. 120

In [92]:
# output voltage in case of circuit shown in  fig. 4.30 with ideal op-amp

import math
#Variable declaration
Vin = 5.0                    # input voltage at inverting terminal
V1 = 3.0                     # input voltage at non-inverting terminal
C = 0.2*10**-6               # feedback capacitor
R = 40*10**3                 # Resistor R
t = 50*10**-3                # time delay

#Calculations
Vout = -((Vin-V1)*t/(R*C))+V1


%matplotlib inline
import matplotlib.pyplot as plt
from numpy import arange,sin,pi
t = arange(0.0,5.0,0.01)
t1 = arange(0.0,6.0,0.01)
t2 = arange(0.0,5,0.01)
t3 = arange(-9.5,0.0,0.01)

plt.axis([0,5.5,-10.0,4.1])
plt.plot(t1,t1*0/t1,'b')
plt.plot(t,3-t*12.5/5.0,'b')
plt.plot(t2,-t2*9.5/t2,'--')
plt.plot(t3*5/t3,t3,'--')
plt.title("Output Voltage")
plt.xlabel("Time(x 10^-2) ")
plt.ylabel("Output Voltage in Volts")

#Result
print("Vout = %.1f V"%Vout)
Vout = -9.5 V

example 4.15, Page No. 121

In [48]:
# Time when output will get saturated in fig. 4.33

import math
#Variable declaration
R = 500.0*10**3         # Resistopr R
C = 10.0*10**-6         # feedback capacitor
V = -0.5                # V(t)
Vo = 12.0               # Saturation Voltage   
#Calculations
Vout = -V/(R*C)
t = Vo/Vout

#Result
print("Time duration required for saturation of output voltage = %d seconds"%t)
Time duration required for saturation of output voltage = 120 seconds

example 4.16, Page No.122

In [51]:
# expression using op-amp

import math
#Variable declaration
Cf = 10.0*10**-6       # feedback capacitor, assumed value
V1 = 1                 # multiplication factor for input 1
V2 = 2                 # multiplication factor for input 2
V3 = 5                 # multiplication factor for input 3

#Calculations
R1 = 1/(Cf*V1)
R2 = 1/(Cf*V2)
R3 = 1/(Cf*V3)

#Result
print("R1 = %d k-ohm\nR2 = %d  k-ohm\nR3 = %d   k-ohm\nCircuit will be ass show in fig. 4.35"%(R1/1000,R2/1000,R3/1000))
R1 = 100 k-ohm
R2 = 50  k-ohm
R3 = 20   k-ohm
Circuit will be ass show in fig. 4.35

example 4.17, Page No. 129

In [68]:
# Practical differentiator

import math
#Variable declaration
fmax = 150.0               # max frequency to be differentiate
C1 = 1*10**-6              # Capacitor C1, we choose

#Calculations
fa =fmax
Rf = 1/(2*math.pi*fa*C1)
Rf = Rf/1000              # k-ohm
Rf = math.floor(Rf*100)/100
fb = 10*fa
R1 = 1/(2*math.pi*fb*C1)
R1 = math.floor(R1*10)/10
Cf = R1*C1/(Rf*10**3)
Rcomp = R1*Rf*10**3/(R1+Rf*10**3)

#Result
print("R1 = %.1f ohm\nC1 = %d uF\nRf = %.2f k-ohm\nCf = %.1f uF\nRcomp = %.2f ohm"%(R1,C1*10**6,Rf,Cf*10**6,math.floor(Rcomp*100)/100))
R1 = 106.1 ohm
C1 = 1 uF
Rf = 1.06 k-ohm
Cf = 0.1 uF
Rcomp = 96.44 ohm

example 4.18, Page No.130

In [73]:
# op-amp differentiator

import math
#Variable declaration
Vm = 10*10**-6             # peak value of sine wave
fa = 2000.0                # maximum frequency
R = 50*10**3               # Resistor R 
C = 2*10**-6               # Capacitor C


#Calculations
Vout = -R*C*Vm*2*math.pi*fa

#Result
print("Vout = %f*cos(%d*pi*t) micro-V"%(Vout,2*fa))
Vout = -0.012566*cos(4000*pi*t) micro-V

example 4.19, Page No.130

In [12]:
# Differentiator design

import math
#Variable declaration
V = 3.0                   # input sine wave ampitude
f = 200.0                 # input sine wave frequency
fa = 1000.0               # maximum input frequency

#Calculations
C = 0.1*10**-6            #Assumed value
R = 1/(2*math.pi*fa*C)
R_1 = math.floor(R/100)*100
fb = 20*fa
R_dash =  1/(2*math.pi*fb*C)
R_dash_1 = 82*10**3 
C_dash = R_1*C/R_dash_1
Vout = -R_1*C*(V/2)*2*math.pi*f

#Result
print("R    = %.2f k-ohm = %.1f k-ohm(say)\nRom  = %.1f k-ohm\nVout = %.4fcos(%d*pi*t)"%(R/1000,R_1/1000,R_1/1000,Vout,f*2))
R    = 1.59 k-ohm = 1.5 k-ohm(say)
Rom  = 1.5 k-ohm
Vout = -0.2827cos(400*pi*t)

example 4.20, Page No.142

In [8]:
# Instrumentation Amplifier (refer fig 4.64)

import math
#Variable declaration
R1 = 200.0                 # Resistor R1
R2 = 100.0                 # Resistor R2
Rf = 100.0*10**3           # Feedback Resistor Rf
Rg_min = 100.0             # 100 ohm + 0 ohm
Rg_max = 100.0*10**3+100   # 100 ohm + 100 k-ohm


#Calculation
Gain1 = (1+(2*Rf/Rg_min))*(R2/R1)
Gain2 = (1+(2*Rf/Rg_max))*(R2/R1)

#Result
print("For all practical purposes, the gain can be varied from %.1f to %.1f"%(Gain2, Gain1))
#Answer for max gain is wrong in the book
For all practical purposes, the gain can be varied from 1.5 to 1000.5

example 4.21, Page No. 142

In [10]:
# Instrumentation Amplifier (refer fig 4.65)

import math
#Variable declaration
R1 = 100.0*10**3                  # Resistor R1
R2 = 100.0*10**3                  # Resistor R2
Rf = 470.0*10**3                  # Feedback Resistor Rf
Gain = 100.0                      # Gain 

#Calculations
Rg = 2*Rf/((Gain*(R1/R2))-1)

#Result
print(" Rg = %.2f k-ohm"%(Rg/1000))
 Rg = 9.49 k-ohm

example 4.22, Page No. 144

In [13]:
# Transducer Resistance

import math
#Variable declaration
R = 100.0              # reference resistance of the transducer
alfa = 0.00392         # Alfa value
T1 = 25                # Temperature Value 1
T2 = 100               # Temperature Value 2

#Calculations
R_25  = R*(1+alfa*T1)
R_100 = R*(1+alfa*T2)

#Result
print("It can be seen that Delta_R is %.1f ohm for a change at %d°C"%(R_25-R,T1))
print("while Delta_R is %.1f ohm for a change of %d°C."%(R_100-R,T2))
It can be seen that Delta_R is 9.8 ohm for a change at 25°C
while Delta_R is 39.2 ohm for a change of 100°C.

example 4.23, Page No.

In [15]:
# instrumentation amplifier design

import math
#Variable declaration
P_min = 0                 # minimum value of potentiometer
P_max = 50*10**3          # maximum value of potentiometer
G_min = 5.0               # minimum gain 
G_max = 200.0             # maximum gain

#Calculations
R3 = 1000.0               # assumed value
R4 = 1000.0               # resistor in series with potentiometer
x1 = (R4+P_min)/R3                
x2 = (R4+P_max)/R3                
y  = ((G_min/x1)-1)/2     # R1/R2
R2 =10*10**3              # assumed value
R1 = R2*y

#Result
print("R1 = %.0f k-ohm\nR2 = %.0f k-ohm\nR3 = %.0f  k-ohm\nR4 = %.0f  k-ohm\n"%(R1/1000,R2/1000,R3/1000,R4/1000))
R1 = 20 k-ohm
R2 = 10 k-ohm
R3 = 1  k-ohm
R4 = 1  k-ohm

example 4.24, Page No. 147

In [16]:
print("Theoretical example")
Theoretical example

example 4.25, Page No. 147

In [17]:
# Gain of instrumentation Amplifier(refer fig. 4.73)

import math
#Variable declaration
Rf = 5.0                # Resistor Rf in k-ohm
Rg = 1.0                # Resistor Rg in k-ohm
R1 = 10.0               # Resistor R1 in k-ohm
R2 = 20.0               # Resistor R2 in k-ohm

#Calculations
A = (1+(2*Rf/Rg))*(R2/R1)

#Result
print("A = %d"%A)
A = 22

example 4.26, Page No. 147

In [27]:
# output voltage of the circuit (refer fig. 4.74)

import math
#Variable declaration
R_A1  = 1000.0                # terminal resistor for op-amp A1
Rf_A1 = 5000.0                # feedback resistor for op-amp A1
R_A2  = 1000.0                # terminal resistor for op-amp A2
Rf_A2 = 2000.0                # feedback resistor for op-amp A2
Rcom_A2= 2000.0               # Rcom resistor for op-amp A2
V1 = 1.0                      # input at terminal 1 of A1 in mV
V2 = 5.0                      # 5*sin(wt)-->input at terminal 2 of A1 in mV
V3 = 5.0                      # input at terminal 2 of A2

#Calculations
Vin_1 = V1*(-Rf_A1/R_A1)
Vin_2 = V2*(-Rf_A1/R_A1)
Vout = Vin_1*(-Rf_A2/R_A2)+(1+Rf_A2/R_A2)*(Rcom_A2/(R_A2+Rcom_A2))*V3
Vout2 = Vin_2*(-Rf_A2/R_A2)

#Result
print("Vout = %d + %d*sin(wt) mV"%(Vout,Vout2))
Vout = 20 + 50*sin(wt) mV

example 4.27, Page No. 148

In [28]:
# output voltage of the circuit (refer fig. 4.75)


import math
#Variable declaration
Rf = 10.0                # Resistor Rf in k-ohm
Rg = 5.0                 # Resistor Rg in k-ohm
R1 = 1.0                 # Resistor R1 in k-ohm
R2 = 2.0                 # Resistor R2 in k-ohm
Vin2 = 2.0               # input at non-inverting terminal of A2 in mV
Vin1 = 1.0               # input at non-inverting terminal of A1 in mV

#Calculations
A = (1+(2*Rf/Rg))*(R2/R1)
Vout = A*(Vin2 - Vin1)
#Result
print("Vout = %d mV"%Vout)
Vout = 10 mV

example 4.28, Page No.148

In [31]:
# Determining the value of Rg

import math
#Variable declaration
Rf = 15.0                # Resistor Rf in k-ohm
R1 = 1.0                 # Resistor R1 in k-ohm
R2 = 2.0                 # Resistor R2 in k-ohm
Vin2 = 5.0*10**-3         # input at non-inverting terminal of A2 
Vin1 = 2.0*10**-3         # input at non-inverting terminal of A1 
Vout = 3                 # output voltage

#Calculations
A = Vout/(Vin2-Vin1)
Rg = 2*Rf/((A*R1/R2)-1)

#Result
print("Rg = %.2f ohm"%(Rg*1000))
Rg = 60.12 ohm

example 4.29, Page No.149

In [32]:
print("Theoretical example")
Theoretical example

example 4.30, Page No.150

In [33]:
print("Theoretical example")
Theoretical example

example 4.31, Page No. 151

In [42]:
# 3 op-amp instrumentation amplifier design

import math
#Variable declaration
g = 1.0                   # minimum gain required
G = 10000.0               # Maximum gain required
pot = 100.0               # potentiometer max value
#Calculations
A2 = 1.0/5.0             # Assumed gain of second stage
R1 = 100.0               # Resistor R1
R2 = R1*A2
x = ((G/A2)-1)/2         # Rf/Rgb
y = ((1/A2)-1)/2
Rgb = y*pot/(x-y)
Rf = x*Rgb

#Result
print("R1  = %d k-ohm\nR2  = %d  k-ohm\nRgb = %d     ohm\nRf  = %d k-ohm\n"%(R1,R2,Rgb*1000,Rf))
R1  = 100 k-ohm
R2  = 20  k-ohm
Rgb = 8     ohm
Rf  = 200 k-ohm

example 4.32, Page No.168

In [43]:
# Value of the current flowing through the Resistor R(Refer fig. 4.106)
import math
#Variable declartion
R2 = 1000.0                # Resistor in series with R
Va = Vb = 5.0              # input voltage

#Calculations
I = Vb/R2

#Result
print("I = %d mA"%(I*10**3))
I = 5 mA

example 4.33, Page No. 169

In [65]:
# Plot output waveform (refer fig 4.109)
##########-------PLOT--------#############


%matplotlib inline
import matplotlib.pyplot as plt
from numpy import arange,sin,pi
t = arange(0.0,1.0,0.01)
t1 = arange(0.0,3.0,0.01)
t2 = arange(0.0,1.0,0.01)
t3 = arange(-0.5,0.0,0.01)
t4 = arange(-1.0,0.0,0.01)
t5 = arange(0.0,0.5,0.01)
t6 = arange(1.0,2.0,0.01)

plt.axis([0,2.0,-1.5,0.9])
plt.plot(t1,t1*0/t1,'b')
plt.plot(t,-t*1,'b')
plt.plot(t2,-t2*1/t2,'--')
plt.plot(t5,-t5*0.5/t5,'--')
plt.plot(t3*0.5/t3,t3,'--')
plt.plot(t4*1.0/t4,t4,'--')
plt.plot(t6,-t6*1/t6,'b')
plt.title("Output Voltage")
plt.xlabel("Time(ms)")
plt.ylabel("Vo(t)")
Out[65]:
<matplotlib.text.Text at 0xb45df28>

example 3.34, Page No. 170

In [66]:
print("Theoretical example")
Theoretical example

example 3.35, Page No. 170

In [67]:
# output of circuit in fig. 4.111

import math
#Variable declaration
R1 = 1.0              # Resistance to inverting terminal
R2 = 2.0              # Resistance to non-inverting terminal
Rf = 10.0             # Feedback resistance
Rcom = 1.0            # Resistance Rcom
V1 = 2.0              # input voltage at inverting terminal 
V2 = 5.0              # input voltage at non-inverting terminal 

#Calculations
Vo1 = -Rf*V1/R1
Vb = V2*Rcom/(R2+Rcom)
Vo2 = (1+(Rf/R1))*Vb
Vout = Vo1+Vo2

#Result
print("Vo = %.3f V"%Vout)
Vo = -1.667 V

example 4.36, Page No. 170

In [69]:
# Output voltage of circuit shown in fig. 4.114

import math
#Variable declaration
Rf = 10.0                     # Resistor Rf in k-ohm
R1 = 5.0                      # Resistor R1 in k-ohm
R2 = 4.0                      # Resistor R2 in k-ohm
R3 = 2.0                      # Resistor R3 in k-ohm
V1 = 5.0                      # input 1
V2 = 2.0                      # input 2
V3 = 3.0                      # input 3

#Calculations
Vout = -((Rf*V1/R1)+(Rf*V2/R2)+(Rf*V3/R3))

#Result
print("Vout = %d V"%Vout)
Vout = -30 V

example 4.37, Page No. 171

In [72]:
# output Voltage of circuit in fig. 4.116

import math
#Variable declaration
R1 = 2.0              # Resistance to inverting terminal
R2 = 1.0              # Resistance to non-inverting terminal
Rf = 4.0              # Feedback resistance
Rcom = 1.0            # Resistance Rcom
V1 = 2.0              # input voltage at non-inverting terminal 
V2 = 4.0              # input voltage at non-inverting terminal 

#Calculations
Vb1 = V2*R2/(R2+Rcom)
Vo1 = (1+(Rf/R1))*Vb1
Vb2 = V1*R2/(R2+Rcom)
Vo2 = (1+(Rf/R1))*Vb2
Vout = Vo1+Vo2

#Result
print("Vo = %d V"%Vout)
Vo = 9 V

example 4.39, Page No. 171

In [77]:
# output of differential amplifier

import math
#Variable declaration
V1 = 1.0*10**-3          # input voltage 1 
V2 = 2.0*10**-3          # input voltage 2 
Ad = 5000.0              # differential gain
CMRR = 1000.0            # Common Mode Rejection Ratio

#Calculations
Ac = Ad/CMRR
Vd = (V1-V2)
Vc = (V1+V2)/2
Vout = Ac*Vc+Ad*Vd

#Result
print("Vo = %.4f V"%Vout)
Vo = -4.9925 V

example 4.40, Page No. 172

In [90]:
# output Voltage of circuit in fig. 4.116

import math
#Variable declaration
R1 = 40.0              # Resistance to inverting terminal
R2 = 25.0              # Resistance to inverting terminal
Rf = 50.0              # Feedback resistance
R3 = 10.0              # Resistance to non-inverting terminal
R4 = 20.0              # Resistance to non-inverting terminal
Rcom = 30.0             # Resistance Rcom
V1 = 1.0              # input voltage at inverting terminal 
V2 = 2.0              # input voltage at inverting terminal 
V3 = 3.0              # input voltage at non-inverting terminal 
V4 = 4.0              # input voltage at non-inverting terminal 

#Calculations
# (i)
Vo1 = -(Rf/R1)*V1
# (ii)
Vo2 = -(Rf/R2)*V2
# (iii)
R1 = R1*R2/(R1+R2)
Vb3 = V3*(Rcom*R4/(Rcom+R4))/(R3+(Rcom*R4/(Rcom+R4)))
Vo3 = (1+(Rf/R1))*Vb3
Vo3 = math.floor(Vo3*10**4)/10**4
# (iv)
Vb4 = V4*(Rcom*R3/(Rcom+R3))/(R4+(Rcom*R3/(Rcom+R3)))
Vo4 = (1+(Rf/R1))*Vb4
Vo4 = math.floor(Vo4*10**4)/10**4

Vout = Vo1+Vo2+Vo3+Vo4

#Result
print("Vo = %.4f V"%Vout)
Vo = 6.3408 V