Symbolsk løsning av nodeligninger med Matlab: Difference between revisions

From ift
mNo edit summary
m (Added calculation for all capacitors)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
=== Using Kirchoff's current law (KCL) on a source follower configuration to find Vout as a function of Vin ===
<pre>
<pre>
% Using Kirchoff's current law (KCL) on a source follower configuration
% Using Kirchoff's current law (KCL) on a source follower configuration
% to find Vout as a function of Vin
% to find Vo as a function of Vin
% Kjetil Ullaland
% Kjetil Ullaland, 2020


ligning1='(Vout-Vgs)/Zc+gm*Vgs+Vout/Rl=0';
syms s Cdg Cgs Cds Vin Vo Vgs Zc gm Rl Rs R Av Avo
ligning2='(Vgs-Vout)/Zc+(Vgs-Vin)/Rs=0';
ligning1=subs(ligning1,'1/(j*w*C)','Zc');
ligning2=subs(ligning2,'1/(j*w*C)','Zc');
pretty(ligning1);
pretty(ligning2);


%%
disp('Only Cgd with series resistor is considered (Zc)')


disp('Solve for Vgs');
eq1=(Vo-Vgs)/(R+Zc)+gm*Vgs+Vo/Rl == 0;
vgs_solved=solve(ligning2,'Vgs');
eq2=(Vgs-Vo)/(R+Zc)+(Vgs-Vin)/Rs == 0;
pretty(simplify(vgs_solved));
eq1=subs(eq1,Zc,1/(s*Cdg));
eq2=subs(eq2,Zc,1/(s*Cdg));
disp('KCL for circuit node 1:');
pretty(eq1);
disp('KCL for circuit node 2:');
pretty(eq2);


disp('Solve for Vout(vin)');
disp('Solve for Vo and Vin and calculate Av (Vo/Vin):');
ligning3=subs(ligning1,vgs_solved,'Vgs');
solved=solve(eq1,eq2,Vo,Vin);
Vout_solved=solve(ligning3,'Vout');
Av=solved.Vo/solved.Vin;
pretty(simplify(Vout_solved))
pretty(simplify(Av));
 
pretty(subs(Av,Rl*gm,Avo));
%%
disp('All MOST capasitors are considered')
 
syms s Cdg Cgs Cds Vin Vo Vgs gm Rl Rs Av Avo
 
eq1=(Vo-Vgs)*s*Cdg + gm*Vgs + Vo/Rl + Vo*s*Cds == 0;
eq2=(Vgs-Vin)/Rs + Vgs*s*Cgs + (Vgs-Vo)*s*Cdg == 0;
disp('KCL for circuit node 1:');
pretty(eq1);
disp('KCL for circuit node 2:');
pretty(eq2);
 
disp('Solve for Vo and Vin and calculate Av (Vo/Vin):');
solved=solve(eq1,eq2,Vo,Vin);
Av=solved.Vo/solved.Vin;
pretty(simplify(Av));
 
pretty(subs(Av,Rl*gm,Avo));
</pre>
 
=== Using Kirchoff's current law (KCL) on single transistor stage, fig. 9.18 to find Vo as a function of Is ===
<pre>
% Using Kirchoff's current law (KCL) on single transistor stage, fig. 9.18
% to find Vo as a function of Is
% Kjetil Ullaland, 2020
 
syms Vo V1 s gm R1 R2 C C1 C2 Is Zc Rz;
 
%% With feedforward capacitor
eq1=(Vo-V1)/Zc+gm*V1+Vo/R2+Vo*s*C2==0;
eq2=(V1-Vo)/Zc+V1*s*C1+V1/R1+Is==0;
eq1=subs(eq1,Zc,1/(s*C));
eq2=subs(eq2,Zc,1/(s*C));
 
disp('Solve for Vo and V1 and calculate Vo/Is with capacitor only in feedforward loop');
solved=solve(eq1,eq2,Vo,Is);
VoOnIs=solved.Vo/solved.Is;
pretty(simplify(VoOnIs));
 
