# determination of various parameters of feedback amplifiers
import math
#Variable declaration
Av=-100
B=0.01
#Calculations
Avd=Av/(1-B*Av)
v1d=10**-3
V0=Avd*v1d*1000
Vx=B*V0
V1=v1d+Vx
#Result
print("V1=%.3f\nV1d=%.3f\nThis is negative feedback because, v1<v1_dash\n"%( V1,v1d))
#percentage variation in Avdash
import math
#Variable declaration
Av=-100
Avd=-50
Avnew=-200
B=0.01
# Calculations
Avdnew=Avnew/(1-B*Avnew)
avchange=(-Avdnew)-(-Avd)
var=avchange*100/(-Avd)
#Result
print("Variation = %.1f%%"%var)
# reverse transmission factor and gain with feedback
import math
#Variable declaration
dA=100.0
A=1000.0
dAf=0.1
Af=100.0
#Calculations
#(a)
B=(((dA/A)*(Af/dAf))-1)/A
#(b)
Aff=A/(1+B*A)
#Result
print("(a)\nBeta=%.3f"%B)
print("\n(b)\nAf=%d"%Aff)
# Improvement in stability
import math
#Variable declaration
S=0.1
Sdash=0.01
Avdash=100.0
#Calculations
k=S/Sdash # k=1+BAv
Av=Avdash*k
B=(k-1)/Av
#Result
print("By providing negative feedback,with\nBeta = %.3f\nwe can improve the stability to 1%%."%B)
# Overall gain and reverse transmission factor
import math
#Variable declaration
Av=500.0
D=5.0
#Calculations
Ddash=0.1
B=((D/Ddash)-1)/(Av)
Avdash=-Av/(1+B*Av)
#Result
print("Av_dash = %.0f"%Avdash)
# different parameters with and without negative feedback
import math
#Variable declaration
Vs=150.0
A=10000.0
Vs2=130.0
A2=8000.0
#Calcualtions
V0=A*Vs
Afb=10000.0/80.0
B=((A/Afb)-1)/A
V02=A2*Vs
Afb2=A2/(1+(B*A2))
sg=(A-A2)*100/A
sgf=(Afb-Afb2)*100/Afb
#Result
print("Beta =%.4f"%B)
print("%% stability of gain without feedback=%.0f%%\n%% stability of gain with feedback=%.4f%%"%(sg,sgf))
print("Therefore, with neative feedbaclk stability is improved.")
# Avf, Rof and Rif for the voltage series feedback
import math
#Variable declaration
Rs=0
hfe=50.0
hie =1.100
hre=0
hoe=0
r5=2.2000
r7=3.3000
r3=33.0
r1=0.1
r2=10.0
r9=2.2
R1=0.98
r6=2.2
R0=2.0
#Calculations
#Rl =R5 is in parallel with R7,R8 and h1e2
Rl1=(r5*r3*r7*hie)/((r5*r3*r7)+(hie*r3*r7)+(r5*hie*r7)+(r5*r3*hie))
Rl2=(r9*(r1+r2))/(r9+(r1+r2))
Re=(r1*r6)/(r1+r6)
Av1=-(hfe*Rl1)/(hie+(1+hfe)*0.098) # The voltage gain AV1 of Q
Av2=(-hfe*Rl2)/hie # Voltage gain AY2 of transistor Q2
Av=Av1*Av2 # Voltage gain Ay of the two stages is cascade without feedback
B=r1/(r1+r2)
K=Av*B
D=1+K
Avf=Av/D
Ri=hie+(1+hfe)*Re # Input resistance without external feedback
Ridash=Ri*D
Rof=R0/D # Output resistance without feedback
#Result
print("Rl1_dash=%f"%Rl1)
print("Rl2=%f = 2 KOhm(approx)"%Rl2)
print("Re=%f kohm = %.0f ohm"%(Re,math.ceil(Re*1000)))
print("Av1 = %.2f\nAv2 = %.2f"%(Av1,Av2))
print("Avf = %d"%Avf)
print("Ri_dash = %f K Ohm"%Ridash)
print("Rof_dash=%f K Ohm"%Rof)
#Though the calculations are same as given in book answers
#do not match with the answers given in the Book.
# current series feedack
import math
#Variable declaration
Rc1 =3.0
Rc2 =0.500
Re2 = 0.05
Rdash=1.2
Rs = 1.2
hfe = 50.0
hie = 1.1
hre=0
hre =0
#Calculations
Ai=-hfe # EmItter follower
Ri2=hie+(1+hfe)*(Re2*Rdash/(Re2+Rdash))
k1=-Rc1/(Rc1+Ri2)
k1=math.ceil(k1*1000)
k1=k1/1000
R=Rs*(Rdash+Re2)/(Rs+(Rdash+Re2))
k2=R/(R+hie)
k2=math.floor(k2*1000)
k2=k2/1000
AI=Ai*k1*k2*hfe
B=Re2/(Re2+Rdash)
D=(1+B*AI)
Adash=AI/(1+B*AI)
Avdash=Adash*Rc2/Rs
Ri=R*hie/(R+hie) # Ri = Input resistance without feedback
Ridash=Ri/D
Rol=Rc2 # RoL =Ro in parallel with RC2 = RC2 and Ro is large
Rldash= Rol*D/D # with feedback considering RL
#Result
print("AI=%d\nBeta=%.2f\nAi_dash=%.1f\nAv_dash=%.2f"%(AI,B,Adash,Avdash))
print("Ri=%f K Ohm\nRl_dash=%.2f K Ohm"%(Ri,Rldash))
# calculation of Avf and Rif for given circuit
import math
#Variable declaration
Rc=4.0
Rb=40.0
Rs=10.0
hie=1.1
hfe=50.0
hre=0
hoe=0
#Calculations
Rcdash=Rc*Rb/(Rc+Rb)
R=Rs*Rb/(Rs+Rb)
Rm=-hfe*Rcdash*R/(R+hie)
Rm=math.floor(Rm)
B=-1/(Rb)
D=1+B*Rm
Rmdash=Rm/D
Avdash=Rmdash/Rs
Ri=R*hie/(R+hie)
Ridash=Ri/D
#Result
print("Transresistance Rm=%d k"%Rm)
print("Beta=%.3f mA/V\nRm_dash=%dk Ohm\nAv_dash=%f\nRi=%f k Ohm"%(B,Rmdash,Avdash,Ri))
print("Ri_dash=%f kOhm"%Ridash)