Buck Circuit Simulation

Hi all,

I try to build a very simple buck circuit simulation using KiCAD, here is the circuit:

And here is the result:

That the vout is about 12V, but the duty cycle of the PWM input is 50%, so the vout I expected is 6V( half of VIN 12V).

I have checked circuit several times, but I can’t find out what I did wrong.

So could anyone to help me solve this issue?

Here is the source file of the simulation.
Buck.zip (20.6 KB)

First, I know very little of using Spice…
… but had a look at your circuit anyway.

It looks like the dutycyle of your VPULSE is not what you expect it to be. I see a duty cycle of some 99.999% Your circuit also did not run “out of the box” because no simulation type is defined. In KiCad it’s normal to add these parameters as simple text lines in the schematic.

Maybe you can start at the link below, it’s got a bunch of examples that are supposed to “work”.

Hi Paul,

Thank you very much for your reply.

I am sure that the VPULSE is a PWM generator that generates 50% duty cycle PWM.

And then, I set the simulation command using configuration UI:

But of course, add a simulation command text in the schematics is a great option for simulation:

Here is out of box project:

Buck-simulation-out-of-box.zip (7.1 KB)

Use an NMOS power switch.

And reduce the load resistance of R103 (10 Ohms or so).

Hi all.

Maybe problem is diode hasn’t model assigned.

Thanks.

PMOS hasn’t model assigned either.

No, that’s not the reason.
If you have something like

.model __D101 D
.model __Q101 VDMOS PCHAN

in your netlist, you are using default parameter sets for a diode or a PMOS power device which have been offered by ngspice. These parameters may be suitable (or not) for a specific application, so are a compromise.

In this special example you may need to reduce the load to 1 Ohm and raise the inductance to 100 uH to see an effect (reduced output voltage).

In fact there is no need to switch to an NMOS device.

Apart from:

I guess I’d still prefer to use a model of a real life FET (somewhat compatible with the final application) as it makes the simulation closer to something “usable”.

This thread also illustrates the problems I have with Spice and why I have not done much with it. I’ve put several attempts into it, but after some time and frustration with getting silly things right to get it “working”, my focus wavers and I drift off to something else. I guess that for someone knowledgable about Spice and in combination with the library management team it should not be too difficult to collect a “starters library” with a bunch of usable FET’s. opamps, a 555 and a bunch of other jelly bean parts and to make them part of KiCad’s default libraries.

From the few simulations I’ve ran myself, and from other examples and threads from this forum, the simulator seems to work quite well, but scrounging the internet to find compatible models is a real nuisance, and when combined with the very little experience I have with Spice and not really understanding where it goes wrong each time the threshold for entry is too high for me.

Sorry about the rant, I hope it will be interpreted in some positive way.

1 Like

It is dispensable.

Searching for basic models, one might have a look at Spice models and model parameters for ngspice circuit simulator and especially at https://ngspice.sourceforge.io/model-parameters/basic_models.7z.

It is o.k. if somebody is not interested in simulating. But there are other ways to help the OP, for example with electrical engineering judgement. The OP wondered why with a 50% duty cycle on his switch the output was not half the input voltage.

What will be the ouput voltage if the load resistance is very large or infinite?
What will be the output voltage if the load resistance is 0?

Perhaps the original assumption is not correct and may need some refinement.

But then the simulation may help, in that it easily allows to change the R, C, and L without destroying anything.

1 Like

It should normally be at 50%, except at the extremes you mention.
But looking at it electronically, the inductor is ridiculously small. At 20 kHz, 100…500 uH is reasonable, not 10 uH. It has to carry continuous DC at all times. The simulation is probably correct.
Try with a reasonable inductor and load and see what happens.

I am interested. I just get bogged down into all the nitty gritty details on almost all my attempts to just get the simplest of simulation working.

The Buck configuration is a simple low-pass filter, so with a 50% duty cycle you would expect half the input voltage on the output.

He used an 1k resistor, which would be 6mA at 6V, and probably enough to overcome leakage. Lowering the resistor to 6 Ohm (should be 1A @6V) also does not help. I see a duty cycle of 50% on the gate, but 99% or so on the Drain, so something in the FET is not working.

Yah, ok, so I went to sourceforge, and to Diodes.com and:

  1. Got the model for a simple BS250P.spice.txt
  2. Looked at what’s in the file and found “.SUBCKT”
  3. Put it in the project directory and renamed to BS250P.sub
  4. KiCad / Edit Schematic Fet Properties / Simulation Model / Spice Model / BS250.sub

