NGSpice not converging for full bridge rectifier model

I’m trying to simulate the output of a full bridge rectifier with output filter but the simulator keeps failing with timestep too small, which I understand is a false error but rather indicates a problem with the model. I have only used standard KiCAD components and the model seems pretty straight-forward. Have I reached the limit of what NGSpice can model ?


I’m using:
Application: KiCad Schematic Editor x86_64 on x86_64
Version: 7.0.11, release build
Libraries:
wxWidgets 3.2.4
FreeType 2.13.0
HarfBuzz 7.3.0
FontConfig 2.14.2
libcurl/8.1.2 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.41.0
Platform: macOS Big Sur Version 11.7.10 (Build 20G1427), 64 bit, Little endian, wxMac
Build Info:
Date: Feb 22 2024 12:26:24
wxWidgets: 3.2.4 (wchar_t,wx containers)
Boost: 1.82.0
OCC: 7.7.0
Curl: 7.77.0
ngspice: 41
Compiler: Clang 13.0.0 with C++ ABI 1002
Build settings:
KICAD_SPICE=ON

If you have chosen the diode from library Simulation_SPICE: its model is too simple. Capacitances are missing, and this may create problems for transient simulations. Either use a realistic model (e.g. 1N4007) or edit the basic model:

Double click onto diode symbol–>Simulation Model …–>Parameter Table–> Capacitance–> Junction Capacitance cjo Value 10p

Do this for all 4 diodes. This is what I get afterwards:

Super ! That did the trick ! Fantastic !!

Should I include the ESR for my capacitors or will it not have an impact ?

I’ve added series resistances to the capacitors, I expect is the usual method.

I’ve implemented the second stage of the voltage converter, a bucking of the output of the filtered full bridge rectifier with a p-channel mosfet, driven by an n-channel mosfet which is driven by a voltage voltage source with 1% duty cycle.

Again, NGSpice fails to converge with the “timestep too small” error. I am running at 20ns interval. I have used standard KiCAD spice components and D5 has the diode capacitance adjustment to 10pF as D1-D4. I have tried deleting each of the discrete components without much luck, after 1ms (the time delay of the pulse source), spice fails.

For the pulse source: t,delay = 1ms, y1 = 0, y2 = 5, tr = 1u, tf = 1u, tw = 10u, per = 1.2m np = 1000

Suggestions greatly appreciated !!

Built in MOS models in KiCad 7 have a bad threshold parameter vto=0V.

Double click onto the NMOS, Simulation Model…, Simulation Model Editor, Parameter table, DC: enter 4 into value column of parameter vto. For the PMOS, enter -4 into the value column.

For V2, set y2=15

If you simulate with high voltages, relaxing some limit specifications may help. Put the line
.options chgtol=1e-11 into a text box onto the Eeschema canvas.

If this does not help, put your project into a zip file and upload it here.

I had caught that the thresholds were set to 0. I had set them to 1 and -1V respectively. I adjusted them to 4 / -4V as per your suggestion and have added the text. The simulation runs for 2ms rather than 1ms :joy:, then fails with the timestep too small error.

Here is the zip file:
MBO_Supply_Simulation.zip (12.5 KB)

Thanks in advance for your help !

With KiCad 8.0.1 (using ngspice-42) on MS Windows, your example runs out of the box.

My setting on the canvas is
.options chgtol=1e-11 method=gear abstol=100n
due to avoid trap ringing. abstol is required when simulating currents and power dissipation of all devices (KiCad 8!) during transient simulation.

If you are going to simulate more, I suggest to upgrade.

Concerning the circuit, what is the inductor L1 with 840H ? This thing delays the voltage ramp, and when you switch off the clock it contains so much energy that you create ringing in the kV range, nice plot, but very unrealistical. Better just use a large capacitor, the rest is to be handled by the converter.

A good idea is always to seperate things: run the rectifier separately (you have done that), and then the converter (with a constant voltage supply), and when both are ready, put them together. With L1 at 840H this then yields surprises though.

Unfortunately I am running on MacOS Big Sur, so KiCAD 8 is not possible, it seems. Fortunately, the simulation runs as well with your additional parameters :slight_smile: !!

I am trying to simulate the basic principal of operation of the Power Integration LinkSwitch-TN2 LNK3205. Of course, the LNK320x includes feedback and control (which I am not simulating) to make adjust the switching such that the output voltage is constant.

PI recommends this circuit above 1W, which is my maximum power level. As you, I don’t see the reason for the LC circuit on the output of the rectifier circuit, especially with such a high cutoff frequency; the input voltage is smoother without it. But I’m not that experienced with this family of components, so I figured I’d simulate it. In the end, the inductor probably isn’t appropriate for my low power levels.

Thanks for your help in getting the simulation working !!