from __future__ import division
V_CE=4# #It should be high enough so that collector base junction is reverse-biased
i_B=30*10**-6# #base current, a value is selected from the graph
i_C=3*10**-3# #collector current corresponding to values of i_B and V_CE
B=i_C/i_B# #beta value
print 'The value of beta B = %0.2f'%B
from __future__ import division
V_CC=10#
V_BB=1.6#
R_B=40*10**3#
R_C=2*10**3#
V_in_Q=0# #Q point
V_in_max=0.4#
V_in_min=-0.4#
#the following values are found from the intersection of input loadlines with the input characteristic
i_B_Q=25*10**-3# #for V_in_Q
i_B_max=35*10**-3# #for V_in_max
i_B_min=15*10**-3# #for V_in_min
#the following values are found from the intersection of output loadlines with the output characteristic
V_CE_Q=5# #corresponding to i_B_Q
V_CE_max=7# #corresponding to i_B_min
V_CE_min=3# #corresponding to i_B_max
print 'graphs cannot be shown but the required values are'
print 'maximum value of V_CE = %0.2f'%V_CE_max
print 'minimum value of V_CE = %0.2f '%V_CE_min
print 'Q-point value of V_CE = %0.2f '%V_CE_Q
from __future__ import division
V_CC=15#
B=100# #beta value
R_B=200*10**3#
R_C=1*10**3#
#we proceed in such a way that the required values will be displayed according to the satisfied condition of the below three cases
#a)cut-off region
V_BE=15# #no voltage drop across R_B in cut-off state
V_CE=15# #no voltage drop across R_C in cut-off state
i_C=0# #no collector current flows as there is no voltage drop
i_B=0# #no base current flows as there is no voltage drop
if(V_BE<0.5): #cut-off condition
print 'collector current = %0.2f amperes'%i_C
print 'collector to emitter voltage = %0.2f volts'%V_CE
#b)saturation region
V_BE=0.7# #base to emitter voltage in saturation state
V_CE=0.2# #collector to emitter voltage in saturation state
i_C=(V_CC-V_CE)/R_C# #collector current
i_B=(V_CC-V_BE)/R_B# #base current
if((B*i_B>i_C) and (i_B>0)): #saturation state conditions
print 'collector current = %0.2f amperes'%i_C
print 'collector to emitter voltage = %0.2f volts'%V_CE
#c)active region
V_BE=0.7# #base to emitter voltage in active state
i_B=(V_CC-V_BE)/R_B# #base current
i_C=B*i_B# #collector current in active state
V_CE=V_CC-i_C*R_C# #collector to emitter voltage
if((V_CE>0.2) and (i_B>0)) : #active state conditions
print 'collector current = %0.2f amperes'%i_C
print 'collector to emitter voltage = %0.2f volts'%V_CE
R_B=200*10**3#
R_C=1*10**3#
V_CC=15#
B=300# #beta value
#we proceed in such a way that the required values will be displayed according to the satisfied condition of the below three cases
#a)active region
V_BE=0.7# #base to emitter voltage in active state
i_B=(V_CC-V_BE)/R_B# #base current
i_C=B*i_B# #collector current in active state
V_CE=V_CC-i_C*R_C# #collector to emitter voltage
if((V_CE>0.2) and (i_B>0)): #active state conditions
print 'collector current = %0.2f amperes'%i_C
print 'collector to emitter voltage = %0.2f volts'%V_CE
#b)saturation region
V_BE=0.7# #base to emitter voltage in saturation state
V_CE=0.2# #collector to emitter voltage in saturation state
i_C=(V_CC-V_CE)/R_C# #collector current
i_B=(V_CC-V_BE)/R_B# #base current
if((B*i_B>i_C) and (i_B>0)): #saturation state conditions
print 'collector current = %0.2f amperes'%i_C
print 'collector to emitter voltage = %0.2f volts'%V_CE
#c)cut-off region
V_BE=15# #no voltage drop across R_B in cut-off state
V_CE=15# #no voltage drop across R_C in cut-off state
i_C=0# #no collector current flows as there is no voltage drop
i_B=0# #no base current flows as there is no voltage drop
if(V_BE<0.5): #cut-off condition
print 'collector current = %0.2f amperes'%i_C
print 'collector to emitter voltage = %0.2f volts'%V_CE
from __future__ import division
V_CC=15#
V_BB=5#
V_BE=0.7# #assuming the device is in the active state
R_C=2*10**3#
R_E=2*10**3#
i_E=(V_BB-V_BE)/R_E# #emitter current
print " All the values in the textbook are Approximated hence the values in this code differ from those of Textbook"
#a)B=100
print 'For beta B=100:'
B=100# #beta value
i_B=i_E/(B+1)# #base current
i_C=B*i_B# #collector current
V_CE=V_CC-i_C*R_C-i_E*R_E# #collector to emitter voltage
print 'collector current = %0.2e amperes'%i_C
print 'collector to emitter voltage = %0.2f volts'%V_CE
#b)B=300
print 'For beta B=300:'
B=300# #beta value
i_B=i_E/(B+1)# #base current
i_C=B*i_B# #collector current
V_CE=V_CC-i_C*R_C-i_E*R_E# #collector to emitter voltage
print 'collector current = %0.2e amperes'%i_C
print 'collector to emitter voltage = %0.2f volts'%V_CE
from __future__ import division
V_CC=15#
R_1=10*10**3#
R_2=5*10**3#
R_C=1*10**3#
R_E=1*10**3#
V_BE=0.7#
R_B=1/((1/R_1)+(1/R_2))# #thevenin resistance
V_B=V_CC*R_2/(R_1+R_2)# #thevenin voltage
print " All the values in the textbook are Approximated hence the values in this code differ from those of Textbook"
#a)B=100
print 'For beta B=100:'
B=100# #beta value
i_B=(V_B-V_BE)/(R_B+(B+1)*R_E)# #base current
i_C=B*i_B# #collector current
i_E=i_B+i_C# #emitter current
V_CE=V_CC-i_C*R_C-i_E*R_E# #collector to emitter voltage
print 'collector current = %0.2e amperes'%i_C
print 'collector to emitter voltage = %0.2f volts'%V_CE
#b)B=300
print 'For beta B=300:'
B=300# #beta value
i_B=(V_B-V_BE)/(R_B+(B+1)*R_E)# #base current
i_C=B*i_B# #collector current
i_E=i_B+i_C# #emitter current
V_CE=V_CC-i_C*R_C-i_E*R_E# #collector to emitter voltage
print 'collector current = %0.2e amperes'%i_C
print 'collector to emitter voltage = %0.2f volts'%V_CE
%matplotlib inline
from matplotlib.pyplot import plot,subplot,title,xlabel,ylabel,show
from numpy import arange,sin,pi
from __future__ import division
V_CC=15#
V_BE=0.7#
B=100# #beta value
R_1=10*10**3#
R_2=5*10**3#
R_L_1=2*10**3# #R_L is taken as R_L_1
R_C=1*10**3#
R_E=1*10**3#
V_T=26*10**-3# #thermal voltage
#from the analysis of the previous example we have the the values of i_C_Q and V_CE
i_C_Q=4.12*10**-3#
V_CE=6.72#
r_pi=(B*V_T)/i_C_Q#
R_B=1/((1/R_1)+(1/R_2))# #thevenin resistance
R_L_2=1/((1/R_L_1)+(1/R_C))# #R_L' is taken as R_L_2
A_v=-(R_L_2*B)/r_pi# #voltage gain
A_voc=-(R_C*B)/r_pi# #open circuit voltage gain
Z_in=1/((1/R_B)+(1/r_pi))# #input impedance
A_i=(A_v*Z_in)/R_L_1# #current gain
G=A_i*A_v# #power gain
Z_o=R_C #output impedance
#assume f=1hz
f=1#
tt=arange(0,3+0.0005,0.0005)
V_in=[];V_o=[]
for t in tt:
V_in.append(0.001*sin(2*pi*f*t))
V_o.append(-((0.001*sin(2*pi*f*t))*R_L_2*B)/r_pi)
subplot(121)
title('Input voltage vs time')
xlabel('time')
ylabel('input voltage')
plot(tt,V_in)
subplot(122)
title('output voltage vs time')
xlabel('time')
ylabel('output voltage')
plot(tt,V_o)
#In the graph, notice the phase inversion between input and output voltages
print " All the values in the textbook are Approximated hence the values in this code differ from those of Textbook"
print 'voltage gain = %0.2f'%A_v,
print 'open circuit voltage gain = %0.2f'%A_voc
print 'input impedance = %0.2f ohms'%Z_in
print 'current gain = %0.2f'%A_i
print 'power gain = %0.2f'%G
print 'output impedance = %0.2f ohms'%Z_o
from __future__ import division
V_CC=20#
V_BE_Q=0.7#
V_T=26*10**-3# #thermal voltage
B=200# #beta value
R_S_1=10*10**3# #R_S is taken as R_S_1
R_1=100*10**3#
R_2=100*10**3#
R_L_1=1*10**3# #R_L is taken as R_L_1
R_E=2*10**3#
V_B=V_CC*R_2/(R_1+R_2)# #thevenin voltage
R_B=1/((1/R_1)+(1/R_2))# #thevenin resistance
R_L_2=1/((1/R_L_1)+(1/R_E))# #R_L' is taken as R_L_2
i_B_Q=(V_B-V_BE_Q)/(R_B+R_E*(1+B))
i_C_Q=B*i_B_Q#
i_E_Q=i_B_Q+i_C_Q#
V_CE_Q=V_CC-i_E_Q*R_E#
#we can verify that the device is in active region as we get V_CE>0.2 and i_BQ>0
r_pi=B*V_T/i_C_Q#
A_v=(1+B)*R_L_2/(r_pi+(1+B)*R_L_2)# #voltage gain
Z_it=r_pi+(1+B)*R_L_2# #input impedance of base of transistor
Z_i=1/((1/R_B)+(1/Z_it))# #input impedance of emitter-follower
R_S_2=1/((1/R_S_1)+(1/R_1)+(1/R_2))# #R_S' is taken as R_S_2
Z_o=1/(((1+B)/(R_S_2+r_pi))+(1/R_E))# #output impedance
A_i=A_v*Z_i/R_L_1# #current gain
G=A_v*A_i# #power gain
print " All the values in the textbook are Approximated hence the values in this code differ from those of Textbook"
print 'voltage gain = %0.2f'%A_v
print 'input impedance = %0.2f ohms'%Z_i
print 'current gain = %0.2f'%A_i
print 'power gain = %0.2f'%G
print 'output impedance = %0.2f ohms'%Z_o