Common Spice Problems.

Advertisements

What to do if your spice simulation just refuses to give a sensible answer. Spice is a very powerful simulator but it can be temperamental. This article is a distillation of lessons I have learned about learning to live with Spice.

First I will discuss three common problems:

1) The solver won’t even start.

This usually means that you have made a mistake in your schematic. Common problems include failing to put in a ground, failing to connect all components, failing to give a value to all components. Spice will usually give you an error message that points to the source of the problem.

2) The simulator does not converge on a solution or takes a very long time to reach a solution.

This means that SPICE is having a hard time solving the system of equations that represent your circuit.

Unfortunately this is a regular occurrence for the type of non-linear switching circuits that are common in power electronics. Even the humble diode can cause endless problems. There are several tricks you can use to make your circuit more spice friendly and I have listed the ones I use on the next page.

3) The simulator happily converges but the solution it presents is crazy.

This is the most insidious behaviour of spice. Remember that Spice uses a set of mathematical equations to represent your circuit. It then solves these equations to predict the real life currents and voltages that would flow. Most of the time the solution to these equations is a good reflection of the behaviour of the circuit.

Sometimes however the solver throws up parasitic solutions, which bear no relation to the real life

behaviour of the circuit involved. Usually the parasitic solution will have crazy oscillations or some other easy to spot inconsistency. The bottom line is that you should never run a spice simulation (or indeed any other simulation package) without some idea of what the answer will look like. You need to be able to see that the solution presented makes sense.

If you really have no idea what the answer will look like then simplify the circuit and simulate that first to get a clue as to what the more complex circuit should do.

If you suspect your Spice circuit is giving a crazy parasitic solution then use the steps below to make it more SPICE friendly.

4.) Your waveforms look OK until you zoom in on the details.

LTspice compresses its output datafiles by default. This reduces the file size considerably but the compression is lossy and some of the fine detail may be lost or corrupted. A typical example would be if you zoom in on a waveform expecting to see small sinusoidal ripple but instead see a triangle wave.

If you suspect that this is happening to you then try disabling compression. To disable compression once (just to try it out) use the control panel, go to the compression tab and un-tick first and second order compression. To disable compression every time a schematic is simulated then add the following directive: .option plotwinsize=0

I recommend turning off compression every time you need to zoom in on the details of a waveform at least for the first pass. Be aware however that this will eat up disk space and memory.

Steps to make a circuit more SPICE friendly

Advertisements

1. Always use simple generic versions of diodes, transistors and op amps before you use more complex

models. In most cases the generic model will solve much quicker and give you a pretty good idea of how the circuit will behave. You can always add in more complex models later. I have given examples on the next page of how to enter simple generic components.

2. Adding a small resistance in series with inductors or capacitors helps damp out any oscillations. You

can do this by right clicking on the component and changing the series resistance value. A value of 0.1

Ohm often works but bewares if this is not much smaller than the other resistors in your circuit it will

interfere with your results.

3. Avoid zero rise times in pulse sources (square waves). Make sure the pulse has a definite rise time. It can be very small (eg nano-seconds) but it shouldn’t be zero.

4.If the solver seems to be missing details of waveforms try using a small value for maximum time step in the simulation command settings. This will slow down your simulation but should allow the solver to more accurately reflect what is happening in your circuit.

5. Trivial but often overlooked: Make sure you simulate for long enough to see what is happening (stop time in the simulation commands) and make sure that any voltage sources repeat for the full duration of your simulation (number of cycles in the voltage source parameters).

6. Try skipping the initial operating point solution. Before running a transient simulation Spice runs an

initial operating point solution to work out the starting currents in inductors and starting voltages on

capacitors. These may not be what you expect. You can disable this and all inductors will start with 0A and capacitors will start with 0V. You will probably have to run this simulation for many cycles however to get it to converge on the steady state conditions.

7. The solver doesn’t actually use the schematic instead it uses the net list extracted from the schematic.

