Spice simulation

Earlier in this thread, Bob asked about fitting parameters for fT vs. Ic, and I posted the Excel spreadsheet I use for doing that in post #733 of this thread. I provided only a very brief explanation of what I did. In addition, teodorom asked me in an email for specific details of how I do the parameter fitting in my spreadsheet. I thought it might be best to explain that here, in case anybody else was wondering what I did. The details I'll describe are for the 2SC4793.xls spreadsheet in post #733. This post will end up being pretty long-winded, so I'll probably break it up into multiple posts.

The Toshiba parts are pretty nice, but the data sheets are also pretty sparse. I have an old DOS version of the program SpiceMod that I use to get some of the parameters that can't be obtained (or at least I can't figure out how to obtain them) from the data sheet. I use SpiceMod to get BR, IKR, VAF and VAR, MJC, VJC, MJE, VJE and TR. I assume ISC is zero and FC is 0.5 (the default). I then scan the data sheet graphs of fT vs. Ic, beta vs. Ic, and Ic vs. Vbe into .PNG files. I import these into the Engauge Digitizer software, capture the data points, and export them as .CSV files to import into Excel.

The first step is done in the worksheet tab named "Ic_vs_Vbe". We need to first compute IS and NF. I import the CSV file of Ic vs. Vbe into columns A and B of this worksheet. Column C has the computation of ln(Ic) for the measured data. I then generate a graph of ln(Ic) vs. Vbe, which is on the worksheet named "ln(Ic) vs. Vbe graph". At low currents, the fit to a line is poor because of inaccurate data caused by the data sheet not using a log scale for Ic. At high currents, the graph bends downward. This effect is what causes decreasing beta at high Ic values. So I "eyeball" the region of the graph where the current is not too small and not too large, where it visually fits a line well, at Ic values less than where the beta begins to decrease at high currents. I find the actual data points by hovering the mouse on the graph at the beginning and end of the region. The beginning and end of this range are marked in column D ("fit start" and "fit end"). I do a linear regression of this data in cells F2 and F3 using the Excel "slope" and "intercept" functions. The intercept is ln(IS), and NF can be found as NF=1/(slope*VT) where VT is kT/q. In the spreadsheet, k, T and q are named "boltz", "temp" and "charge" respectively. Names are given to cells using either Insert, Name, Define or typing the name into the "name box" at the upper left of the spreadsheet. Just for verification, I plot the idealized line on the log plot using the data in columns H and I.

Now that IS and NF have been found, the next step is to fit beta vs. Ic to the data sheet curves.
 
Continuing from post #743...

Fitting of beta vs. Ic is also done using the “Ic_vs_Vbe” worksheet tab. The measured data is imported into columns V and W, with a dummy index in column U. The simulated beta is computed by stepping over a range of Vbe values, then computing Ic and Ib as a function of Vbe and the relevant device parameters, and computing the ratio of Ic/Ib. The relevant device parameters are found in columns E and F. There is a graph of simulated and measured beta vs. Ic on the “beta vs. Ic graph” worksheet tab. Before running the solver to fit the parameters, I first put in approximate values of BF, ISE, NE (erroneously named “NEL”), IKF and NK to get the measured and simulated beta vs. Ic reasonably close to each other.

Because I am stepping Vbe rather than Ic, the value of Ic cannot be specified independently. I determine a minimum and maximum Vbe in the first and last cells of column X respectively, then compute a Vbe increment in cell W97. The Vbe values are chosen to sweep the full range of measured Ic without exceeding it. The Vbe increment is used along with the minimum Vbe and the index in column U to sweep the Vbe values. When doing this, the computed Ic values will not in general match up with the Ic values at which beta is measured. To fix this problem, I created the interp_lookup() function. Use Alt-F11 to see the code. This function takes an x value (the lookup), and Excel ranges for the measured x and y values. In this case, the lookup is the Ic value computed from the swept Vbe, the x range is the range of measured Ic values, and the y range is the range of measured beta. So interp_lookup() returns an interpolated value for measured beta at the Ic value computed from the stepped Vbe. One quirk is the return type of interp_lookup(), which is a Variant, rather than a Double. If the value of Ic one wishes to look up in the measured data of beta vs. Ic is below the minimum measured Ic or above the maximum measured Ic, interp_lookup() returns an error. Otherwise, it returns the interpolated beta from the measured data. More on this in a moment.

The Ic and Ib values are computed from Vbe, Vbc and the relevant device parameters using the calc_Ib() and calc_Ic() functions in the Visual Basic code. These functions implement the formulas on this page. Vbe and Vbc appear in columns X and Y respectively. The computed Ib and Ic values appear in columns Z and AA respectively. Computed beta appears in column AB. The measured interpolated beta is in column AC. Note that some of the cells in column AC are blank, even though the interp_lookup() function appears in these cells. This is due to interp_lookup() encountering an out-of-range condition and returning an error as described above. The difference between the computed beta and the measured interpolated beta is in column AD. When the interpolated beta lookup results in an error, an error is shown in these cells.

