# Chapter 9 - Digital Circuits and Logic Families¶

## Example 9_1 Page No. 278¶

In :
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

VCC= 5.00  volts
RB= 10000.00  ohm
RL= 1000.00  ohm
VCS= 0.20  volts
VBS= 0.80  volts
V_gamma= 0.60  volts
ICS = (VCC-VCS)/RL=4.80e-03  ampere
vi= 5.00  volts
IBS=(vi-VBS)/RB=4.20e-04  ampere
Beta_Fmin=ICS/IBS= 11.43


## Example 9_2 Page No. 279¶

In :
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

VD= 0.70  V
part(i)
vA= 0.00  V
vB= 0.00  V
vX=0.00  V
part(ii)
vA= 0.00  V
vB= 5.00  V
vX=vB-VD= 4.30  V
part(iii)
vA= 5.00  V
vB= 0.00  V
vX=vA-VD= 4.30  V
part(iv)
vA= 5.00  V
vB= 5.00  V
vX=vA-VD=vB-VD= 4.30  V


## Example 9_3 Page No. 281¶

In :
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

VD= 0.70  V
part(i)
vA= 0.00  V
vB= 0.00  V
vX=VD=0.70  V
part(ii)
vA= 0.00  V
vB= 5.00  V
vX=VD 0.70  V
part(iii)
vA= 5.00  V
vB= 0.00  V
vX= 0.70  V
part(iv)
vA= 5.00  V
vB= 5.00  V
vX = vA = vB= 5.00  V


## Example 9_6 Page No. 285¶

In :
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

VIL= 0.60  V
VIH= 0.75  V
VOL= 0.20  V
VOH= 1.00  V
NML=VIL-VOL= 0.40  V
NMH=VOH-VIH= 0.25  V


## Example 9_7 Page No. 287¶

In :
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

IIL= -1.60e-03  A
IIH= 4.00e-05  A
IOL= 1.60e-02  A
IOH= -4.00e-04  A
Fan-out=abs((IOH/IIH)=abs((IOL/IIL))= 10.00


## Example 9_8 Page No. 288¶

In :
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

VIL= 0.80  V
VIH= 2.00  V
VOL= 0.40  V
VOH= 2.40  V
NML=VIL-VOL= 0.40  V
NMH=VOH-VIH= 0.40  V


## Example 9_9 Page No. 289¶

In :
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

VIL= 1.00  V
VIH= 4.00  V
VOL= 0.50  V
VOH= 4.50  V
NML=VIL-VOL= 0.50  V
NMH=VOH-VIH= 0.50  V


## Example 9_10 Page No. 291¶

In :
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

V_gamma= 0.60  volts
VEE= -5.20  volts
VBE3=VBE4=VBE5 0.70  volts
RE= 779.00  ohm
RL2= 220.00  ohm
RL3= 245.00  ohm
VREF= -1.29  volts
V(1)= -0.70  volts
V(0)= -1.70  volts
part(i)
VE=VREF-VBE3= -1.99  volts
IE=(VEE-VE)/RE= -0.00  A
IC3=IE= -0.00  A
vC3=IC3*RL3= -1.01  volts
vY=vC3-VBE5= -1.71  volts
vX=vC2-VBE4= -0.70  volts
Base -Emitter reverse voltage,VBEr=V(0)-VE= 0.29  volts
Transistor T1 and T2 off since VBEr < V_gamma
part(ii)
vY=VC3-VBE= -0.70  volts
VE=vB-VBE= -1.40  volts
VBE3=VREF-VE= 0.11  volts
VBE3 is smaller than V_gamma,hence T3 is off
IC2=(VEE-VE)/RE= -0.00  A
vC2=IC2*RL2= -1.07  volts
vX=vC2-VBE4= -1.77  volts
part(iii)
VE3=VE= -1.99  volts
VB3=VREF= -1.29  volts
IC3=(VEE-VE3)/RE= -0.00  A
VC3=IC3*RL3= -1.01  volts
VCB3=VC3-VB3= 0.28  volts
All parameters have appropriate signs for npn BJT hence BJT in active region


## Example 9_11 Page No. 292¶

In :
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

VIL= -1.48  V
VIH= -1.10  V
VOL= -1.63  V
VOH= -0.98  V
NML=VIL-VOL= 0.15  V
NMH=VOH-VIH= 0.12  V