You can look at the net list from the view menu. Even if you aren’t a SPICE expert it is pretty easy to see what is going on and you can sometimes spot mistakes in the net list.

8. In desperation you could try changing the solver settings on the SPICE tab of the Control Panel. This

allows you to select different integration methods etc. I generally wouldn’t recommend this except as a last resort.

9. Divide and conquer – If you have a large circuit that refuses to solve – Start again with a small piece. Get that working and keep adding to it.

10. If all else fails perhaps SPICE is reflecting the actual behaviour of your circuit. A typical case of this

was the case of a switching circuit simulation that showed crazy spikes of thousands of Amps. At first the solver was thought to be at fault but in fact the timing of the switches was incorrect and they were shorting out the supply giving the extreme currents.

Advertisements

Generic Component Models in LTSPICE

ComponentGeneric Version
DiodeUse the Spice Directive command to put the following model statement on your schematic: .model MyDiode D(Ron=.1 Roff=1Meg Vfwd=0.7) When you enter a diode hold down Ctrl and Right Click on it. This will open the component attribute editor. Change the value attribute to MyDiode
Switching TransistorsYou can use a voltage-controlled switch to replace most switching transistors. First use the Spice Directive command to put a model statement on your schematic: .model MySwitch SW(Ron=.1 Roff=1Meg Vt=1) Enter the switch (Component SW) on the schematic. Right Click to get the component attributes and change the value to MySwitch. This switch will be closed if the control voltage is greater than Vt and open otherwise
npn transistorUse the Spice Directive command to put the following model statement on your schematic: .model MyNpn NPN(Bf=100) When you enter an npn transistor hold down Ctrl and Right Click on it. This will open the component attribute editor. Change the value attribute to MyNpn Note: Bf is the current gain (Beta). You can change this to another value if required
Mosfet (NMOSUse the Spice Directive command to put the following model statement on your schematic: .model MyMosfet NMOS(VTO=2 KP =100 Rd=.1) When you enter an NMOS transistor hold down Ctrl and Right Click on it. This will open the component attribute editor. Change the value attribute to MyMosfet Note: VTO is the gate threshold voltage, KP is the trans-conductance and Rd is the on state drain source resistance.
IGBTLTSpice doesn’t have a native IGBT model at present. Suggest you use a voltage controlled switch (SW) or a Mosfet.
Op AmpIn SPICE terms an op amp is not really a model it is a sub-circuit (ie it is made up of combination of the basic model elements). However LTSpice has a handy universal op amp sub-circuit with 4 levels of complexity. To use it select the UniversalOpamp component from the op amp library (it’s the very last one). You can select the level by Right Clicking on the component (NB not CTRL right clicking) Level 1 is a basic 1 pole op amp that doesn’t even use supply rails Level 2 is my favourite. It has supply rails, voltage, current and slew rate limits. For more info on the parameters of the universal op-amp look at the file C:\Program Files\LTC\SwCADIII\examples\Educational\UniversalOpamp.asc Sometimes I find that the default bandwidth (GBP) and Slew rate (Slew) are too slow particularly if you are simulating a comparator – You can increase these in the component attribute menu
TransformerSpice doesn’t have a native transformer element but you can create a transformer using coupled inductors with the mutual inductance (K) element. First create an inductor for each winding. Use the Ind2 symbol in LTSpice because it has a dot showing the polarity of the winding. Choose a large inductance for the primary winding (for example 10H) and then the inductance s of the other windings must be proportional to the turns ratio squared. For example: L1 = 10H, L2 = 10H *(N2/N1)2 , L3=10H*(N3/N1)2  etc. Now use the spice directive command to add the spice line: K1 L1 L2 L3 1 Where L1, L2 etc are the inductors corresponding to the windings Warning about transformers in Spice – Transformers are particularly prone to giving strange results if the initial conditions are not correctly set. If you have a transformer you may wish to skip the initial operating point solution in the simulation command menu.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s