Chapter 13 , Operational Amplifiers (Op-Amps)

Example 13.1 , Page Number 481

In [1]:
import math

#Variables

Ad = 100.0                     #Differential mode gain
Acm = 0.01                     #Common-mode gain

#Calculation

CMRR =  Ad/Acm                 #CMRR
CMRR1 = 20*math.log10(CMRR)    #CMRR (in db)

#Result

print "CMRR : ",CMRR1,"db."
CMRR :  80.0 db.

Example 13.2 , Page Number 481

In [2]:
#Variables

Ad = 1.0 * 10**5                     #Differential mode gain
CMRR = 1.0 * 10**4                   #CMRR

#Calculation

Acm = Ad/CMRR                        #Common-mode gain

#Result

print "Common mode gain : ",Acm,"."
Common mode gain :  10.0 .

Example 13.3 , Page Number 482

In [4]:
#Variables

V1 = 745.0 * 10**-6            #Input voltage1 (in volts)
V2 = 740.0 * 10**-6            #Input voltage2 (in volts)
Vcm = (V1 + V2)/2              #Commonn mode signal (in volts)
Vd = V1 - V2                   #Differential voltage (in volts)
Ad = 5 * 10**5                 #Differential voltage gain
CMRR = 1.0 * 10**4             #CMRR
 
#Calculation

Vout = Ad*Vd*(1 + 1/CMRR*Vcm/Vd)    #output voltage (in volts)
error = Vout - Ad*Vd                #Error voltage (in volts)
Percerror = error/Vout*100          #Percentage error

#Result

print "Output voltage :",round(Vout,6),"V."
print "Percentage error : ",round(Percerror,4),"%."
Output voltage : 2.537125 V.
Percentage error :  1.4633 %.

Example 13.4 , Page Number 483

In [5]:
#Variables

A = 200000.0               #Open loop voltage gain
Vd = 25.0 * 10**-6         #Input differential voltage (in volts)

#Calculation

Vout = A*Vd                #output voltage (in volts) 

#Result

print "Output voltage : + (or) - ",Vout,"V."
Output voltage : + (or) -  5.0 V.

Example 13.5 , Page Number 486

In [6]:
#Variables

Af = 10.0                   #Voltage gain
R1 = 3.0 * 10**3            #Resistance (in ohm) 

#Calculation

Rf = (Af - 1)*R1            #Resistance (in ohm) 

#Result

print "Rf : ",Rf*10**-3,"kilo-ohm."
Rf :  27.0 kilo-ohm.

Example 13.6 , Page Number 486

In [8]:
#Variables

R1 = 2.0 * 10**3            #Resistance (in ohm) 
Rfmin = 0.0                 #Resistance (in ohm) 
Rfmax = 100.0 * 10**3       #Resistance (in ohm) 

#Calculation

Afmin = 1 + Rfmin/R1        #Minimum voltage gain
Afmax = 1 + Rfmax/R1        #Maximum voltage gain 

#Result

print "Maximum closed loop voltage gain",Afmax,"."
print "Minimum closed loop voltage gain",Afmin,"."
Maximum closed loop voltage gain 51.0 .
Minimum closed loop voltage gain 1.0 .

Example 13.7 , Page Number 488

In [10]:
#Variables

R1 = 5.0 * 10**3            #Resistance (in ohm) 
Rf = 500.0 * 10**3          #Feedback resistance (in ohm)
Vin = 0.1                   #Input voltage (in volts)

#Calculation

Af = -Rf/R1                 #Voltage gain
Rin = R1                    #Input resistance (in ohm)
Rout = 0                    #Output resistance (in ohm)
Vout = Af*Vin               #Output voltage (in volts)
Iin = Vin/R1                #Input current (in Ampere)

#Result

print "Voltage gain : ",Af,"."
print "Input resistance : ",Rin*10**-3,"kilo-ohm."
print "Output resistance : ",Rout,"ohm."
print "Output voltage : ",Vout,"V."
print "Input current : ",Iin*10**3,"mA."
Voltage gain :  -100.0 .
Input resistance :  5.0 kilo-ohm.
Output resistance :  0 ohm.
Output voltage :  -10.0 V.
Input current :  0.02 mA.