%% With series resistor and capacitor in feedforward loop
eq1=(Vo-V1)/(Zc+Rz)+gm*V1+Vo/R2+Vo*s*C2==0;
eq2=(V1-Vo)/(Zc+Rz)+V1*s*C1+V1/R1+Is==0;
eq1=subs(eq1,Zc,1/(s*C));
eq2=subs(eq2,Zc,1/(s*C));
 
disp('Solve for Vo and V1 and calculate Vo/Is with resistor and capacitor in feedforward loop');
solved=solve(eq1,eq2,Vo,Is);
VoOnIs=solved.Vo/solved.Is;
pretty(simplify(VoOnIs));
</pre>
</pre>

Latest revision as of 11:39, 23 September 2020

Using Kirchoff's current law (KCL) on a source follower configuration to find Vout as a function of Vin

% Using Kirchoff's current law (KCL) on a source follower configuration
% to find Vo as a function of Vin
% Kjetil Ullaland, 2020

syms s Cdg Cgs Cds Vin Vo Vgs Zc gm Rl Rs R Av Avo

%%
disp('Only Cgd with series resistor is considered (Zc)')

eq1=(Vo-Vgs)/(R+Zc)+gm*Vgs+Vo/Rl == 0;
eq2=(Vgs-Vo)/(R+Zc)+(Vgs-Vin)/Rs == 0;
eq1=subs(eq1,Zc,1/(s*Cdg));
eq2=subs(eq2,Zc,1/(s*Cdg));
disp('KCL for circuit node 1:');
pretty(eq1);
disp('KCL for circuit node 2:');
pretty(eq2);

disp('Solve for Vo and Vin and calculate Av (Vo/Vin):');
solved=solve(eq1,eq2,Vo,Vin);
Av=solved.Vo/solved.Vin;
pretty(simplify(Av));

pretty(subs(Av,Rl*gm,Avo));
%%
disp('All MOST capasitors are considered')

syms s Cdg Cgs Cds Vin Vo Vgs gm Rl Rs Av Avo

eq1=(Vo-Vgs)*s*Cdg + gm*Vgs + Vo/Rl + Vo*s*Cds == 0;
eq2=(Vgs-Vin)/Rs + Vgs*s*Cgs + (Vgs-Vo)*s*Cdg == 0;
disp('KCL for circuit node 1:');
pretty(eq1);
disp('KCL for circuit node 2:');
pretty(eq2);

disp('Solve for Vo and Vin and calculate Av (Vo/Vin):');
solved=solve(eq1,eq2,Vo,Vin);
Av=solved.Vo/solved.Vin;
pretty(simplify(Av));

pretty(subs(Av,Rl*gm,Avo));

Using Kirchoff's current law (KCL) on single transistor stage, fig. 9.18 to find Vo as a function of Is

% Using Kirchoff's current law (KCL) on single transistor stage, fig. 9.18
% to find Vo as a function of Is
% Kjetil Ullaland, 2020

syms Vo V1 s gm R1 R2 C C1 C2 Is Zc Rz;

%% With feedforward capacitor
eq1=(Vo-V1)/Zc+gm*V1+Vo/R2+Vo*s*C2==0;
eq2=(V1-Vo)/Zc+V1*s*C1+V1/R1+Is==0;
eq1=subs(eq1,Zc,1/(s*C));
eq2=subs(eq2,Zc,1/(s*C));

disp('Solve for Vo and V1 and calculate Vo/Is with capacitor only in feedforward loop');
solved=solve(eq1,eq2,Vo,Is);
VoOnIs=solved.Vo/solved.Is;
pretty(simplify(VoOnIs));

%% With series resistor and capacitor in feedforward loop
eq1=(Vo-V1)/(Zc+Rz)+gm*V1+Vo/R2+Vo*s*C2==0;
eq2=(V1-Vo)/(Zc+Rz)+V1*s*C1+V1/R1+Is==0;
eq1=subs(eq1,Zc,1/(s*C));
eq2=subs(eq2,Zc,1/(s*C));

disp('Solve for Vo and V1 and calculate Vo/Is with resistor and capacitor in feedforward loop');
solved=solve(eq1,eq2,Vo,Is);
VoOnIs=solved.Vo/solved.Is;
pretty(simplify(VoOnIs));