Kicads simulator: spice/pspice/ltspice

I was attempting to simulate a fairly complex circuit and my results just didn’t make sense - not only could I not get the simulator to behave the way I thought it should, but also the way others using SPICE could get their simulators to work (OrCAD, Eagle, others). I wanted a constant (power) load.

I stripped my circuit back to the bare minimum - a source and a resistor. It still wouldn’t work.

I spent a couple of days scratching my head and reading blogs. The preferred way of simulating a constant load (according to multiple blogs) is to assign a formula to a resistor that varies the resistance according to the applied voltage. The term used liberally is: “limit(0.001,V(Vr)**2/10,10000)” for a 10 watt load, and a guard rail for zero volts. Kicad simply refused to do it!

I’m pretty new to simulation, and the first ‘SPICE guide’ I came across was for NGspice. OK, spice is spice I thought. Reading through it “limit” is defined as a two term function. What? Why is ‘limit’ defined as a two term function but everyone uses three terms?

Quite by chance I then happened to find a “Pspice” manual on-line - I couldn’t locate the ‘ngspice’ page I’d originally read… and they should all be the same, right… To my surprise ‘limit’ had three terms! I’d previously noticed “sim command” had a select box “compatibility mode”, but hadn’t paid it much attention. Time to just try whatever! Select “Pspice” and it worked!

If I changed it back to ‘spice’ or selected ‘LTspice’ it just gave the same nonsensical answer.

Such a simple mistake - and so much time lost! I’m sure old-hands would giggle!

A further problem is I can’t get the Kicad simulator to measure the current through the resistor - even though the item is listed in the “Add Signals” list - it simply won’t add! I assume this is because not much dev effort has been put into Kicad simulation? Any tips on solving this particular problem?

And one more question (sorry): is it possible to add a “signal” that is not one of the base signals? I tried to type “I(V2) * V(Vin)” to graph the power (and both those signals are valid)… but no dice.


This is probably about 90% true. Of course, it’s the 10% that gets you!

Based on using Spice since running it on a VAX from text files (Spice 2G6 IIRC) up to today, my opinion is that Pspice is based on Spice 2 with custom extensions and most of the others on Spice 3 and possibly Xspice extensions. Pspice was the most standard, but I would say that today LTspice is the de facto standard for non-chip designers. I have not used NGspice very much, though it looks attractive. If starting new, I would go with LTspice or NGspice as the most standard.

You may also want to consider Qspice from Qorvo, also free. It’s not been around for as long (a few years), and it is not open source, which means that Qorvo could lose interest or decide to monetize it at some point. I thought the same about LTspice, but it’s been nearly 20 years that I have been using it. Sometimes you win!

In the end, I would like the NGspice/KiCad to reach or surpass the ease of use of LTspice or Qspice. Both of the latter have the same author, who makes a mix of really great interface decisions and some real head-scratchers (like device names with unpronounceable characters in Qspice, WTF!). It seems to me that NGspice/KiCad has made a huge amount of progress in the last few years and is getting closer, but I have been using LTspice for a long time so it’s hard for me to justify switching yet.

Just my 0.02 in your favorite currency,
John

I am aware of it, and that it uses NGspice as a simulation choice is a big plus. It looks incredibly promising, but QUCS-S documentation is poor and it is therefore difficult for me to accomplish real work. As an example, there is no clear documentation about how to create a symbol. This is a pretty fundamental task when using Spice of any sort.

Interestingly, NGspice documentation is incredibly thorough. Kudos to those who have worked on it.

John

You can also try Keysight PathWave Advanced Design System 2025 works on both Windows and Linux

You appear to be using a reasonably old version of KiCad (v6 or v7?). In V9 there are some more options in the interface, including for user-defined signals which would allow you to plot a math op on two other signals (like I*V). In V9 you can also just directly plot power dissipated in a component.

But even in your version, you should be able to plot the current through the resistor. I’m not sure why that wouldn’t work. You could try the probe button and clicking on one of the resistor pins.

1 Like

Using KiCad 9.0.2 I have immediately got this:

2 Likes

Well, I guess it’s time to update then!

I thought I was using v8, but upon checking the help, I found the version installed is v7. I was pretty sure I’d upgraded when 8.02 came out (I’m always reluctant to load up a x.00). Perhaps I only updated my work PC and not my home one…

That should solve both my final questions - thank you,
MM