import math #(a) #initialisation of variables E=10 #E in V R=1 #R in Kohm #Calculations Id=E/R #Eq.(2.2) Vd=E print "The current Ic is= %fmA "%(Id),";Vd=0V" print "The diode voltage is= %fV"%(Vd),";Id=0A" print "The resulting load line appears in Fig. 2.4. The intersection between the load line and the characteristic curve defines the Q-point as" print "The level of VD is certainly an estimate, and the accuracy of ID is limited by the chosenscale. A higher degree of accuracy would require a plot that would be much large and perhaps unwieldy" #(B) print "(B)" Ir=9.25 #Ir in mA Vdq=0.78 #Vdq in v Vr=Ir*R print "Vr = Ir*R = Idq*R %d="%(Vr),"or" Vr = E-Vdq print "Vr = E-Vdq = %f" %(Vr) print "The difference in results is due to the accuracy with which the graph can be read. Ideally,the results obtained either way should be the same." #Graph solution to example 2.1 import numpy as np import matplotlib.pyplot as plt Vd = np.linspace(0.0,10.0) Id = np.linspace(0.0,10.0) Id= -Vd + 10 plt.plot(Vd, Id) Vd = [0,0,0.1,0.1,0.2,0.2,0.3,0.3,0.3,0.3,0.4,0.5,0.6,0.7] Id = [0,0,0,0,0,0,0,0,0.1,0.1,0.3,0.7,2.0,10.0] plt.plot(Vd, Id,'yo-') plt.xlabel('Voltage (v)') plt.ylabel('current (mA)') plt.title('About as simple as it gets, folks') plt.grid(True) plt.savefig("test.png") plt.show() print "example 2.2:" print "repeat the example 2.1 for R =2"