from __future__ import division
VCC=5
print "VCC= %0.2f"%(VCC)," volts" # voltage supply
RB=10*10**(3)
print "RB= %0.2f"%(RB)," ohm" # Base-resistance
RL=1*10**(3)
print "RL= %0.2f"%(RL)," ohm" # Load resistance
VCS=0.2
print "VCS= %0.2f"%(VCS)," volts" # collector saturated voltage
VBS=0.8
print "VBS= %0.2f"%(VBS)," volts" # Base voltage at saturation
V_gamma=0.6
print "V_gamma= %0.2f"%(V_gamma)," volts" # Threshold or cut-in voltage
ICS=(VCC-VCS)/RL
print "ICS = (VCC-VCS)/RL=%0.2e"%(ICS)," ampere" #Saturation collector current of transistor T1
vi=5
print "vi= %0.2f"%(vi)," volts" # Input voltage
IBS=(vi-VBS)/RB
print "IBS=(vi-VBS)/RB=%0.2e"%(IBS)," ampere" # Forward base drive required to sustain ICS
Beta_Fmin=ICS/IBS
print "Beta_Fmin=ICS/IBS= %0.2f"%(Beta_Fmin) # Common-emitter current gain
#NOTE: Correct formulae for ICS=(VCC-VCS)/RL
# but in book it is written wrong as ICS=(VCC-VCS)/RB but had calculated ans (in book) according to correct formulae ICS=(VCC-VCS)/RL
from __future__ import division
VD=0.7
print "VD= %0.2f"%(VD)," V" # Diode voltage drop in conduction mode
print "part(i)"# part(i)of question
vA=0
print "vA= %0.2f"%(vA)," V" # Input voltage1 of diode OR logic gate
vB=0
print "vB= %0.2f"%(vB)," V" # Input voltage2 of diode OR logic gate
vX=0 # Since both input voltages vA=vB=0V
print "vX=%0.2f"%(vX)," V" # Output voltage of diode OR logic gate for part(i)
print "part(ii)"# part(ii)of question
vA=0
print "vA= %0.2f"%(vA)," V" # Input voltage1 of diode OR logic gate
vB=5
print "vB= %0.2f"%(vB)," V" # Input voltage2 of diode OR logic gate for SECOND CASE: when vA=0V and vB=5V
vX=vB-VD
print "vX=vB-VD= %0.2f"%(vX)," V" # Output voltage of diode OR logic gate for SECOND CASE
print "part(iii)"# part(iii)of question
vA=5
print "vA= %0.2f"%(vA)," V" # Input voltage1 of diode OR logic gate for THIRD CASE when vA=5V and vB=0V
vB=0
print "vB= %0.2f"%(vB)," V" # Input voltage2 of diode OR logic gate
vX=vA-VD
print "vX=vA-VD= %0.2f"%(vX)," V" # Output voltage of diode OR logic gate for THIRD CASE
print "part(iv)"# part(iv)of question
vA=(+5)
print "vA= %0.2f"%(vA)," V" # Input voltage1 of diode OR logic gate
vB=(+5)
print "vB= %0.2f"%(vB)," V" # Input voltage2 of diode OR logic gate
vX=vA-VD # Since both diodes D1 and D2 are conducting
vX=vB-VD
print "vX=vA-VD=vB-VD= %0.2f"%(vX)," V" # Output voltage of diode OR logic gate for FOURTH CASE: when vA=5V and vB=5V
from __future__ import division
VD=0.7
print "VD= %0.2f"%(VD)," V" # Diode voltage drop in conduction mode
print "part(i)"
vA=0
print "vA= %0.2f"%(vA)," V" # Input voltage of diode AND logic gate
vB=0
print "vB= %0.2f"%(vB)," V" # Input voltage2 of diode AND logic gate
vX=VD # Since both input voltages vA=vB=0V
print "vX=VD=%0.2f"%(vX)," V" # Output voltage of diode AND logic gate for FIRST CASE: when vA=0V and vB=0V
print "part(ii)"
vA=0
print "vA= %0.2f"%(vA)," V" # Input voltage of diode AND logic gate
vB=5
print "vB= %0.2f"%(vB)," V" # Input voltage2 of diode AND logic gate for SECOND CASE: when vA=0V and vB=5V
vX=VD #due to diode A which is conducting and the Diode B is reverse biased with a voltage VD-VB=0.7-5=-4.3
print "vX=VD %0.2f"%(vX)," V"
#due to diode B which is conducting
print "part(iii)"
vA=5
print "vA= %0.2f"%(vA)," V" # Input voltage for THIRD CASE when vA=5V and vB=0V
vB=0
print "vB= %0.2f"%(vB)," V" # Input voltage2 of diode AND logic gate
vX = VD#due to diode B which is conducting and the Diode A is reverse biased with a voltage VD-VA=0.7-5=-4.3
print "vX= %0.2f"%(vX)," V"
print "part(iv)"
vA=5
print "vA= %0.2f"%(vA)," V" # Input voltage forfourth CASE when vA=5V and vB=5V
vB=5
print "vB= %0.2f"%(vB)," V" # Input voltage2 of diode AND logic gate for CASE: when vA=0V and vB=5V
vX=vA # Since both diodes D1 and D2 are Non-conducting, so no voltage drop across'R'(resistor)
print "vX = vA = vB= %0.2f"%(vX)," V" # Output voltage of diode AND logic gate for FOURTH CASE: when vA=5V and vB=5V
from __future__ import division
VIL=0.6
print "VIL= %0.2f"%(VIL)," V" # Minimum input voltage level for which output is maximum
VIH=0.75
print "VIH= %0.2f"%(VIH)," V" # Maximum input voltage level for which output is minimum
VOL=0.2
print "VOL= %0.2f"%(VOL)," V" # Minimum output voltage level for maximum input level
VOH=1
print "VOH= %0.2f"%(VOH)," V" # Maximum output voltage level for minimum input level
NML=VIL-VOL
print "NML=VIL-VOL= %0.2f"%(NML)," V" # Low level noise immunities
NMH=VOH-VIH
print "NMH=VOH-VIH= %0.2f"%(NMH)," V" # High level noise immunities
from __future__ import division
IIL=-1.6*10**(-3)
print "IIL= %0.2e"%(IIL)," A" # Input sink Current of TTL driver
IIH=40*10**(-6)
print "IIH= %0.2e"%(IIH)," A" # source (supply) reverse Current of TTL driver
IOL=16*10**(-3)
print "IOL= %0.2e"%(IOL)," A" # Specified Maximum sink Current of TTL driver
IOH=-400*10**(-6)
print "IOH= %0.2e"%(IOH)," A" # Specified Maximum source Current of TTL driver
Fan_out=abs((IOH/IIH))
print "Fan-out=abs((IOH/IIH)=abs((IOL/IIL))= %0.2f"%(Fan_out)# Fan-out of TTL
from __future__ import division
VIL=0.8
print "VIL= %0.2f"%(VIL)," V" # Minimum input voltage level for which output is maximum
VIH=2
print "VIH= %0.2f"%(VIH)," V" # Maximum input voltage level for which output is minimum
VOL=0.4
print "VOL= %0.2f"%(VOL)," V" # Minimum output voltage level for maximum input level
VOH=2.4
print "VOH= %0.2f"%(VOH)," V" # Maximum output voltage level for minimum input level
NML=VIL-VOL
print "NML=VIL-VOL= %0.2f"%(NML)," V" # Low level noise immunities
NMH=VOH-VIH
print "NMH=VOH-VIH= %0.2f"%(NMH)," V" # High level noise immunities
from __future__ import division
VIL=1
print "VIL= %0.2f"%(VIL)," V" # Minimum input voltage level for which output is maximum
VIH=4
print "VIH= %0.2f"%(VIH)," V" # Maximum input voltage level for which output is minimum
VOL=0.5
print "VOL= %0.2f"%(VOL)," V" # Minimum output voltage level for maximum input level
VOH=4.5
print "VOH= %0.2f"%(VOH)," V" # Maximum output voltage level for minimum input level
NML=VIL-VOL
print "NML=VIL-VOL= %0.2f"%(NML)," V" # Low level noise immunities
NMH=VOH-VIH
print "NMH=VOH-VIH= %0.2f"%(NMH)," V" # High level noise immunities
from __future__ import division
V_gamma=0.6
print "V_gamma= %0.2f"%(V_gamma)," volts" #Threshold voltage
VEE=-5.2
print "VEE= %0.2f"%(VEE)," volts" # voltage supply
VBE3=0.7
VBE4=VBE3
VBE5=VBE3
print "VBE3=VBE4=VBE5 %0.2f"%(VBE3)," volts" #base-emitter voltage
RE=779
print "RE= %0.2f"%(RE)," ohm" # Emitter-resistance
RL2=220
print "RL2= %0.2f"%(RL2)," ohm" # Load resistance
RL3=245
print "RL3= %0.2f"%(RL3)," ohm" # Load resistance
VREF=-1.29
print "VREF= %0.2f"%(VREF)," volts" # Reference- voltage
V_1=-0.7
print "V(1)= %0.2f"%(V_1)," volts" # Acceptable voltage for high logic
V_0=-1.7
print "V(0)= %0.2f"%(V_0)," volts" # Acceptable voltage for low logic
print "part(i)"# part(i)of question
VE=VREF-VBE3
print "VE=VREF-VBE3= %0.2f"%(VE)," volts" # Emitter- voltage
IE=(VEE-VE)/RE
print "IE=(VEE-VE)/RE= %0.2f"%(IE)," A" #Emitter- Current
IC3=IE# since IC=IE neglecting IB
print "IC3=IE= %0.2f"%(IE)," A" #Collector- Current
vC3=IC3*RL3
print "vC3=IC3*RL3= %0.2f"%(vC3)," volts" # Collector- voltage
vY=vC3-VBE5
print "vY=vC3-VBE5= %0.2f"%(vY)," volts" # Emitter follower output voltage for vB=V(0)
vC2=0
vX=vC2-VBE4
print "vX=vC2-VBE4= %0.2f"%(vX)," volts" # Emitter follower output voltage for vB=V(0)
VBEr=(V_0)-VE
print "Base -Emitter reverse voltage,VBEr=V(0)-VE= %0.2f"%(VBEr)," volts"#Base- Emitter junction reverse voltage ,this is sufficient to keep T1 and T2 off since threshold =0.6V
print "Transistor T1 and T2 off since VBEr < V_gamma" # Since VBEr < V_gamma hence T1 and T2 off
print "part(ii)"# part(ii)of question
IC2=IE
VBE=0.7
vB=V_1
IC3=0
VC3=0
vY=VC3-VBE5
print "vY=VC3-VBE= %0.2f"%(vY)," volts"# Emitter follower output voltage for SECOND CASE for vB=V(1)
VE=vB-VBE
print "VE=vB-VBE= %0.2f"%(VE)," volts" # Emitter- voltage
VBE3=VREF-VE
print "VBE3=VREF-VE= %0.2f"%(VBE3)," volts"#Base- Emitter junction voltage
print "VBE3 is smaller than V_gamma,hence T3 is off"
IC2=(VEE-VE)/RE
print "IC2=(VEE-VE)/RE= %0.2f"%(IC2)," A" #Collector- Current for T2(transistor)
vC2=IC2*RL2
print "vC2=IC2*RL2= %0.2f"%(vC2)," volts" # Collector- voltage for T2
vX=vC2-VBE4
print "vX=vC2-VBE4= %0.2f"%(vX)," volts" # Emitter follower output voltage for vB=V(1)
print "part(iii)"# part(iii)of question
VE3=-1.99
print "VE3=VE= %0.2f"%(VE3)," volts" # Transistor T3 Emitter- voltage ,when T3 is conducting
VB3=VREF
print "VB3=VREF= %0.2f"%(VB3)," volts" # Base- voltage when T3 is conducting
IC3=(VEE-VE3)/RE# Collector current for T3 neglecting IB
print "IC3=(VEE-VE3)/RE= %0.2f"%(IC3)," A" #Collector- Current
VC3=IC3*RL3
print "VC3=IC3*RL3= %0.2f"%(VC3)," volts" # Collector- voltage when T3 is conducting
VCB3=VC3-VB3
print "VCB3=VC3-VB3= %0.2f"%(VCB3)," volts" # Base- voltage when T3 is conducting
#All parameters have appropriate signs for npn BJT hence BJT in active region not in saturation in which VCB will have a (-)value
print "All parameters have appropriate signs for npn BJT hence BJT in active region"
# NOTE: Author ha not used any symbol for Base- Emitter junction reverse voltage But I have used 'VBEr' for it.
# ERROR :sign of IE is given wrong in the book in part(i) and sign of IC2 in part(ii)
# In part(i) Correct Formulae of vC3 is vC3 =IC3*RL3 but given in book is vC3 =(-)IC3*RL3 because author has included the (-)ive sign or the polarity of IC3 in the formulae
# IN book in part(ii) mistakenly it is written as vB=V_0 =-0.7 V but Correct expression is vB=V_1=-0.7 V because vB is at high at V_1=-0.7 V
# In part(ii) Author has used formulae vC2=-IC2*RL2 because he has included the (-)ive sign of the IC2 in the formulae but I have used vC2=IC2*RL2 to remove any ambiguity in program
from __future__ import division
VIL=-1.475
print "VIL= %0.2f"%(VIL)," V" # Minimum input voltage level for which output is maximum
VIH=-1.105
print "VIH= %0.2f"%(VIH)," V" # Maximum input voltage level for which output is minimum
VOL=-1.63
print "VOL= %0.2f"%(VOL)," V" # Minimum output voltage level for maximum input level
VOH=-0.98
print "VOH= %0.2f"%(VOH)," V" # Maximum output voltage level for minimum input level
NML=VIL-VOL
print "NML=VIL-VOL= %0.2f"%(NML)," V" # Low level noise immunities
NMH=VOH-VIH
print "NMH=VOH-VIH= %0.2f"%(NMH)," V" # High level noise immunities