Finally, in cell AE2, a total RMS beta error is defined as SQRT(1/ROWS(AD10:AD95)*SUMSQ(AD10:AD95)). The solver is invoked to adjust the device parameters in columns E and F to minimize this error. One bug of this procedure is that as the solver adjusts the parameters, the range of Ic can change (because Vbe is fixed and parameters are varied). This can result in the solver encountering an error during the solution process due to the computed Ic values exceeding the range of the measured ones. When this happens, I need to manually change the formula in cell AE2 to exclude the cells having these errors. Fortunately, this doesn’t happen often. If all goes well, the solver will have adjusted the parameters to fit the simulated beta to the measured.

Unfortunately, a side effect of this parameter adjustment is to mess up the curve of ln(Ic) vs. Vbe somewhat. I used a manual, ad hoc approach to fix this. These computations are in columns K through O. I ended up readjusting IS and NF manually to match the simulated and measured curves of simulated ln(Ic) vs. Vbe. After doing this, I re-ran the optimization to once again fit the simulated beta to the measured data. After doing this, both ln(Ic) vs. Vbe and beta vs. Ic simulated and measured data matched up well, so I made no further attempts to refine the results.

It should be noted that all these adjustments were done with an RB value of zero. The final step was to manually tweak RB so that the simulated and measured curves of ln(Ic) vs. Vbe matched well in the high-current region. I did not use the solver for this, as it was quite easy to do visually.
 
After the DC parameters have been found, it’s time to match up simulated and measured fT v. Ic. This is done using the formulas on this page. The worksheet tab for these computations is called “fT_vs_Ic”. There is also a graph of these data on the worksheet tab called “fT_vs_Ic_graph”. Unfortunately, the data sheet does not provide graphs of Cbe and Ccb vs. their associated voltages – only one capacitance at a fixed voltage. I used the values of CJC, VJC, MJC, VJE, and MJE provided by SpiceMod. The adjustable parameters are TF, CJE, XTF and ITF. These parameters are in columns A and B.

The measured fT vs. Ic are in columns E and F, with a dummy index in column D. There is a similar need for interpolating the measured fT vs. Ic data, like what I described for fitting the beta curves, so I won’t repeat that description. The relevant bias voltages and computed Ic are in columns G, H and I respectively. The value of fT is computed using the calc_fT_MHz() Visual Basic function. One quirk of this computation is the need for eliminating the singularity that would occur in the computation of Cbe when the Vbe value is equal to VJE. The method for avoiding this makes use of FC and is described on this page. The Visual Basic code implements this technique for computing Cbe. It also needs to compute gm in order to compute Cbe. It does this using a numerical differentiation technique. One cannot simply use Ic/(NF*VT), because the equations that take into account the high-level injection make this formula invalid at high Ic values.

The errors between simulated and measured fT, expressed as a percentage, are in column L, while the RMS value of these percentages is in cell M3. The solver is invoked to adjust TF, CJE, XTF and ITF to match simulated and measured fT vs. Ic by minimizing the value in cell M3. As you can see from the graphs, the curves match very closely.

Whew! That whole description sure was longer than I originally thought it would be.
 
Forgive the newbie questions! (though I have played with spice and think its a great tool, but like all tools, one must know its limitations). Seems alot of DIYers trust there sims too much. Why do the manufacturers give out spice models that are inadequate? When you make your own spice models, how many tranny samples do you use for your measurements. How accurate are spice simulations? (are they only accurate in the forward active region, do they simulate smoke (kidding), etc?)
 
cbdb said:
Why do the manufacturers give out spice models that are inadequate?

It's hard to generalize about this, but it appears that in the case of On Semiconductor, they subcontract out the creation of SPICE models. In order to get the most accurate models possible, it's necessary to have some device data that's not normally present in typical datasheets. So if one uses only the datasheet data, some guesswork is required. The subcontractor used by On Semiconductor uses a model parameter extraction program called MODPEX. It appears that this tool is buggy. Fitting SPICE parameters to measurement data uses a software technique called optimization, which tries to select the parameter combination that minimizes the errors between simulated and measured data. But optimizers often have the problem of giving an answer that corresponds to a local minimum rather than the best possible minimum. So the optimizer can sometimes converge on a nonsensical answer. This means human intervention in the process is unavoidable if one desires the best possible models. Further, if a subcontractor is paid on a per-model rather than a per-hour basis, this is a disincentive to spend the time necessary to get the best possible models.

When you make your own spice models, how many tranny samples do you use for your measurements.

None. The data is captured from the datasheets using a freeware called the Engauge Digitizer. For each curve on the graph, this software gives about 100 points. The measurement equipment required to get the needed data is prohibitively expensive (Agilent semiconductor parameter analyzer, Agilent network analyzer, etc).

How accurate are spice simulations?

