Spice is a powerful tool for circuit analysis. But it often surprises users with
. holes in its abilities and strange definitions
. lack of industry-wide standards
. the need for the user to model the physics of their circuit, not just draw the schematic

I hope this blog will educate users and promote discussion in these areas.

How to Think Like Spice (creating the circuit model)

How does Spice think?

You’re an engineer. Spice doesn't think like you think.

Spice was written by a group of Professors and grad students at the University of California, Berkeley, over 45 years ago. So it thinks like most of your college professors did - it likes theory and ignores reality.

It simulates by solving matrixes of circuit equations. Circuit equations use ideal electrical elements: resistance, capacitance, inductance. Things we can't buy.

So it follows that we need to go back to college thinking to understand Spice. And that Spice depends totally on us to interpret the physical world into its theoretical world. This process is called modeling your circuit for simulation

You Create the Circuit Model, not Spice

Consider your physical circuit on a PCB. It's built of parts you can buy, each of which if far from a pure electrical element. It has a ground plane with measurable impedance, noisy power supplies, stray coupling between traces, etc.

Spice has ideal electrical elements, its ground node connects all ground points with zero impedance, its voltage sources have zero impedance and are used to provide the power supply voltages in simulation. Ordinary circuit equations don't couple to each other.

So you are the physicist here. How do you take the Physics of your physical circuit and create a schematic for Spice's ideal world that includes enough of the real world imperfections to make a  model accurate enough for your needs. But not totally accurate as that takes forever. This is the major challenge of using Spice.

Keep this concept in mind to guide you in using Spice effectively.

Given the above, notice that the Spice schematic is almost always different from the PCB schematic.

Rule 1  If you find yourself starting to simulate the PCB schematic, stop. You have brain fade.

Working with Spice as a breadboard

An effective way to use simulation is to first gain some understanding of your area of design - from past experience, reading and playing in the lab with a real circuit, playing with the program. Then plan a model of the proposed circuit considering the real world imperfections of the parts you will be using. Keep the model’s schematic to only the bare essentials to start. Enter this schematic into the program and do your initial simulation. Now the important part - confirm that the results of simulation are reasonably close to the results from your lab circuit. No lab circuit? - do some other form of reality checking/testing.

Rule 2  Avoid the beginner’s mistake of assuming that since simulation runs without errors, your schematic accurately models your lab circuit.

Continue with an interactive process of improving your simulation model of your design AND your lab design, repeatedly comparing the two. When they match over time, frequency, etc., you know you can trust your simulation model. Have fun.

Details of modeling your circuit for simulation

How is the schematic for simulation going to differ from your lab or production circuit schematic? Remember that resistors, capacitors, inductors and voltage/current sources in the simulator schematic are mathematically perfect. Parts you can buy always are mixtures of resistance, capacitance and inductance.
Also remember when using a Spice subcircuit that models a complex part, the subcircuit may model only a portion of the behavior of the physical device.

Common imperfections of physical devices
Resistors
inductance for wirewound resistors
Capacitors
series resistance, especially electrolytics where resistance is large and varies strongly with frequency and temperature. Also far from perfect are ceramic caps made from high dielectric materials (Z5u, etc.).
Inductors, transformers
series resistance, self resonance with the winding capacitance (at surprisingly low frequencies) and usually a series resonance at much higher frequency. If there is a magnetic core, it may saturate and has losses that go up very rapidly with frequency.
Circuit board
Even the ground plane has significant resistance if you are pumping several amps through it. Long traces have significant inductance at higher frequencies. And stray capacitance, etc.

subcircuit limitations
Op Amps
Manufacturers supply models (in the form of Spice Subcircuits) for many of the Op Amps they make. Be aware that the models are all greatly simplified in number of transistors/FET’s compared to the actual Op Amp. They also differ widely in the amount and accuracy of the functionality they include. If your design depends on Op Amp input noise, slew rate, distortion, input common-mode rejection versus frequency, power supply rejection or handling input or output signals near the supply rails, you need to verify that the manufacturer's Op Amp model you use
  1. models these areas
  2. matches a real world Op Amp in the lab close enough for your purposes

Also note that production Op Amps have wide tolerances on GBW (gain-bandwidth product) from lot to lot. The manufacturer’s model usually has a typical value.
Power FET’s
Manufacturers use Subcircuits to model Power FET’s. These vary in complexity and accuracy. See discussion of Op Amp above.

Spice model limitation at High Frequency / fast Rise Time
The general purpose Spice models (.Model) for diodes, FETs and transistors do not include any lead inductance. You or the manufacturer can write a Spice .Subckt which contains the .Model plus lead/package inductances. Power MOSFETs are modeled using a .Subckt and usually have these inductances.

switching circuits with inductors/transformers
The inductors and transformers in Spice have no winding capacitance. Switching an ideal inductor that has current flowing can result in an infinite voltage spike with zero rise time. Simulation will fail (you can almost feel the simulated gamma rays coming out of the screen). Add parallel capacitance and/or resistance to limit bandwidth and limit spike rise time/amplitude during switching.

Power Supplies
Remember that Spice voltage sources turn on instantly. Real power supplies do not. This sometimes results in Spice finding a different DC Bias solution than the actual circuit has! Fix crazy DC bias voltages by adding NodeSets to the schematic.
Spice voltage sources have such low impedance over all frequencies that they will short out DC drop, ripple and noise that would appear in any real world circuit. So consider adding series resistance (and possibly inductance) if using a voltage source to model a real power supply or voltage regulator.

Ground Layout and Impedance.
Spice’s ground symbol provides the perfect, zero impedance connection between all points. No real circuit or ground plane is like this. Ground impedance issues are complicated. See EDN.com for a detailed article on ground currents and grounding.

Too Much Perfection!
Many circuits improve in performance as part values match or track each other. You can get some awesome numbers with Spice's perfect components.

No comments:

Post a Comment