# Chapter 12: The Operational Amplifier

### Example 12.1, Page Number: 392

In [1]:
import math
A_ol=100000.0;    #open loop voltage gain
A_cm=0.2;    #common mode gain
CMRR=A_ol/A_cm;
CMRR_dB=20*math.log10(CMRR);
print('CMRR = %d'%CMRR)
print('CMRR in decibels = %f'%CMRR_dB)

CMRR = 500000
CMRR in decibels = 113.979400

### Example 12.2, Page Number: 395

In [2]:
del_t=1.0;    # in microseconds
#lower limit is -9V and upper limit is 9V from the graph
del_V_out=9.0-(-9.0);
slew_rate=del_V_out/del_t;
print('slew rate =%d V/microseconds'%slew_rate)

slew rate =18 V/microseconds

### Example 12.3, Page Number: 400

In [3]:
R_f=100*10**3;
R_i=4.7*10**3;
A_cl_NI=1+(R_f/R_i);
print('closed loop voltage gain = %f'%A_cl_NI)

closed loop voltage gain = 22.276596

### Example 12.4,Page Number: 402

In [4]:
R_i=2.2*10**3;
A_cl=-100.0;    #closed loop voltage gain
R_f=abs(A_cl)*R_i;
print('value of R_f = %d ohms'%R_f)

value of R_f = 220000 ohms

### Example 12.5, Page Number: 404

In [5]:
Z_in=2*10**6;
Z_out=75.0;
A_ol=200000.0;
R_f=220.0*10**3;
R_i=10.0*10**3;
B=R_i/(R_i+R_f);    #B is attenuation
Z_in_NI=(1+A_ol*B)*Z_in;
Z_out_NI=Z_out/(1+A_ol*B);
A_cl_NI=1+(R_f/R_i);
Z_in_NI=Z_in_NI/10**10
print('input impedance = %f * 10^10 ohms'%Z_in_NI)
print('output impedance = %f ohms'%Z_out_NI)
print('closed loop voltage gain = %d'%A_cl_NI)

input impedance = 1.739330 * 10^10 ohms
output impedance = 0.008624 ohms
closed loop voltage gain = 23

### Example 12.6, Page Number: 405

In [6]:
B=1.0;    #voltage follower configuration
A_ol=200000.0;
Z_in=2*10**6;
Z_out=75.0;
Z_in_VF=(1+A_ol)*Z_in;
Z_out_VF=Z_out/(1+A_ol);
Z_in_VF=Z_in_VF*10**-11
print('input impedance = %d * 10^11 Ohms'%Z_in_VF)
print('output impedance = %f Ohms'%Z_out_VF)

input impedance = 4 * 10^11 Ohms
output impedance = 0.000375 Ohms

### Example 12.7, Page Number: 406

In [7]:
R_i=1.0*10**3;
R_f=100.0*10**3;
Z_in=4.0*10**6;
Z_out=50.0;
A_ol=50000.0;
B=R_i/(R_i+R_f);    #attenuation
Z_in_I=R_i;    #almost equal to R_i
Z_out_I=Z_out/(1+(A_ol*B));
A_cl_I=-R_f/R_i;
print('input impedance = %d Ohms'%Z_in_I)
print('output impedance = %f Ohms'%Z_out_I)
print('closed loop voltage gain =%d'%A_cl_I)

input impedance = 1000 Ohms
output impedance = 0.100796 Ohms
closed loop voltage gain =-100

### Example 12.8, Page Number: 412

In [8]:
import math
f_c_ol=100.0;
A_ol_mid=100000.0;
f=0.0;
A_ol=A_ol_mid/(math.sqrt(1+(f/f_c_ol)**2))
print('open loop gain when f=0Hz is %f'%A_ol);
f=10.0;
A_ol=A_ol_mid/(math.sqrt(1+(f/f_c_ol)**2))
print('open loop gain when f=10Hz is %f'%A_ol)
f=100.0;
A_ol=A_ol_mid/(math.sqrt(1+(f/f_c_ol)**2))
print('open loop gain when f=100Hz is %f'%A_ol)
f=1000.0;
A_ol=A_ol_mid/(math.sqrt(1+(f/f_c_ol)**2))
print('open loop gain when f=1000Hz is %f'%A_ol)

open loop gain when f=0Hz is 100000.000000
open loop gain when f=10Hz is 99503.719021
open loop gain when f=100Hz is 70710.678119
open loop gain when f=1000Hz is 9950.371902

### Example 12.9,Page Number: 413

In [9]:
import math
f_c=100.0;
f=1.0;
print('phase lag when f=1Hz     = %f degrees'%theta)

f=10.0;
print('phase lag when f=10Hz    = %f degrees'%theta)
f=100.0;
print('phase lag when f=100Hz   = %f degrees'%theta)
f=1000.0;
print('phase lag when f=1000Hz  = %f degrees'%theta)
f=10000.0;
print('phase lag when f=10000Hz = %f degrees'%theta)

phase lag when f=1Hz     = -0.572939 degrees
phase lag when f=10Hz    = -5.710593 degrees
phase lag when f=100Hz   = -45.000000 degrees
phase lag when f=1000Hz  = -84.289407 degrees
phase lag when f=10000Hz = -89.427061 degrees

### Example 12.10, Page Number: 415

In [10]:
import math
A_v1=40.0;    #all gains are in decibels
A_v2=32.0;
A_v3=20.0;
f_c1=2*10**3;
f_c2=40*10**3;
f_c3=150*10**3;
f=f_c1;
A_ol_mid=A_v1+A_v2+A_v3;
#theta 1

#theta 2

#theta 3

theta_tot=theta1+theta2+theta3;
print('open loop midrange gain in decibels is %d'%A_ol_mid)
print('total phase lag in degrees is %d'%theta_tot)

open loop midrange gain in decibels is 92
total phase lag in degrees is -45

### Example 12.11, Page Number: 416

In [11]:
A_ol_mid=150000.0;    #open loop midrange gain
B=0.002;    #feedback attenuation
BW_ol=200;    #open loop bandwidth
BW_cl=BW_ol*(1+B*A_ol_mid);
print('closed loop bandwidth = %d Hz'%BW_cl)

closed loop bandwidth = 60200 Hz

### Example 12.12, Page Number: 417

In [12]:
BW=3*10**6;    #unity gain bandwidth
A_ol=100.0;    #open loop gain
print("non-inverting amplifier")
R_f=220.0*10**3;
R_i=3.3*10**3;
A_cl=1+(R_f/R_i);    #closed loop gain
BW_cl=BW/A_cl;
print('closed loop bandwidth = %f Hz'%BW_cl)
print("inverting amplifier")
R_f=47.0*10**3;
R_i=1.0*10**3;
A_cl=-R_f/R_i;
BW_cl=BW/(abs(A_cl));
print('closed loop bandwidth = %f Hz'%BW_cl)

non-inverting amplifier
closed loop bandwidth = 44334.975369 Hz
inverting amplifier
closed loop bandwidth = 63829.787234 Hz