home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 334_01 / electron.dem < prev    next >
Text File  |  1991-02-05  |  2KB  |  99 lines

  1. # Electronics demo
  2. #
  3. # Bipolar Transistor (NPN) Mutual Characteristic
  4. Ie(Vbe)=Ies*exp(Vbe/kT_q)
  5. Ic(Vbe)=alpha*Ie(Vbe)+Ico
  6. alpha = 0.99
  7. Ies = 4e-14
  8. Ico = 1e-09
  9. kT_q = 0.025
  10. set dummy Vbe
  11. set grid
  12. set offsets
  13. set nolog
  14. set nopolar
  15. set samples 160
  16. set title "Mutual Characteristic of a Transistor"
  17. set xlabel "Vbe (base emmitter voltage)"
  18. set xrange [0 : 0.75]
  19. set ylabel "Ic (collector current)"
  20. set yrange [0 : 0.005]
  21. set key .2,.0045
  22. set format y "%.4f"
  23. plot Ic(Vbe)
  24. set format "%g"
  25.  
  26. pause -1 "Hit return to continue"
  27.  
  28. # Junction Field Effect Transistor (JFET) Mutual Characteristic
  29. # drain current above pinch off
  30. Ida(Vd)=Ido*(1-Vg/Vp)**2
  31. # drain current below pinch off
  32. Idb(Vd)=Ido*(2*Vd*(Vg-Vp)-Vd*Vd)/(Vp*Vp)
  33. # drain current
  34. Id(Vd)= (Vd>Vg-Vp) ? Ida(Vd) : Idb(Vd)
  35. # drain current at zero gate voltage
  36. Ido = 2.5
  37. # pinch off voltage
  38. Vp = -1.25
  39. # gate voltage
  40. Vg = 0
  41. set dummy Vd
  42. set nogrid
  43. set nokey
  44. set offsets 0, 1, 0, 0
  45. set title "JFET Mutual Characteristic"
  46. set xlabel "Drain voltage Vd (V)"
  47. set xrange [0 : 4]
  48. set ylabel "Drain current Id (mA)"
  49. set yrange [0 : 5]
  50. set label "-0.5 Vp" at 4.1,0.625
  51. set label "-0.25 Vp" at 4.1,1.4
  52. set label "0" at 4.1,2.5
  53. set label "Vg = 0.5 Vp" at 4.1,3.9
  54. plot Vg=0.5*Vp,Id(Vd),Vg=0.25*Vp,Id(Vd),Vg=0,Id(Vd),Vg=-0.25*Vp,Id(Vd)
  55. set nolabel
  56.  
  57. pause -1 "Hit return to continue"
  58.  
  59. # amplitude frequency response
  60. A(jw) = ({0,1}*jw/({0,1}*jw+p1)) * (1/(1+{0,1}*jw/p2))
  61. p1 = 10
  62. p2 = 10000
  63. set dummy jw
  64. set grid
  65. set key
  66. set logscale xy
  67. set offsets 0, 0, 0, 0
  68. set title "Amplitude Frequency Response"
  69. set xlabel "jw (radians)"
  70. set xrange [1.1 : 90000.0]
  71. set ylabel "magnitude of A(jw)"
  72. set autoscale  y
  73. plot abs(A(jw))
  74.  
  75. pause -1 "Hit return"
  76.  
  77. # phase frequency response
  78. set nolog y
  79. set logscale x
  80. set title "Phase Frequency Response"
  81. set ylabel "Phase of A(jw) (degrees)"
  82. plot 180/pi*arg(A(jw))
  83.  
  84. pause -1 "Hit return"
  85.  
  86. # undo what we've done
  87. set dummy x
  88. set nogrid
  89. set offsets 0,0,0,0
  90. set title ""
  91. set ylabel ""
  92. set xlabel ""
  93. set xrange [-10:10]
  94. set autoscale xy
  95. set key
  96. set format xy "%g"
  97. set nolabel
  98. set nolog
  99.