Sunday, June 10, 2012

First attempts at simulation

The problem I'm facing, trying to understand whether a circuit will function as planned, is not unusual. The pros handle it in two ways. One way is to build a test board that implements a piece of the design and see how it behaves. The breadboard is my first approximation of this. I've also considered building a real PCB with a representative portion, but the cost of the PCB itself is a significant factor. If I make (or have made) a small, 2-layer board without solder mask, it'd cost about $60, or 1/3rd the cost of the full board. But that's still a pretty limited test.

The other way the pros handle this is to use simulation. There are programs available to model electronic circuits, and these models can be amazingly accurate. Many are built on SPICE, a development of the University of California at Berkeley originally released in 1972, and further developed over the 40 years since. However, these simulations are dependent on having good models of the components.

At first I looked at open-source projects. Direct descendants of SPICE itself are still available, though using them involves coding text descriptions of the circuits (still referred to as a "deck", as in "a deck of punched cards"), running it through SPICE, then using yet another tool to graph the textual output files. Yuck.

One promising package is QUCS, the "Quite Universal Circuit Simulator". I was initially quite impressed with it, but I had trouble getting QUCS to adequately simulate the FETs I'm using. It's not based on SPICE, and therefore requires some translation of the models. QUCS depends on having what's known as Level 1 simulation parameters (things like the dimensions of the channel, the thickness of the oxide between the channel and the gate, etc). The vendor-supplied SPICE models contain mostly Level 3 parameters (higher level definitions) which QUCS won't accept. In an attempt to understand QUCS better I tried simulating a MOSFET that I did have some Level 1 parameters on, the Diodes Inc. BSS138W.  MOSFETs are modeled in two modes, with different formulas for each mode. With QUCS I got an ugly discontinuity at the transition from one mode to the other, which broke any attempt to perform a reasonable simulation. Postings to the QUCS Help forum have received no replies.

My next attempt was a free simulator from Linear Technologies called LTspiceIV. As its name suggests, it's built on SPICE, but with a very nice GUI front-end. It's a closed-source Windows program, but it runs under Wine emulation quite nicely. Even the help functions properly. Being built on SPICE, it accepted the rather complex model Fairchild provides for the FDV301N quite well.

This simulation raises some concerns that have been lingering in the back of my mind for a while. Using 10K Ohm pull-up resistors, as I've been doing on the breadboard, results in horribly long propagation delays through a chain of simple FET inverters. Dropping the resistor to 4.7K Ohms brings the delays back into a usable realm, but I don't understand the difference between the simulation and the real-world performance. I'll have to duplicate my simulation circuit on the breadboard and do a direct comparison.

Unfortunately, LTspice is not happy with the Phillips model for the BSS83. It seems to work OK if the pull-up resistor is less than about 900 Ohms, but above that the simulation generates discontinuities at the same transition point that QUCS has trouble with. This time, however, it produces spikes of +/- 60V and then the simulation goes into an endless loop. Not very useful, I must say.

I'm currently trying to develop a Level 1 model for the BSS83 from the datasheet and the Phillips Level 3 model. Maybe I can guess enough to get something that matches the datasheet closely enough that I can get a useful simulation.

Or maybe I'll build a test PCB.

No comments:

Post a Comment