#Determine the Q point
#given
B=50.; #dc beta
Rc=2.2*10.**3.;#ohm #resistor connected to collector
Rb=270.*10.**3.;#ohm #resistor connected to base
Vcc=9.;#V #Voltage supply across the collector resistor
Vbe=0.7;#V #base to emitter voltage
Ib=(Vcc-Vbe)/Rb; #Base current
Ic=B*Ib; #Colletor current
Ics=Vcc/Rc; #Colletor saturation current
#Actual Ic is the smaller of the above two values
Vce=Vcc-Ic*Rc;
print '%s %.1f %s %.1f %s' %("The Q point is =",Vce,'V',Ic*1000,'mA');
#Note--In book Vce = 5.7 V because of approaximation
#Determine the Q point
#given
B=150.; #dc beta
Rc=1.*10.**3.;#ohm #resistor connected to collector
Rb=100.*10.**3.;#ohm #resistor connected to base
Vcc=10.;#V #Voltage supply across the collector resistor
Vbe=0.7;#V #base to emitter voltage
Ib=(Vcc-Vbe)/Rb; #Base current
Ic=B*Ib; #Colletor current
Ics=Vcc/Rc; #Colletor saturation current
#Actual Ic is the smaller of the above two values i.e. Ic(sat) and since the transistor is in saturation mode therefore Vce will become 0
Vce=0;
print '%s %.f %s %.f %s' %("The Q point is =",Vce,"V",Ics*1000,"mA");
#Determine Rb and percentage change in collector current due to temperature rise
#given
#Calculating the base resistance
B=20.; #dc beta
Rc=1.*10.**3.;#ohm #resistor connected to collector
Ic=1.*10.**-3.;#A #collector current
Vcc=6.;#V #Voltage supply across the collector resistor
Vbe=0.3;#V #for germanium
Icbo=2.*10.**-6.;#A #collector to base leakage current
Ib=(Ic-(1.+B)*Icbo)/B;
Rb=(Vcc-Vbe)/Ib;
print '%s %.f %s' %("The value of resistor Ib is =",120,'kohm');
Rb=120.*10.**3.;#ohm approax
#Now when temperature rise
Icbo=10.*10.**-6.;#A #collector to base leakage current
B=25.;#dc beta
Ic1=B*Ib+(B+1)*Icbo;# #changed collector current
perc=(Ic1-Ic)*100./Ic;#percentage increase
print '%s %.f %s' %("The percentage change in collector current is =",perc,"percent");
#Determine the Q point at two different B
#given
#At B=50
B=50.; #dc beta
Rc=2.*10.**3.;#ohm #resistor connected to collector
Rb=300.*10.**3.;#ohm #resistor connected to base
Vcc=9.;#V #Voltage supply across the collector resistor
Ib=Vcc/Rb; #Base current
Ic=B*Ib; #Colletor current
Ics=Vcc/Rc; #Colletor saturation current
#Actual Ic is the smaller of the above two values
Vce=Vcc-Ic*Rc;
print '%s %.2f %s %.1f %s' %("The Q point (At B=50) =",Vce,"V",Ic*1000,"mA");
#At B=150
B1=150.; #dc beta
Ic1=B*Ib; #Colletor current
Ics1=Vcc/Rc; #Colletor saturation current
#Actual Ic is the smaller of the above two values i.e. Ic(sat) and since the transistor is in saturation mode therefore Vce will become 0
Vce=0;
print '%s %.f %s %.1f %s' %("\nThe Q point (At B=150) is =",Vce,"V",Ics*1000,"mA");
print '%s %.f' %("\nThe factor at which collector current increases =",Ics1/Ic);
#determine Q point in collector to base bias circuit
#given
B=100.; #dc beta
Rc=500.;#ohm #resistor connected to collector
Rb=500.*10.**3.;#ohm #resistor connected to base
Vcc=10.;#V #Voltage supply across the collector resistor
Ib=Vcc/(Rb+B*Rc); #Base current
Ic=B*Ib; #Colletor current
Ics=Vcc/Rc; #Colletor saturation current
#Actual Ic is the smaller of the above two values
Vce=Vcc-(Ic+Ib)*Rc;
print '%s %.1f %s %.1f %s' %("The Q point is =",Vce,"V",Ic*1000,"mA");
#Calculate the collector current and change in it if B is changed by three times of previous B
#given
B=50.; #dc beta
Rc=2.*10.**3.;#ohm #resistor connected to collector
Rb=300.*10.**3.;#ohm #resistor connected to base
Vcc=9.;#V #Voltage supply across the collector as it is PNP so taking positive
Ib=Vcc/(Rb+B*Rc); #Base current
Ic=B*Ib; #Colletor current
print '%s %.3f %s' %("Collector current (B=50)=",Ic*1000,"mA\n");
#Now B=150
B=3.*B; #three times of previous B
Ib1=Vcc/(Rb+B*Rc); #Base current
Ic1=B*Ib1; #Colletor current
print '%s %.2f %s' %("Collector current (B=150)=",Ic1*1000,"mA\n");
print '%s %.f' %("The factor at which collector current increases =",Ic1/Ic);
#Calculate the value of all three current Ie and Ic and Ib
#given
B=90.; #dc beta
Rc=1.*10.**3.;#ohm #resistor connected to collector
Rb=500.*10.**3.;#ohm #resistor connected to base
Re=500.;#ohm #resistor connected to emitter
Vcc=9.;#V #Voltage supply across the collector resistor
Ib=Vcc/(Rb+B*Re); #Base current
Ic=B*Ib; #Colletor current
Ie=Ic+Ib; #Emitter current
print '%s %.1f %s %s %.3f %s %s %.3f %s' %("Base current =",Ib*10**6,"uA\n","\nCollector current =",Ic*10**3,"mA\n","\nEmitter current =",Ie*10**3,"mA");
#Calculate max and min value of emitter current
#given
#At B=50
B=50.; #dc beta
Rc=75.;#ohm #resistor connected to collector
Re=100.;#ohm #resistor connected to emitter
Rb=10.*10.**3.;#ohm #resistor connected to base
Vcc=6.;#V #Voltage supply across the collector resistor
Vbe=0.3;#V #for germanium
Ib=(Vcc-Vbe)/(Rb+(1.+B)*Re); #Base current
Ie=(1.+B)*Ib;
Vce=Vcc-(Rc+Re)*Ie
print '%s %.2f %s' %("Minimum emitter current =",Ie*10**3,"mA\n");
print '%s %.2f %s' %("The collector to emitter volatge =",Vce,"V\n");
#At B=300
B1=300.; #dc beta
Ib1=(Vcc-Vbe)/(Rb+(1.+B1)*Re);#Base current
Ie1=(1.+B1)*Ib1;
Vce1=Vcc-(Rc+Re)*Ie1
#Here Vce1= -1.4874 V but can never have negative voltage because Ie1 is wrong as it cant be more than saturation value therefore
Ie1=Vcc/(Rc+Re);
#And Vce=0 V
Vce1=0;#V
print '%s %.2f %s' %("Maximum emitter current =",Ie1*10**3,"mA\n");
print '%s %.f %s' %("The collector to emitter volatge(saturation) =",Vce1,"V");
#Determine the value of base resistance
#given
B=100.; #dc beta
Rc=200.;#ohm #resistor connected to collector
Re=500.;#ohm #resistor connected to emitter
Vcc=9.;#V #Voltage supply across the collector as it is PNP so taking positive
Vce=4.5;#V #Collector to emitter voltage
Ic=(Vcc-Vce)/(Rc+Re);
Ib=Ic/B;
Rb=(Vcc-B*Re*Ib)/Ib;
print '%s %.f %s' %("The value of base resistance is =",Rb/1000,"kohm");
#Determine the collector current at two different B
#given
#At B=50
B=50.;#dc beta
Rc=2.;#ohm #resistor connected to collector
Re=1000.;#ohm #resistor connected to emitter
Rb=300.*10.**3.;#ohm #resistor connected to base
Vcc=9.;#V #Voltage supply across the collector resistor
Ib=Vcc/(Rb+B*Re); #Base current
Ic=B*Ib; #Colletor current
print '%s %.2f %s' %("The collector current at (B=50)=",Ic*1000,"mA\n");
#At B=150
B1=150.;#dc beta
Ib1=Vcc/(Rb+B1*Re); #Base current
Ic1=B1*Ib1; #Colletor current
print '%s %.1f %s' %("The collector current at (B=150)=",Ic1*1000,"mA\n");
print '%s %.1f' %("The factor at which collector current increases=",Ic1/Ic);
#IN BOOK Ic(AT B=50)= 1.25 mA and Ic1/Ic=2.4 DUE TO APPROAXIMATION
#Calculate Q point in voltage divider
#given
B=100.; #dc beta
Rc=2.*10.**3.;#ohm #resistor connected to collector
R1=10.*10.**3.;#ohm #voltage divider resistor 1
R2=1.*10.**3.;#ohm #voltage divider resistor 2
Re=200.;#ohm #resistor connected to emitter
Vcc=10.;#V #Voltage supply across the collector resistor
Vbe=0.3;#V #base to emitter voltage
I=Vcc/(R1+R2); #current through voltage divider
Vb=I*R2; #voltage at base
Ve=Vb-Vbe;
Ie=Ve/Re;
Ic=Ie #approaximating Ib is nearly equal to 0
Vc=Vcc-Ic*Rc;
Vce=(Vc)-Ve;
print '%s %.1f %s %.f %s' %("The Q point is =",Vce,"V",Ic*1000,"mA");
Ibc=I/20.; #critical value of base current
Ib=Ic/B; #actual base current
#Since Ib < Ibc, hence assumption is alright
#Solve the voltage divider accurately by applying thevenin's theorem
#given
B=100.; #dc beta
Rc=2.*10.**3.;#ohm #resistor connected to collector
R1=10.;#ohm #voltage divider resistor 1
R2=1.;#ohm #voltage divider resistor 2
Re=200.;#ohm #resistor connected to emitter
Vcc=10.;#V #Voltage supply across the collector resistor
Vbe=0.3;#V #base to emitter voltage
Vth=Vcc*R2/(R1+R2);
Rth=R1*R2/(R1+R2);
print '%s %.1f %s' %("\nThevenin equivalent voltage Vth =",Vth,"V");
print '%s %.1f %s' %("\nThevenin equivalent resistance Rth =",Rth,"kohm");
Ib=(Vth-Vbe)/(Rth+(1.+B)*Re);
Ic=B*Ib;
Ie=Ic+Ib;
Vce=Vcc-Ic*Rc-Ie*Re;
print '%s %.4f %s' %("\nThe accurate value of Ic =",Ic*10**3,"mA");
print '%s %.5f %s' %("\nThe accurate value of Vce =",Vce,"V");
Icp=3.*10.**-3.; # Current calculated by voltage divider in previous example
Vcep=3.4; # Voltage calculated by voltage divider in previous example
Err_Ic=(Ic-Icp)*100./Ic;
Err_Vce=(Vce-Vcep)*100./Vce;
print '%s %.1f %s' %("\nError in Ic =",Err_Ic,"percent\n");
print '%s %.1f %s' %("\nError in Vce =",Err_Vce,"percent");
# The errors and The accurate values are different
# because of the approaximation in Vth and Rth in book
# In Book Ic = 2.8436 mA and Vce = 3.73839 V
# Error in Ic = -5.5%
# Error in Vce = +9%
#determine the Q point for the emitter bias circuit
#given
B=100.; #dc beta
Rc=5.*10.**3.;#ohm #resistor connected to collector
Rb=10.*10.**3.;#ohm #resistor connected to base
Re=10.*10.**3.;#ohm #resistor connected to emitter
Vcc=12.;#V #Voltage supply across the collector resistor
Vee=15;#V #supply at emitter
Ie=Vee/Re;
Ic=Ie;
Vce=Vcc-Ic*Rc;
print '%s %.1f %s %.1f %s' %("The Q point is =",Vce,"V",Ic*1000,"mA");
#Calculate Vgs and Rs
#given
import math
Vp=2.;#V
Idss=1.75*10.**-3.;#A #drain current at Vgs=0
Vdd=24.;#V #drain to supply source
Id=1.*10.**-3.;#A #drain current
Vgs=(-Vp)*(1-math.sqrt(Id/Idss));
Rs=abs(Vgs)/Id;
print '%s %.3f %s' %("Vgs =",Vgs,"V\n");
print '%s %.f %s' %("Rs =",Rs,"ohm");