And then I get:

And that is enough for me to give up (again). Having to go hunt into text files for Spice simulation parameters about you do not even know the syntax is just too much to ask from beginners. And I suspect this is true for a lot of beginners. And if they can’t even get started, then they will never get to the point to put in enough effort to learn to solve problems like this.

License issues are often quoted for the complete lack of spice models with KiCad itself. When I look at that model, the license seems fairly open and I see no issue for not putting it in KiCad’s librarys (together with some edits to make it “work”).

* DIODES INCORPORATED AND ITS AFFILIATED COMPANIES AND SUBSIDIARIES (COLLECTIVELY, "DIODES") 
* PROVIDE THESE SPICE MODELS AND DATA (COLLECTIVELY, THE "SM DATA") "AS IS" AND WITHOUT ANY 
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY 
* OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY ARISING FROM COURSE OF DEALING OR COURSE OF 
* PERFORMANCE, OR ANY WARRANTY THAT ACCESS TO OR OPERATION OF THE SM DATA WILL BE UNINTERRUPTED, 
* OR THAT THE SM DATA OR ANY SIMULATION USING THE SM DATA WILL BE ERROR FREE. TO THE MAXIMUM 
* EXTENT PERMITTED BY LAW, IN NO EVENT WILL DIODES BE LIABLE FOR ANY DIRECT OR INDIRECT, 
* SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR IN CONNECTION WITH 
* THE PRODUCTION OR USE OF SM DATA, HOWEVER CAUSED AND UNDER WHATEVER CAUSE OF ACTION OR THEORY 
* OF LIABILITY BROUGHT (INCLUDING, WITHOUT LIMITATION, UNDER ANY CONTRACT, NEGLIGENCE OR OTHER 
* TORT THEORY OF LIABILITY), EVEN IF DIODES HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, 
* AND DIODES' TOTAL LIABILITY (WHETHER IN CONTRACT, TORT OR OTHERWISE) WITH REGARD TO THE SM 
* DATA WILL NOT, IN THE AGGREGATE, EXCEED ANY SUMS PAID BY YOU TO DIODES FOR THE SM DATA.



*ZETEX BS250P Spice Model v1.0 Last Revised 19/3/03
    *
    .SUBCKT BS250P 3 4 5
    *                D G S
    M1 3 2 5 5 MBS250
    RG 4 2 160
    RL 3 5 1.2E8
    C1 2 5 47E-12
    C2 3 2 10E-12 
    D1 3 5 DBS250
    *
    .MODEL MBS250 PMOS VTO=-3.193 RS=2.041 RD=0.697 IS=1E-15 KP=0.277
    +CBD=105E-12 PB=1 LAMBDA=1.2E-2
    .MODEL DBS250 D IS=2E-13 RS=0.309
    .ENDS BS250P
    *
    *$
    *

BS250P.sub (1.6 KB)

I see it as pretty relevant to OP’s post. I assume he’s also a beginner with Spice and is getting confused by simple things that seem incomprehensible. So I stand by my point: It would be very nice if there was some limited amount of spice models integrated into KiCad that are error free and guaranteed to work, just so that beginners can experiment with the simulator and get sensible results.

Edit:

It turns out you all were right all along. It took me about an hour but I finally managed to figure out my error, thanks to holger’s last post.



No it is not.
You can download the file and run it yourself.
In the screenshot below, Red is at the gate, which shows the pulse source works, and Blue is at the drain, which shows very short spikes.

The inductor value is apparently derived from some variable, but even changing it to 0.001 (which should be 1uH) does not change anything in the result. Which was expected, because the blue signal is just bonkers and shows the Fet itself does not work as a switch (which would be expected).

image

I design power. Nothing wrong with using a Pch MOSFET in your original circuit. That is correct for your 0-12V gate drive. The most likely problem is that you need to either increase inductance or increase load current so that you get continuous conduction mode “CCM”.

I just picked this out quickly and cannot say that it is the best, but I would be surprised if it is not basically accurate: What are Buck Converters? - Basic Operation and Discontinuous Mode vs. Continuous Mode | Overview of Design Examples of AC-DC Non-isolated Buck Converters | TechWeb

1 Like

