import math
##Example 12.1
A=10**5;##open loop gain
Af=50.;##closed loop gain
b=(A/Af-1.)/A;
print"%s %.2f %s"%('\nfeedback transfer function=\n',b,'')
A=-10**5;
Af=-50.;
b=(A/Af-1.)/A;
print"%s %.2f %s"%('\nfeedback transfer function=\n',b,'')
import math
##Example 12.2
A=10**5;
Af=50.;
b=0.019999;
dA=10**4;
dAf=Af*dA/(A*(1.+b*A));
print"%s %.2e %s"%('\ndAf ',dAf,'\n')
##x=dAf/Af
x=dAf/Af;
x=x*100.;
print"%s %.2e %s"%('\npercent change dAf/Af= ',x,'\n')
import math
##Example 12.3
Ao=10**4;
wh=2.*math.pi*100.;##rad/s
Af=50.;
##x=(1+bAo)
x=Ao/Af;
print"%s %.2f %s"%('\n(1+bAo)=\n',x,'')
wfh=wh*x;
print"%s %.2f %s"%('\nclosed loop bandwidth=\n',wfh,'')
import math
##Example 12.5
Av=10**5;
Avf=50.;
Rf=10.;##Kohm
Ro=20000.;##Ohm
##x=(1+bvAv)
x=Av/Avf;
print"%s %.2e %s"%('\n(1+bvAv)=\n',x,'')
Rif=Rf*x;
Rif=Rif*0.001;##MOhm
print"%s %.2f %s"%('\ninput resistance= ',Rif,' MOhm\n')
Rof=Ro/x;
print"%s %.2f %s"%('\noutput resistance= ',Rof,' Ohm\n')
import math
##Example 12.6
Af=10**5;
Aif=50.;
Rf=10000.;
Ro=20.;
##x=(1+biAi)
x=Af/Aif;
print"%s %.2e %s"%('\n(1+biAi)=\n',x,'')
Rif=Rf/x;
print"%s %.2f %s"%('\ninput resistance = ',Rif,'Ohm\n')
Rof=Ro*x;
Rof=Rof*0.001;##Mohm
print"%s %.2f %s"%('\noutput resistance= ',Rof,' MOhm\n')
import math
##Example 12.7
Ri=50.;
R1=10.;
R2=90.;
Av=10**4;
bv=1./(1.+R2/R1);
print"%s %.2f %s"%('\nfeedback transfer function=\n',bv,'')
Rif=Ri*(1.+bv*Av);
Rif=Rif*0.001;##Mohm
print"%s %.2f %s"%('\ninput resistance= ',Rif,' MOhm\n')
import math
##Example 12.11
hFE=100.;##transistor parameter
Vbe=0.7;
Vcc=10.;
R1=55.;
R2=12.;
Re=1.;
Rc=4.;
Rl=4.;
Icq=0.983;
Vceq=5.08;
Vt=0.026;
r=hFE*Vt/Icq;
print"%s %.2f %s"%('\nsmall signal parameter resistance= ',r,' KOhm\n')
gm=Icq/Vt;
print"%s %.2f %s"%('\ntransconductance= ',gm,' mA/V\n')
Agf=-gm*(Rc/(Rc+Rl))/(1.+Re*(gm+1./r));
print"%s %.2f %s"%('\ntransconductance transfer function= ',Agf,' mA/V\n')
##as first approximation
Agf2=-1./Re;
print"%s %.2f %s"%('\nAgf= ',Agf2,' mA/V\n')
Avf=Agf*Rl;
print"%s %.2f %s"%('\nvoltage gain=\n',Avf,'')
import math
##Example 12.15
##Determine the loop gain fig12.45(a)
hFE=100.;
Vbe=0.7;
Icq=0.492;
r=5.28;
gm=18.9;
Rs=10.;
R1=51.;
R2=5.5;
Re=0.500;
Rc=10.;
Rf=82.;
x=r*R2/(r+R2);
y=R1*x/(x+R1);
t=Rs*y/(y+Rs);
Req=t;
print"%s %.2f %s"%('\nequivalent resistance ',t,' KOhm\n')
T=gm*Rc*Req/(Rc+Rf+Req);
print"%s %.2f %s"%('\nthe loop gain=\n',T,'')
import math
##Example 12.19
##T=b*100/(sqrt(1+(f/10^5)^2) angle=-3tan^-1(f/10^5)
##stable at f180 at which phase becomes -180 degrees
##-3*atan(f180/10^5)=-180
f180=math.tan(60/57.3)*10**5;
print"%s %.2f %s"%('\nfrequency at -180 degree= ',f180,'f Hz\n')
b=0.2;
T=b*100./(math.sqrt(1.+(f180/10**5)**2))**3;
print"%s %.2f %s"%('\nmagnitude of the loop gain=\n',T,'')
b=0.02;
T=b*100./(math.sqrt(1.+(f180/10**5)**2))**3;
print"%s %.2f %s"%('\nmagnitude of the loop gain=\n',T,'')
import math
##Example 12.22
Ao=10**6;
fPD=0.010;##KHz
b=0.01;
Af=Ao/(1.+b*Ao);
print"%s %.2f %s"%('\nlow frequency closed loop gain=\n',Af,'')
fc=fPD*(1.+b*Ao);
print"%s %.2f %s"%('\nclosed loop 3dB frequency= ',fc,' KHz\n')
import math
##Example 12.23
A=10**3;
Cf=30.*10**-12;##feedback capacitor (F)
R2=5.*10**5;
Cm=Cf*(1.+A);
print"%s %.2e %s"%('\nMiller capacitance= ',Cm,' F\n')
fp=1/(2.*math.pi*R2*Cm);
print"%s %.2f %s"%('\ndominant pole frequency = ',fp,'Hz\n')