Code covered by the BSD License

# Indirect Feedback Compensation Techniques for Multi-Stage Operational Amplifiers

### Vishal Saxena (view profile)

Matlab simulation files for designing Two and Three-Stage Opamps using Indirect Compensation.

```%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Indirect Feedback Reverse Nested Compensation of 3-Stage Opamp
% Pseudo Class-AB Output Stage (MS Thesis Pg. 114, Fig. 3-40)
% Pole-Zero Cancelled, CL=30pF in parallel with RL=1K.
% Vishal Saxena
% Boise State University
% PS: Rescale the frequency axes for this plot to start from baseband.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear all; clc;
%% Define the circuit symbols here
syms s vs v1 v2 vo s R1 R2 R3 Rc1 Rc2 gm1 gm2 gm3 C1 C2 Cc1 Cc2;
% Nodal Analysis Equations
eq1 = 'gm1*vs + v1/R1 + v1*s*C1 + v2/(1/(s*Cc1)+Rc1)- vo/(1/(s*Cc2)+Rc2)=0'
eq2 = '-gm2*v1 + v2/R2 + v2/(1/(s*Cc1)+Rc1) + v2*s*C2=0'
eq3 = 'gm3*v2 + gm3*v1 + vo/R3 + vo/(1/(s*Cc2)+Rc2) + vo*s*C3=0'
[v1,v2,vo]=solve(eq1,eq2,eq3,v1,v2,vo);

% Define DC gain
Av = gm1*R1*(gm2*R2+1)*gm3*R3;

% Get Num and Den
[n,d]=numden(vo/vs);
%pretty(sort(n)/sort(d));

% Extract the coefficients from Num and Den
n1=expand(n/Av);

b = sym2polys(n1,s);
pretty(b)

a = sym2polys(d,s);
pretty(a')

%% Define circuit constants
gm1=170e-6; gm2=218e-6;gm3=1960e-6;
R1=160e3;R2=160e3;
RL=1e3;
R3=parl(19.5e3,RL);
C1=10e-15;C2=17.2e-15;C3=30e-12;
Cc1=1e-12;Cc2=2e-12;
Rc0=1/(sqrt(2)*gm1);

%% Apply pole-zero cancellation criterion
Rc2 = (Cc1/Cc2^2)*((C3+Cc2)/gm3);
Rc1 = C3/(gm3*Cc2) - 1/gm2;

format short e

%% Substitute the constants
b_num=subs(b);
a_num=subs(a);
Av_num=subs(Av);

% Find pole and zero locations
z = roots(b_num)
p = roots(a_num)

% Define AC transfer function
H1=tf(Av_num*b_num,a_num);

%% Plot Spectrum
figure(1)
h1=pzplot(H1);
setoptions(h1,'FreqUnits','Hz');

% Pole zero plot
figure(2)
h2=bodeplot(H1);
setoptions(h2,'FreqUnits','Hz');
grid on;

R1c = Rc1-Rc0
R2c = Rc2-Rc0
fun=gm1/(2*pi*Cc2)```