OP-AMP Test

Contents

test 1 (integrator)

filename = 'oaf1.net';
type(filename);
parse;
symbuild;
idn = find(strcmp(yname,'V(out)'));

s = sym('s');
H = inv(Gm+Cm*s)*Is;
fprintf('\noutput is %s\n',char(yname(idn)));
pretty(H(idn))
%% op-amp test (integrator)

V Vs in 0 1
R Rs in 2 5K
C Cf  2 out 1m
OA u1 0 2 out

output is V(out)

       Vs
  - -------
    Cf Rs s

test 2 (Sallen-Key lowpass filter)

filename = 'oaf2.net';
type(filename);
parse;
symbuild;
idn = find(strcmp(yname,'V(out)'));


s = sym('s');
H = inv(Gm+Cm*s)*Is;
fprintf('\noutput is %s\n',char(yname(idn)));
pretty(H(idn))
% op-amp test (Sallen-Key lowpass filter)
% Attia, PSpice and MATLAB for Electronics, p 258-259

V Vs in 0 1
R R1 in 2 30K
R R2 2 3 30K
R R3 4 0 10K
R R4 out 4 40K
C C1 2 out 0.005u 
C C2  3 0 0.005u
OA u1 3 4 out

output is V(out)

                           Vs (R3 + R4)
  -------------------------------------------------------------
                                                              2
  R3 - C1 R1 R4 s + C2 R1 R3 s + C2 R2 R3 s + C1 C2 R1 R2 R3 s
syms C1 C2 R1 R2 R3 R4
a1 = C1*C2*R1*R2*R3;
a2 = (C2*R1*R3+C2*R2*R3-C1*R1*R4);
a3 = R3;
b1 = R3+R4;
w0 = sqrt(a3/a1);
alpha = a2/a1
gain = b1/a3
 
alpha =
 
(C2*R1*R3 - C1*R1*R4 + C2*R2*R3)/(C1*C2*R1*R2*R3)
 
 
gain =
 
(R3 + R4)/R3
 
sysbuild;

H = inv(Gm+Cm*s)*Is;
fprintf('\noutput is %s\n',char(yname(idn)));
pretty(H(idn))
output is V(out)

    7136238463529799405291429847247475681913733120
  --------------------------------------------------
                                                   2
  (5666839779443574375 s - 37778931862957161709568)
b1 = 7136238463529799405291429847247475681913733120;
a1 = 5666839779443574375;
a2 = 37778931862957161709568;

gain = b1/a2^2

tau = a1/a2
1/tau
gain =

     5


tau =

  1.5000e-004


ans =

  6.6667e+003

r = a1/a2;
a = [r^2 2*r 1];
b = 1;
f = logspace(1,5,401);
freqs(b,a,f);

test 3 (Sallen-Key highpass filter)

filename = 'oaf3.net';
type(filename);
parse;
symbuild;
idn = find(strcmp(yname,'V(out)'));


s = sym('s');
H = inv(Gm+Cm*s)*Is;
fprintf('\noutput is %s\n',char(yname(idn)));
pretty(H(idn))
% op-amp test (Sallen-Key highpass filter)
% Attia, PSpice and MATLAB for Electronics, p 262-259

V Vs in 0 1
R R1 2 out 30K
R R2 3 0 30K
R R3 4 0 10K
R R4 out 4 40K
C C1 in 2  0.005u 
C C2 2 3 0.005u
OA u1 3 4 out

output is V(out)

                                   2
                   C1 C2 R1 R2 Vs s  (R3 + R4)
  -------------------------------------------------------------
                                                              2
  R3 + C1 R1 R3 s + C2 R1 R3 s - C2 R2 R4 s + C1 C2 R1 R2 R3 s
sysbuild;

H = inv(Gm+Cm*s)*Is;
fprintf('\noutput is %s\n',char(yname(idn)));
pretty(H(idn))
output is V(out)

                                             2
(100353353393387808336209013987989501953125 s ) /

                                               2
   (20070670678677560827382146445383516569375 s  -

   267608942382367488896557370634638554728235008 s +

   892029807941224925661428730905934460239216640000)
b1 = 100353353393387808336209013987989501953125;

% a1 s^2 + a2 s + a3
a1 = 20070670678677560827382146445383516569375;
a2 = 267608942382367488896557370634638554728235008;
a3 = 892029807941224925661428730905934460239216640000;

% high-frequency gain (s->infinity)
gain = b1/a1

% ax^2 + bx + c radical = b^2 - 4*a*c
a1/a3
a2/a3
radical = a2^2 - 4*a1*a3
roots([a1 a2 a3])
gain =

    5.0000


ans =

  2.2500e-008


ans =

  3.0000e-004


radical =

     0


ans =

  1.0e+003 *

   -6.6667
   -6.6667

a = [1 a2/a1 a3/a1];
b = [b1/a1 0 0]/gain;
f = logspace(1,5,401);
freqs(b,a,f);