Example 2: Diode Junction Biasing

The simplest solid-state elements to start working with are diodes. Since bipolar transistors can be modeled from simple p-n diodes, it is useful to first understand diode behavior. From the exponential nature of diode current, we can derive the following ideal p-n junction current equation while ignoring effects such as reverse breakdown.

\(TraditionalForm
    \`I\_pn == 
      I\_s\ \((e^\((\((q\ v\_pn)\)/\((k\ T)\))\) - 1)\)\)

Here, (Subscript[I, s]) is the reverse saturation current (which is temperature dependent), q is the electron charge, k is Boltzmann's constant, T is the temperature in degrees kelvin, and (Subscript[v, pn]) is the voltage across the p-n junction (the diode). We can calculate the q/(k T) factor in Mathematica, where 293 kelvin is the standard temperature of STP.

Needs["Miscellaneous`PhysicalConstants`"]

ElectronCharge/(BoltzmannConstant 293 Kelvin)

From this, we can create a small function for use with the diode (again, we are ignoring reverse breakdown effects, as well as capacitive and resistive effects at high frequencies, so the domain of this equation is limited). (Since we are interested only in low-precision numeric computations here, we apply N to the result of the computation to cause machine-precision real numbers to be returned.)

DiodeCurrent[vpn_, Is_] := N[Is (E^(39.6 vpn) - 1)]

Assuming a typical reverse saturation current of 5 microamperes, we can create the following plot of the behavior of the junction (the factor of 1000 converts amperes to milliamperes for a more readable output).

Plot[1000 DiodeCurrent[(Subscript[v, pn]), 5/10^6], {(Subscript[v, pn]), -0.2, 0.15}, 
      AxesLabel -> {"V", "I (mA)"}, PlotRange -> All]

We can see the reverse current domain in this graph. If we increase the range of voltages in the examination of this behavior, the plot appears closer to the ideal diode model of a voltage-dependent on-off switch. In some forms of analysis, it is sufficient to model a diode as a one-way conductor.

Modifying Graph

It is possible to change the above plot by altering the graphics directives. Graphics directives control the way a shape is drawn, for example, by changing the color of the graph or the labels.  So for the above plot we start off changing the color. To change the color of the graph there are a few functions available, (RGBColor[r,g,b], CMYKColor[cyan, magenta, yellow, black] and GrayLevel[level]).  The one we will use is the function RGBColor.  It specifies a color with the specified proportions of red, green, and blue.

Plot[1000 DiodeCurrent[(Subscript[v, pn]), 5/10^6], {(Subscript[v, pn]), -0.2, 0.15}, 
      AxesLabel -> {"V", "I (mA)"}, 
      PlotStyle -> {RGBColor[0, 0, 1]}, PlotRange -> All]

You can also label the plot,or alter the text style. As an example take a look at the following.

Solving a Simple Diode Circuit

The diode equation is easily invertible until one adds resistors and other diodes into the circuit. These more complicated cases with mixed linear and nonlinear components can be handled with Mathematica's internal root finding function, FindRoot. We can set up a simple circuit and solve its loop equation.

A diode circuit. Output voltage is measured across the diode.

Since we are using numeric techniques, this calculation can be performed only when values are substituted for V1 and R1. This class of technique requires us to give a starting guess for our function. If we give a pair of points as a guess, FindRoot will use a secant method, while if we give a single guess, it will use a variant of Newton's method. Here we will assume the reverse saturation current to be 1 picoampere, which is typical for low reverse current diodes such as a PAD-1 (as opposed to the typical signal diode figure we used in the previous example). We will also assume that V1 is 1 volt and R1 is 50 ohms.

FindRoot[1 - DiodeCurrent[Vout, 1/10^12] 50 - Vout == 0, 
      {Vout, {0.4, 0.6}}]

We can extend this analysis to waveform plotting by extracting the result from the solution rule generated by FindRoot. Here we will plot the voltage across R1 since it results in a familiar rectified waveform.

Note that the output of FindRoot is again in the form of a transformation rule.  It is convenient for us to construct a small function that does the root finding for given input voltage and resistance. We can easily enforce that this will evaluate only when Vin is numeric by testing Vin.

voltageDiode[Vin_?NumberQ, R1_] := 
      Vout /. FindRoot[Vin - DiodeCurrent[Vout, 1/10^12] R1 - Vout == 0, 
          {Vout, {0.4, 0.6}}]

We can now create a plot. It is useful to plot the voltage across R1  since this gives us the familiar half-wave rectified voltage.

Plot[2 Sin[t] - voltageDiode[2 Sin[t], 50], {t, 0.001, 4 π}, 
      PlotRange -> All]