Hi everyone. I have been trying to avoid asking for help and searched the forum for anything that would help, but I have accepted the fact that I need your expert guidance. I am simulating a simple boost converter. It took quite a while (over a week), but I eventually got a working simulation with the ngspice built-in SPICE models (C,L,NMOS,R). From the beginning I was struggling with the simulation terminating with the timestep too small error. I eventually found a post that mentioned that high frequency transients can cause such an error, so I added filters, slowed slew rates, etc to soften everything as much as reasonable. I would find a configuration that would run for a while without errors, but always I run back into the same issue. Sometimes I spend a day or so trying to get the sim happy again. I have tried adjusting the max step time, up and down, sometimes it helps, often it does not.
I feel like I might be missing something fundamental that is giving me so much problem with this. I expected to find this issue pervasive throughout the forum, but the relative scarcity seems to indicate that the simulations should not be this fragile, and I am doing something wrong. I wonāt bother posting the circuit yet, but can if that would be helpful. I am really wanting to be able to use the simulator right in KiCAD but I am loosing valuable time at this point. Any help appreciated.
In my limited experience with ngspice, the time step error is only rarely about the time step. It often means that thereās something else subtly wrong. The fact that it sometimes works is a odd one thoughā¦
With any ngspice issue, it would be very helpful (for others to debug) if you can upload the whole project including spice libraries, preferably in the same folder as everything else. zip file compression of the whole folder is preferred.
āTimestep too smallā is just one the many useless error messages in ngspice.
It basically tells you your simulation wonāt converge, which again means something else is wrong.
It can be the model itself, pin sequencing, an instable circuit, you name it.
I have never used NGSpice but I design power and I have been using LTSpice in my job a lot recently. I am NOT AN EXPERT with LTSpice or any simulation program. My thing is much more design and much less simulation. Butā¦that being saidā¦
I have had LTSpice runs advancing at femtoseconds/second. When this happens the simulation is usually in trouble. Microseconds/second are more normal.
Is there any selection between things like gear integration or trapezoidal or modified trapezoidal integration? If so, try those various options.
I have not used ngspice, so canāt offer a specific answer. I have used ltspice and various others going back to the days of the fortran distribution on 9-track tape
I will second the Gear method for integration, and other adjustable sim parameters ā that helped me years ago when doing some long and problematic transient sims that often refused to converge.
You can also try some tricks like temporarily replacing sections of the circuit with macromodels that have minimal computational needs ā when you isolate an area of the circuit you can investigate more.
Another thing I found handy at times is to lower circuit impedances ā I mean a brute-force adding a 1G-resistor-from-each-node-to-ground sort of thing. Add em on all the nodes and see if it converges, then remove some resistors, re-testā¦ If you have very fast-slewing transitions you might add a bit of capacitance to some nodes. I donāt know quite how the number-crunching goes in spice, maybe something to do with very-large or very-tiny numbers, but there are some practical ways you can massage your circuit to help the simulation.
I appreciate the advice, thank you. I donāt know how to play with simulation integration options in ngspice. Anyone know? I did find that putting in lots of transient softening stuff helped. I have been rebuilding the circuit from scratch again to try to find where things start going sideways and will upload the project when it gets jammed up again. I am currently thinking that the built in VDMOS n-channel mosfet model and its associated default parameters may be the issue. I am using lots of body diode action in my circuit, and it seems like this model may be quite temperamental in that department because when I replace the mosfet (with gate shorted to source) with a diode, it seems to be happy.
So my current course of action is to find an actual model for an actual nmos that I will use in the circuit. Any suggestions appreciated. My goal is to purchase the cheapest (or close to cheapest) nchannel mosfet on lcsc.com and use that. This particular circuit doesnāt need to be super efficient because even though it is on a battery operated device, it is something that will be used for a few seconds once every few days, but there will be hundreds of them. So cost is much more important than efficiency. I have read all the horror stories about finding models. I donāt know anything about mosfet models, and havenāt the slightest clue what most of those parameters mean or do in the various built in models, and donāt really care to learn since this is a small part of a much larger project. So if anyone really knows this stuff, I would really appreciate your guidance. Happy to pay if that is helpful.
Suggestions on mosfets and models much appreciated.
Thank you,
Daniel
Some simulator options for simulating power supplies: .options method=gear chgtol=1e-11 reltol=0.01 rshunt=1G rseries=0.05 cshunt=1p trtol=1
For details see ngspice manual, chapter 15.1.
If you want more info please add a better specification of what your circuit is supposed to do. What we know right now is: Boost converter, cheapest NMOSFET. This is not very precise.
In the old days, we would purchase a dozen or so candidate parts, solder up a little proto circuit for testing them, sit down with a decent oscilloscope and select the best part and a few substitutes.
Simulation has its place for me. Simple analog ac stuff like tweaking response. Seeing the response envelope as components vary over their tolerance ranges. Adding noise sources here and there to find which opamp needs to be pricey and which ones do not. Adding a source in the feedback loop of a power supply to find phase/gain response. Transient startups. Using crude timesteps to get far enough out time to grab cap voltages and inductor currents, and then plugging those in as initial conditions for a fine-timestep run. But for me Iāve never felt the need to completely model everything in a circuit when crude models let me run a simulation much faster and I can spent the time detailing just a small area of interest. Though I realize that there are many simulation use-cases I have never explored. Thereās no replacement for good bench testing though.
Hi all, so after a break and then spending more time on this I have made some progress. I got a windows laptop and tried the windows version wondering if the linux version was perhaps a bit more buggy. That made no difference. Then I took a break for a few weeks. When I came back I built up the circuit from scratch again, and found that I was having trouble because of the capacitors I was using which were āidealā instead of ābehavioral.ā Once changed to behavioral, the circuit was much more stable. I also found mosfet models from a manufacturer and they seem to be stable. The problem I am running into now, is that I am getting (and have gotten in the past) āError:Vector I(MQ2) not found!ā e.g. when I try to probe certain parts of the circuit after simulation. Now I havenāt searched the forum for that yet, and will do that next to see if there is something that I am doing to cause it. But I wanted to just give an update of progress on this rather than just ghost the topic. Thanks everyone for the help so far.
I am assuming it is a known bug that certain actions to modify a circuit while the simulation window is open causes an application crash? That has been a minor nuisance. When does the next upgrade come out?
I was having this identical problem, and also in a boost circuit. NGspice was giving the āTimestep too smallā error, or other problems relating to the diode. I tried adding a few 1M resistors to ground at the problematic junction but that didnāt work.
The solution was to remove the diode, and replace it with a NPN transistor. Connect the Common āCā pin to the node that links with the N-channel MOSFET drain and the inductor -ve pin. The Emitter āEā pin is connected to the R(load).
The Base āBā pin is then connected directly to a DC power supply (I had a 10V supply and used that). This ensures that the transistor is always āOnā and conventional current will flow from C to E, but not from E to C. Effectively, this replaces the diode and the circuit will work. I think the NPN transistor in KiCad is āidealā so there wonāt be any current flowing through BE which would make a mess of your simulation.
The error appears to be in the diodeās SPICE file or default settings. Iām not sure how to fix it though. Problem for another day.
As we are working here with voltages hihgher than in typical integrated circuits, it is advisable to relax the precision constraints a bit, e.g. by putting
Thank you, very helpful. It occurred to me exactly as you are saying that some part models may not be good enough to handle anything beyond more typical use. Boost circuits are highly dynamic, and hence if the models arenāt really good, there seems to be trouble keeping the sim stable in the face of high frequency high voltage ringing etc.