Example 13.8 , Page Number 488

In [11]:
#Variables

Rf = 2.0 * 10**3           #Feedback resistance when S is open (in ohm)
Vin = 1.0                  #Input voltage when S is open (in volts)
R1 = 1.0 * 10**3           #Resistance (in ohm)
R2 = R3 = 1.0 * 10**3      #Resistance (in ohm)

#Calculation

Vout = -Vin*Rf/R1          #Output voltage when S is open (in volts)
Af = -(R3 + R2)/R1         #gain
Vout1 = Af*Vin             #Output voltage when S is closed (in volts)

#Result

print "O/P voltage when switch is open : ",Vout,"V."
print "O/P voltage when switch is closed : ",Vout1,"V."
O/P voltage when switch is open :  -2.0 V.
O/P voltage when switch is closed :  -2.0 V.

Example 13.9 , Page Number 489

In [14]:
#Variables

Rf = 1.0 * 10**6                 #Feedback resistance (in ohm)
Ri = 1.0 * 10**6                 #Input resistance (in ohm)
Vi = 1                           #Input voltage (in volts)

#Calculation

Vo = -Rf/Ri*Vi                   #Output voltage (in volts)
Av = Vo/Vi                       #Voltage gain 
Ai = 1                           #Current gain
Ap = abs(Av*Ai)                  #Power gain 

#Result

print "Voltage gain : ",Av,"."
print "Current gain : ",Ai,"."
print "Power gain : ",Ap,"."
Voltage gain :  -1.0 .
Current gain :  1 .
Power gain :  1.0 .

Example 13.13 , Page Number 492

In [15]:
#Variables

Rf = 20.0 * 10**3                #Feedback resistance (in ohm)
R1 = 10.0 * 10**3                #Resistance (in ohm)

#Calculation

Aoffnoninv = 1 + Rf/R1           #Amplifier gain when S open and non inverted
Aoffinv = -Rf/R1                 #Amplifier gain when S open and inverted
Aoff = Aoffinv + Aoffnoninv      #Amplifier gain when S open
Aon = -Rf/R1                     #Amplifier gain when S is closed    

#Result

print "Amplifier gain when S is open : ",Aoff,"."
print "Amplifier gain when S is closed : ",Aon,"."
Amplifier gain when S is open :  1.0 .
Amplifier gain when S is closed :  -2.0 .

Example 13.14 , Page Number 494

In [16]:
#Variables

Rf = 100.0                       #Feedback resistance (in kilo-ohm)

#Calculation

R1 = Rf                          #Resistance1 (in ohm)
R2 = Rf/10                       #Resistance2 (in ohm)
R3 = Rf/100                      #Resistance3 (in ohm)

#Result

print "R1 : ",R1,"kilo-ohm.\nR3 : ",R2,"kilo-ohm.\nR3 : ",R3,"kilo-ohm."
R1 :  100.0 kilo-ohm.
R3 :  10.0 kilo-ohm.
R3 :  1.0 kilo-ohm.

Example 13.15 , Page Number 494

In [22]:
#Variables

Rf = 12.0 * 10**3            #Feedback resistance (in ohm)
R1 = 12.0 * 10**3            #Resistance1 (in ohm)
R2 = 2.0 * 10**3             #Resistance2 (in ohm)
R3 = 3.0 * 10**3             #Resistance3 (in ohm)
Vi1 = 9.0                    #Input voltage1 (in volts)
Vi2 = -3.0                   #Input voltage2 (in volts)
Vi3 = -1.0                   #Input voltage3 (in volts)

#Calculation

Vout = -Rf*(Vi1/R1 + Vi2/R2 + Vi3/R3)      #Output voltage (in volts)

#Result

print "Output voltage : ",Vout,"V."
Output voltage :  13.0 V.

Example 13.16 , Page Number 495

In [23]:
#Variables

Rf = 6.0                       #Feedback resistance (in kilo-ohm)

#Calculation

R1 = Rf                          #Resistance1 (in ohm)
R2 = Rf/2                        #Resistance2 (in ohm)
R3 = Rf/3                        #Resistance3 (in ohm)

