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_Type2.m
```%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Indirect Feedback Compensation of 2-Stage Opamp
% Cascoded Diff-pair used for Indirect Compensation (MS Thesis Pg. 37, Fig. 2-24)
% 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 roc gm1 gm2 gmc C1 C2 Ca Cc;
% Nodal Analysis Equations
eq1 = '-gm1*vs + va/Ra + va*s*Ca +gmc*va + (va-v1)/roc + s*Cc*(va-vo)=0'
eq2 = '-gmc*va + v1/R1 + v1*s*C1 + (v1-va)/roc=0'
eq3 = 'gm2*v1 + vo/R2 + vo*s*C2 + s*Cc*(vo-va)=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
gmc=gm1; roc=320e3;
Cc=2e-12;
Rc=3.25e3;
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
```