#Reverse Saturation current of diode
import math
#variable declaration
I=40*10**-3 #forword bias current in A
V=0.25 #forword bias voltage in Volt
T=20 #junction temperature in degree C
T=T+273 #junction temperature in degree K
ETA=1 #For Ge
e=1.6*10**-19 #in Coulamb(electronic charge)
k=1.38*10**-23 #in J/K(Boltzman Constant)
#Calculation
#Formula : I=Io*(exp(e*V/(ETA*k*T))-1)
x=math.ceil((e*V/(ETA*k*T)))
Io=I/(math.exp(x)-1)
Io=math.ceil(Io*10**8)/10**8
#Result
print("Reverse saturation current in micro Ampere : %.2f "%(Io*10**6))
#Value of forword voltage
import math
#variable declaration
Io=10*10**-6 # reverse saturation currrent in A
I=1 # forword current in Ampere
ETA=2 # For Si
T=27 # room temperature in degree C
T=T+273 # room temperature in degree K
e=1.6*10**-19 # in Coulamb(electronic charge)
k=1.38*10**-23 # in J/K(Boltzman Constant)
#Calculation
#Formula : I=Io*(exp(%e*V/(ETA*k*T))-1)
V=(ETA*k*T/e)*math.log(I/(Io)+1)
V=math.floor(V*100)/100
#result
print("Forward Voltage across the diode in Volt :%.2f"%V)
#DC Current, DC Voltage, Ripple Factor
import math
#Variable Declaration
RL=1 #load resistance in kOhm
#rf<<RL
Vrms=200 #in Volt
#Part (i)
Vo=Vrms*math.sqrt(2) #in volt
Idc=Vo/(RL*10**3*math.pi) #in Ampere
print("(i)\nDC current in load in mA :%.0f"%(math.floor((Idc*10**3))))
#Part (ii)
Vdc=RL*10**3*Idc #in Volt
print("\n(ii)\nDC voltage across load in volt :%.0f"%(math.floor(Vdc)))
#Part (iii)
#Gamma=sqrt((Irms/Idc)^2-1)=sqrt((Io/2)/(Io/%pi)-1)=sqrt((%pi/2)^2-1)
Gamma=math.sqrt((math.pi/2)**2-1) #unitless
print("\n(iii)\nRipple factor :%.2f "%(math.floor(Gamma*100)/100))
#Part (iv)
PIV=Vrms*math.sqrt(2) #in volt
print("\n(iv)\nPeak Inverse Voltage in volt :%.0f"%(math.floor(PIV)))
#Average dc current rms current rectifcation efcieny PIV
import math
#variable declaration
rf=20.0 #in ohm
RL=980.0 #in Ohm
Vrms=50.0 #in Volt
Vo=Vrms*math.sqrt(2) #in Volt
Io=Vo/(RL+rf) #in Ampere
#Part (i)
Idc=2*Io/math.pi #in Ampere
print("(i)\nAverage DC current in mA :%.0f"%(math.floor(Idc*10**3)))
#Part (ii)
Irms=Io/math.sqrt(2) #in Ampere
print("\n(ii)\nrms value of load current in mA :%.0f"%(math.ceil(Irms*1000)))
#Part (iii)
Vdc=RL*Idc #in Volt
print("\n(iii)\nDC output voltage in volt :%.1f"%(math.floor(Vdc*10)/10))
#Part (iv)
ETA=(Idc**2*RL/(Irms**2*(RL+rf)))*100 #Rectification Efficiency in %
print("\n(iv)\nRectification Efficiency is %.1f%%"%(math.ceil(ETA*10)/10))
#Part (v)
PIV=2*Vo #in volt
print("\n(v)\nPeak Inverse Voltage in volt :%.1f"%PIV)
#Minimum value of resistance
import math
#Variable declaration
Vin=40 #in volt
VZ=10 #in volt
Vo=10 #in volt
IZmax=50 #in mA
IL=0 #in mA
#calculation
#Formula : I=IZ+IL=IZmax+0
I=IZmax+0 #in mA
#Formula : VZ=Vin-R*I
Rmin=(Vin-VZ)/(I*10**-3) #in Ohm
#Result
print("Minimum value of resistance in Ohm :%.0f "%Rmin)
#Value of series resistor
import math
#variable declaration
Vmin=15 #Minimum input voltage in volt
VZ=6.8 #Voltage across zener in volt
Vo=VZ #output voltage in volt
Vsr1=Vmin-Vo #Voltage aross series resistance in volt
print("If R is the series resistance, Total current in series resistance in Ampere : I=Vsr/R=8.2/R ")
ILmin=5 #in mA
print("current in zener diode in Ampere :IZ=I-IL=(8.2/R-IL*10-3).............eqn(1)\n");
Vmax=20 #mximum output voltage
Vo=VZ #output voltage in volt
Vsr2=Vmax-Vo #Voltage aross series resistance in volt
print("Current in series resistance circuit in Ampere : I=Vsr/R\n")
ILmax=15 #in mA
print("current in zener diode in Ampere :IZ=I-IL=(Rs/R-IL*10-3)..............eqn(2)\n")
print("For Zener diode to work as voltage regulator,(1) and (2) must be same.");
print("(8.2/R-IL*10-3)=(13.2/R-IL*10-3)")
R=(Vsr2-Vsr1)/(ILmax*10**-3-ILmin*10**-3) #in Ohm
print("\nRequired value of Series Resistor in ohm : %.0f"%R)
#Current limiting resistance and dissipated power
import math
#variable declaration
Vin=18 #in volt
IZ=20 #in mA
ILav=(5+35)/2 #in mA
VZ=12 #in volt
Vo=12 #in volt
#Calculation
I=IZ+ILav #in mA
R=(Vin-Vo)/(I*10**-3) #in Ohm
P=(I*10**-3)**2*R #in Watts
#Result
print("Current limiting resistance in Ohm : %.0f"%R);
print("Power disspation in resistance in Watt :%.2f "%P);
#Maximum and minimum input supply voltage
import math
#Variable declaration
R=1 #in kOhm
RL=5 #in kOhm
VZ=10 #in volt
Vo=10 #in volt
P=250 #in mW
#Calculation
IL=Vo/RL #in mA
IZmin=0 #in mA
IZmax=P/VZ #in mA
Imin=IZmin+IL #in mA
Imax=IZmax+IL #in mA
Vin_min=VZ+Imin*10**-3*R*10**3 #in volt
Vin_max=VZ+Imax*10**-3*R*10**3 #in volt
#Result
print("The input voltage ranges from %.0fV to %.0fV"%(Vin_min,Vin_max));
#Output voltage voltage drop and current in zener diode
import math
#Variable Declaration
R=5 #in kOhm
R=R*1000 #in Ohm
RL=10.0 #in kOhm
RL=RL*1000 #in Ohm
Vin=120.0 #in Volt
VZ=50.0 #in Volt
#Part (i)
#calculation
Vo=VZ #in Volt
#Result
print("\n(i)\nOutput voltage in volt :%.0f"%Vo)
#Part (ii)
#calculation
VR=Vin-VZ #in Volt
#Result
print("\n(ii)\nVoltage drop across series resistance in volt :%.0f"%VR);
#Part (iii)
#Calculation
IL=Vo/RL #in Ampere
I=VR/R #in Ampere
IZ=I-IL #in Ampere
#Result
print("\n(iii)\nLoad Current in mA :%.0f"%(IL*1000))
print("Current through resistance R in mA :%.0f"%(I*1000));
print("Load Current in mA :%.0f"%(IZ*1000))
#Maximum and Minimum LED current
import math
#Variable declaration
VDmin=1.5 #in Volt
VDmax=2.3 #in Volt
VS=5.0 #in Volt
RS=270.0 #in Ohm
#Calculation
Imin=(VS-VDmax)/RS #in Ampere
Imax=(VS-VDmin)/RS #in Ampere
#Result
print("Minimum value of LED current in mA : %.0f"%(Imin*1000))
print("Maximum value of LED current in mA : %.0f"%(math.ceil(Imax*1000)))
#Frequency range of tuning circuit
import math
#VAriable declarion
C1min=10 #in pF
C2max=50 #in pF
L=5 #in mH
L=L*10**-3 #in H
#Calculation
#Formula : CT=C1*C2/(C1+C2)
#Minimum
C1=10 #in pF
C2=10 #in pF
CTmin=C1*C2/(C1+C2) #in pF
CTmin=CTmin*10**-12 #in F
#Maximum
C1=50 #in pF
C2=50 #in pF
CTmax=C1*C2/(C1+C2) #in pF
CTmax=CTmax*10**-12 #in F
#Formula : f=1/(2*%pi*sqrt(L*C))
#maximum :
fmax=1/(2*math.pi*math.sqrt(L*CTmin));
#minimum :
fmin=1/(2*math.pi*math.sqrt(L*CTmax));
#Result
print("The frequency of tuning circuit ranges from %.3fMHz to %.3fMHz."%(fmin/10**6,fmax/10**6));
#Note : Answer in the book is wrong.
#Diode Capacitance
import math
#Variable Declaration
C1=21.0 # in pF
V1=4.0 # in volt
V2=9.0 # in volt
#Calculations
print("C is proportional to 1/sqrt(V)")
print("So, C2/C1=sqrt(V1/V2)")
C2=math.sqrt(V1/V2)*C1 #in pF
#Result
print("At reverse bias 9V, Diode capacitance in pF : %.0f"%math
#Photocurrent
import math
#Variable Declaration
R=0.90 #in A/W
Pop=1.0 #in mW
#Part (i)
#calculation
IP=R*Pop #in mA
#Result
print("(i)\nPower of incident light 1mW, Photocurrent in mA is :%.2f"%IP);
#Part (ii)
#Result
print("\n(ii)\nHere IP is not proportional to Pop(for Pop>1.5mW)")
print("Hence Photourrent can not be calculated.")
#Responsivity of InGaAs photodiode
import math
#variable declaration
ETA=70.0 #in %
Eg=0.75 #in eV
Eg=Eg*1.6*10**-19 #in Joule
h=6.63*10**-34 #Planks constant in J-s
c=3*10**8 #speed of light in m/s
e=1.6*10**-19 #in coulamb
#Calcualtions
lambda1=h*c/Eg #in meter
R=(ETA/100)*e*lambda1/(h*c) #in A/W
#Result
print("Wavelength in nm :%.1f"%(lambda1*10**9))
print("Responsivity of InGaAs photodiode in A/W :%.3f"%R)
#Equilibrium contact potential
import math
#variable declaration
W1=2.5 #in eV
W2=1.9 #in eV
#Calculation
ContactPotential=W1-W2 #in Volt
#Result
print("Contact potential in Volts :%.1f "%ContactPotential)