Depends on the device types used and the quality of the models. JFET models are typically pretty terrible no matter how much effort is spent getting the SPICE parameters because the model structure itself is oversimplified. For BJTs, very accurate results can be obtained given accurate enough model parameter values. Scott Wurcer of Analog Devices has reported that some (he won't say what percentage) ADI op-amps designed in the simulator have met all specifications on first-pass silicon. But you can bet they have state of the art measurement equipment and devote the necessary time to get the most accurate model parameters possible. Here is a post by Scott that gives some insight into what's possible. Of course, the typical DIYer doesn't have access to models that accurate, but for the ones I provide, I try to do the best job I can given the data available on the datasheet.
 
cbdb said:
Silly me, I thought you actually measured real transistors.

Well, AFAIK, the device vendors actually measure real transistors. But they could be fake I suppose :).

I'm suprised that ON dosnt make there own models (or at least test them?). Dosnt a better model sell devices?

Dunno. Maybe they just think that providing models is little more than a necessary evil, and so they don't allocate the necessary resources to it. I can only speculate about that.
 
Disabled Account
Joined 2007
cbdb said:
Seems alot of DIYers trust there sims too much.


Before I developed any amount of trust, I modeled known, tested designs and compared the performance to the simulated versions. Taking the time to find accurate models will put the sim very close to reality.

Andy has done us a great service by working up these models and sharing them with us.
 
Please let me know if these newbie questions are gumming up any other discussions. If I model (with the latest spice and models)a complete power amp and the sim says its "respectible", what are the chances it works? What about HF stablity, the model dosnt start to oscillate does it?
 
Disabled Account
Joined 2007
cbdb said:
Please let me know if these newbie questions are gumming up any other discussions. If I model (with the latest spice and models)a complete power amp and the sim says its "respectible", what are the chances it works? What about HF stablity, the model dosnt start to oscillate does it?


He's an example: Knowing as little as I do, I (with much help) developed a complete working amp with a simulator. The simulator predicted specs that were later confirmed by real measurement on the actual amp.
Stability can be modeled in the sim. Knowing where to look and what to look for is helpful.
 
He's an example: Knowing as little as I do, I (with much help) developed a complete working amp with a simulator. The simulator predicted specs that were later confirmed by real measurement on the actual amp.
Stability can be modeled in the sim. Knowing where to look and what to look for is helpful.

Sounds like youve spent alot of time in spice (you know alot more than you let on) as well as real circuits. All I know is whats left of theories and equations from 25 years ago, and a revived passsion for audio electronics, mostly due to Spice. Thanks again and hope to be more usefull in the future.
 
andy_c said:


It's hard to generalize about this, but it appears that in the case of On Semiconductor, they subcontract out the creation of SPICE models. In order to get the most accurate models possible, it's necessary to have some device data that's not normally present in typical datasheets. So if one uses only the datasheet data, some guesswork is required. The subcontractor used by On Semiconductor uses a model parameter extraction program called MODPEX. It appears that this tool is buggy. Fitting SPICE parameters to measurement data uses a software technique called optimization, which tries to select the parameter combination that minimizes the errors between simulated and measured data. But optimizers often have the problem of giving an answer that corresponds to a local minimum rather than the best possible minimum. So the optimizer can sometimes converge on a nonsensical answer. This means human intervention in the process is unavoidable if one desires the best possible models. Further, if a subcontractor is paid on a per-model rather than a per-hour basis, this is a disincentive to spend the time necessary to get the best possible models.



None. The data is captured from the datasheets using a freeware called the Engauge Digitizer. For each curve on the graph, this software gives about 100 points. The measurement equipment required to get the needed data is prohibitively expensive (Agilent semiconductor parameter analyzer, Agilent network analyzer, etc).



Depends on the device types used and the quality of the models. JFET models are typically pretty terrible no matter how much effort is spent getting the SPICE parameters because the model structure itself is oversimplified. For BJTs, very accurate results can be obtained given accurate enough model parameter values. Scott Wurcer of Analog Devices has reported that some (he won't say what percentage) ADI op-amps designed in the simulator have met all specifications on first-pass silicon. But you can bet they have state of the art measurement equipment and devote the necessary time to get the most accurate model parameters possible. Here is a post by Scott that gives some insight into what's possible. Of course, the typical DIYer doesn't have access to models that accurate, but for the ones I provide, I try to do the best job I can given the data available on the datasheet.


Hi Andy,

These are very good points. I just have one thing to add, which is an elaboration on a point you mentioned. The data sheets often do not have adequate data, or data over an adequate range. Indeed, for reasons that escape me, sometimes the data sheet data is not right. The only way I was able to get any useful data on ThermalTrak transistors insofar as the Vbe vs diode characteristics was to measure some samples myself.

Even for conventional power transistors I have had to resort to augmenting data sheet information with measurements on real transistors. Even for a power transistor, you really want to construct a Gummel plot (Ic and Ib vs Vbe) for a range of collector currents down to about one ma.

If you get a little creative on your test bench, you would be amazed at what you can measure on a transistor sample (especially dc parameters) with relatively inexpensive instruments and a little bit of time and patience.

Cheers,
Bob