You can also share your design in this forum: Ask a Question - PCBWay Community
Many expert designer come to this forum. You may get some more fruitful advices besides here.

Here is another buck converter design which you can consider for cross-checking your own design: Buck Converter using MOSFET Gate Driver in Proteus - The Engineering Projects

1 Like

Two projects (KiCad 7.0.1) are attached:
Buck.7z (7.9 KB)

1 Like

I can confirm that holgers “Buck2” works:
Gate in Red, it’s inverted output in Blue and the filtered analog output in Green.

It took me over an hour to figure out the difference, and why I could not get the original circuit to work, but I finally managed to get some sensible results out of the original “Buck” by indeed just changing the values of the resistor (1000 Ohm to 10 Ohm) and the Inductor ( 10u to 100u).

It turns out I was mislead the the extra layer of indirection for the values of these parts:

During my earlier experiments, I ignored the ${SIM.PARAMS} part and directly put other values in the Value field. Normally this works, but in this case it is apparently overriden by the Sim.Params and thus what you see in the schematic and what the simulation actually uses gets out of sync.

Below a screenshot with the modified values in the original Buck project.
You can even see some oscillation on the Drain because the Buck convert is used in dis-continuous mode with these settings.

A little frustrating how many complete WAG answers it took to get to this one.

It’s just running in DCM because you’re using a catch diode instead of a synchronous rectifier at low load current.

:person_shrugging:

If the explanation isn’t super obvious to the beginners reading the thread: a buck converter is only equivalent to a filter if the input is fully driven — if you drive it all the way to Vin for the positive section of the drive waveform, but just let go of it for the negative section instead of driving it to ground, then it’s only driven high! Using a diode like this is only equivalent to driving it low if you pull enough current to keep the diode switched on for the entire t_off. If your inductor current drops to zero, the diode switches off and it all goes out the window. This is called discontinuous conduction mode. The giveaway that you’re operating in DCM is the three-stage switching node waveform: first it goes high, then it goes low, then it snaps up to approximately Vout and rings.

A typical buck converter IC solves this by skipping entire pulses if the output goes too high. This is not necessarily a bad thing, but it can cause issues by severely reducing your effective switching frequency and thus f’ing up all your filter calculations. That’s one of the benefits of a synchronous rectifier: it can drive low the whole time, keeping the frequency where you originally designed it (at the cost of keeping a current flowing back and forth through the inductor all the time, meaning your idle power loss is quite high)

Yes when I wrote my earlier response on this thread, I had not noticed that the OP’s circuit is running at 20 KHz. That is a frequency which may have been used in some of the earliest switching power supplies (1970’s?) when components that are optimized for switching power conversion were not so good or readily available. I used 25 KHz in about 1981 for a 120 VAC input switcher using a bipolar switching transistor such as MJE13005. These days if you are switching 12V at a few amps or below, it would be normal to use frequencies of 200 KHz up to maybe 1-2 MHz. Using 20 KHz requires a larger inductor and (depending upon capacitor technology) likely a larger output capacitor also. I cannot think of much advantage to switching that slowly but I would not rule it out under some special circumstances.

I will oversimplify somewhat here: Synchronous rectification (using a low side MOSFET) can force continuous conduction mode “CCM” so that current in the inductor will flow bidirectional (yes it will reverse and flow negative; the current flow direction will alternate back and forth) when the load current is low. Synchronous rectification is more efficient at higher load current but if it “forces” CCM then you may be better off just using a schottky diode and allowing the converter to run in discontinuous conduction mode. Your switch duty cycle will then drop below Vout/Vin.

Anyone who wants to understand this better: Sketch a graph of the expected current waveform in the inductor and post it. The key equation is : dI/dt (slope of current versus time in the inductor) = V/L. Keep it all in volts, seconds, and henries and we will get there. I recommend using scientific or engineering notation.

I can only recommend NOT using the built-in ngspice models of KiCAD, except R, L, C.
The semiconductor models are a disaster.
Just for fun, in tried making a simple PMOS buck circuit like the OP did. and the results were catastrophic.
I simplified the circuit to the following, just for testing. As you see, the PMOS model fails totally. This applies to the D model as well (not included here) which also exhibits weird behaviour.
Note that all symbols and models are from the stock KiCAD library. The three traces are for R2 equal to 100, 1000, 2200 ohms resp.





7.0.1, ngspice-38