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.

TwoStageIndirectCompensation_SLCL.m
```%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Indirect Feedback Compensation of 2-Stage Opamp
% Split Length Current Mirror Load (SLCL) Topology (MS Thesis Pg. 49, Fig. 2-34)
% CL=30pF.
% Vishal Saxena
% Boise State University
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear all; clc;
%% Define the circuit symbols here
syms s vs v1 vo va s R1 R2 Ra rop gm1 gm2 gmp C1 C2 Ca Cc;
% Nodal Analysis Equations
eq1 = '-gm1*vs/2 + v1/R1 + v1*s*C1 -gmp*(va+ (gm1/gmp)*vs) + (v1-va)/rop=0'
eq2 = 'gm2*v1 + vo/R2 + vo*s*C2 + s*Cc*(vo-va)=0'
eq3 = '(va-v1)/rop + gmp*(va+ (gm1/gmp)*vs) + va*s*Ca + gmp*va + s*Cc*(va-vo)=0'

% eq1 = '-gm1*vs + v1/R1 + v1*s*C1 -gmp*(va) + (v1-va)/rop=0'
% eq2 = 'gm2*v1 + vo/R2 + vo*s*C2 + s*Cc*(vo-va)=0'
% eq3 = '(va-v1)/rop + gmp*(va) + va*s*Ca + gmp*va + s*Cc*(va-vo)=0'

[v1,va,vo]=solve(eq1,eq2,eq3,v1,va,vo);

% Define DC gain
Av = -gm1*R1*gm2*R2;

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

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

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

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

%% Define circuit constants
gm1=170e-6; gm2=1960e-6;
R1=160e3;R2=19.5e3;Ra=160e3
C1=10e-15;C2=30e-12;Ca=1e-15
gmp=2*gm1; rop=R1/2;
Cc=2e-12;
Rc=1/(2*gmp);
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)
pzmap(H1)

% Pole zero plot
figure(2)
bode(H1)

Rc
gm1/Cc
```