As you stated, there are 3 parameters that dictate the DC response of a diode. Those are the saturation current (IS), the emission coefficient (N), and the ohmic resistance (RS). I was able to fit the curve with a fairly high accuracy, so I'll document my model procedure.
The SPICE model for the diode closely matches the Schokley diode equation:
If = IS(e^(Vf/(N*Vt)) - 1)
where Vt = kT/q = 26mV
at room temperature.
Get actual values from the graphs provided in the datasheet to use for comparison. The more points the better, and the more accurate the better. Below is a table that I estimated from the figure you provided:
Vf If (mA)
1.3 0.001
1.4 0.010
1.5 0.080
1.6 0.700
1.7 5.000
1.8 20.000
1.9 40.000
2.0 65.000
2.1 80.000
Plug the values into Excel, and change the y-axis to a log scale. You should get a graph that looks identical to the original graph from the datasheet. Add another column for your graph, with If calculated from the forward voltage and the constants IS and N. We can use this configuration to iteratively find IS and N.
Solve for IS and N. We are trying to match the linear part of the graph (1.3 <= Vf <= 1.7). Adjusting IS will move the curve in the y-axis. Get the calculated graph to the same order of magnitude. The next step is to find the emission coefficient (N). N affects both the amplitude and the slope, so some adjustment of IS may be necessary to keep the curve in the same ballpark. Once the slopes match (the lines are parallel), trim IS so that the calculated data matches the datasheet values. I got IS = 1e-18
, and N=1.8
for the diode you listed.
Identify RS. This is a bit tricky. RS is responsible for the curving of the current from 1.7V and above. Consider modeling the ohmic resistance as a resistor in series with the diode. As the current through the diode increases, the voltage drop across the ohmic resistance causes the forward diode voltage Vf to increase slower. At small currents, this effect is negligible.
The first thing to do is to get a ballpark estimate of RS to use in the more accurate solutions. You can calculate the effective value of RS from the datasheet values by back-calculating for Vf using the measured If. The voltage difference between the input value and the calculated Vf can be used with the forward current to generate a resistance. At the higher currents, this will be a good starting value.
To plot the diode current using RS, you need to first calculate the diode Vf given a voltage for the resistor-diode series combination. Wikipedia lists an iterative function - it converges easily if the resistor voltage drop is significant. This function was easy enough to set up in Excel. For Vf values below 1.8, I hard-coded the input value because the iterative function did not converge. Then take this Vf value to calculate the If of the ideal diode. I plotted this with the original datasheet graph.
Using trial and error, you should be able to get a RS value that gets pretty good overlap with the datasheet values. All that's left is to throw the model together in SPICE to verify your work.
Below is my diode model that I verified using HSPICE. The simulation data is almost a perfect overlay for the datasheet graph.
.model Dled_test D (IS=1a RS=3.3 N=1.8)
I used this article, which helped a lot with the diode spice parameters.
I cleaned up my spreadsheet, and tyblu has made it available for download here. Use at your own risk, results not guaranteed, etc... etc...
After having experimented a lot, and read some more, I found an answer to my question.
Simple switch model approach
After seing a demo on the switch models I finally understood the parameters and workings of the SPICE switch model, which I will explain below.
Switch model syntax
.model MODEL SW VT VH RON ROFF
SX N+ N- NC+ NC- MODEL <ON><OFF>
(where a RegEx for X is [a-z0-9]{0,7}
.)
What the manual doesn't explain
Although easily guessed:
- The
N
nodes are the controlled nodes, which will be "short-circuited" or "opened" (continue reading for quoting reason.)
- The
NC
nodes are the controller nodes, from which the "switching" voltage will be read.
The switch is essentially on when the voltage accross the controlled nodes is positive, and off otherwise, this is also easily guessed.
Now, the hysteresis voltage makes it possible for the user to define a "dark voltage interval", in which the switch will not be able to change its state. This interval is defined by [VT-VH, VT+VH]
, and is what provides hysteresis to the model. This is interpreted as follows:
- A voltage over
VT+VH
will turn the switch on.
- A voltage below
VT-VH
will turn the switch off.
Because these are the only conditions ruling the model, the model needs an initial on or off state if the initial voltage across the controller nodes is within the dark voltage interval. This initial state is optional otherwise, for it would be overridden.
The current controlled switch model is analogous to this one, but take note about that between the controlled nodes there is a short circuit.
Sample circuit
Voltage controlled switch
V0 1 0 SIN(0 12 2 0 0)
S1 1 2 1 0 simpleswitch OFF
R2 2 0 10
.model simpleswitch sw vt=0 vh=6 ron=0.1 roff=1Meg
.control
tran 1e-3 1 uic
plot v(2)/10.1 v(1)/10.1 $ voltage/(resistor resistance + switch on resistance)
.endc
Above you can see the plot resulting from the simulation of the circuit source code. The blue curve corresponds to the source voltage, the red curve to the voltage across the resistor.
As it can be observed from the code, the so called dark voltage interval is [-6,6]
, at which the switch does nothing (remembers its last state). As soon as the voltage across the controller nodes is over 6 V, there is a current flowing through the resistor (and thus non-null voltage across it); as soon as the voltage is below -6 V, the current flow is cut.
Best Answer
You can model it with two customized (complementary) MOSFET models connected as a typical CMOS push-pull output.
Here is a link to a video How to model a MOSFET using a Datasheet showing how to model a MOSFET from a datasheet. If you google you can probably find other similar tutorials on creating models.