#Result

print "R1 : ",R1,"kilo-ohm.\nR3 : ",R2,"kilo-ohm.\nR3 : ",R3,"kilo-ohm."
R1 :  6.0 kilo-ohm.
R3 :  3.0 kilo-ohm.
R3 :  2.0 kilo-ohm.

Example 13.17 , Page Number 495

In [25]:
#Variables

R3 = 10.0                        #Resistance (in kilo-ohm)

#Calculation

Rf = 4*R3                        #Feedback resistance (in ohm)
R2 = Rf/3                        #Resistance2 (in ohm)
R1 = Rf/2                        #Resistance1 (in ohm)

#Result

print "Rf : ",Rf,"kilo-ohm.\nR2 : ",round(R2,2),"kilo-ohm.\nR1 : ",R1,"kilo-ohm."
Rf :  40.0 kilo-ohm.
R2 :  13.33 kilo-ohm.
R1 :  20.0 kilo-ohm.

Example 13.18 , Page Number 495

In [26]:
#Variables

V1 = 2.0                       #Voltage1 (in volts)
V2 = -1.0                      #Voltage2 (in volts)

#Calculation

Vs1 = V1*(1.0/2/(1+1.0/2))     #I/P at non-inverting I/P terminal (in volts)
V1o = Vs1*(1 + 2/1)            #O/P voltage1 (in volts)
Vs2 = V2*(1.0/2/(1+1.0/2))     #I/P voltage2 (in volts)
V2o = Vs2*(1 + 2/1)            #O/P voltage2 (in volts)
Vout = V1o + V2o               #Output voltage (in volts)

#Result

print "Output voltage : ",Vout,"V."
Output voltage :  1.0 V.

Example 13.19 , Page Number 496

In [27]:
#Variables

R = 10.0                  #Resistance (in kilo-ohm)

#Calculation

Rf = 10*R                 #feedback resistance (in kilo-ohm)

#Result

print "Feedback resistor : ",Rf,"kilo-ohm."
Feedback resistor :  100.0 kilo-ohm.

Example 13.20 , Page Number 498

In [29]:
#Variables

C = 2.0 * 10**-6                  #Capacitance (in Farad)
R = 50.0 * 10**3                  #Resistance (in ohm)  

#Calculation

scale_factor = -1/(C*R)           #Scale factor (in second)

#Result

print "Output voltage : 0.0113(cos(4000*t)-1) mV."
-10.0
Output voltage : 0.0113(cos(4000*t)-1) mV.

Example 13.21 , Page Number 499

In [30]:
import math

#Variables

C = 2.0 * 10**-6                  #Capacitance (in Farad)
R = 50.0 * 10**3                  #Resistance (in ohm)  
f = 2.0 * 10**3                   #Frequency (in Hertz)
Vpeak = 10.0 * 10**-6             #Peak voltage (in volts)

#Calculation

scale_factor = (C*R)              #Scale factor (in second)

#Result

print "Output voltage : 13.56*cos(4000*math.pi*t)."
Output voltage : 13.56*cos(4000*math.pi*t).

Example 13.22 , Page Number 505

In [31]:
#Variables

IB1 = 10.0 * 10**-6                  #Base current1 (in Ampere)
IB2 = 7.5 * 10**-6                   #Base current2 (in Ampere)   

#Calculation

Iinbias = (IB1 + IB2)/2              #Input bias current (in Ampere)
Iinoffset = IB1 - IB2                #Input offset current (in Ampere)          

#Result

print "Input bias current : ",round(Iinbias*10**6,2),"micro-Ampere."
print "Input offset current : ",round(Iinoffset*10**6,2),"micro-Ampere."
Input bias current :  8.75 micro-Ampere.
Input offset current :  2.5 micro-Ampere.

Example 13.23 , Page Number 505

In [32]:
#Variables

dVout = 20.0                         #Output voltage (in volts)
dt = 4.0                             #time (in micro-seconds) 

#Calculation

SR = dVout/dt                        #Slew rate (in volt per micro-second)

#Result

print "Slew rate : ",SR," V/micro-second."
Slew rate :  5.0  V/micro-second.