Kicad and simulation


#1

I am effectively brand new to Kicad and quite new to the field of electronics - currently distance learning at college of West Anglia.

I now see Kicad as an end to end solution (concept to completion) and simulation as an integral part of that process. But boy has simulation been a bittersweet experience. Whilst some others were turning up at tutorials with sheets of graph paper with hand-drawn creations; me and a couple of other ‘converters’ had plotted and proven schematics to offer with accompanying evidence sheets and plots.

At first, I couldn’t get my head around simulation at all, so resorted to circuit drawing in Kicad - plotting in ltspice - then printing both off separately. Very cumbersome. After spending hours dredging through the www and cobbling bits and pieces of info together I am now getting to grips with Kicad and simulation. Now I need to get a grip of spice directives and ‘of course’ my electronics study!

But without a doubt, Kicad is the way for me and I think some of my chums on the course are coming round to the idea as well.

NB many of the spice models available on the www don’t work with kicad it seems… Comments welcome.


#2

You will need ngspice-30 and set the variable ngbehavior, as described in http://ngspice.sourceforge.net/ngspice-eeschema.html#setting. Then all Spice, PSPICE and TINA models may be used. Most IC companies offer such models. LTSPICE models may be used as well, if they don’t use proprietary devices (e.g. LTSPICE A devices). If so, one has to find a special replacement for this A device.

Unfortunately the current KiCad is delivered with ngspice-27, still not having this compatibility flag. You may vote for the upgrade by supporting my bug report at https://bugs.launchpad.net/kicad/+bug/1821520 by clicking onto the “Does this bug effect you?” button.

ngspice however will not be able to read encrypted models. Unfortunately some semiconductor vendors only offer encrypted models for their more complex ICs, to prevent people from having a look at their internals. These models cannot be made compatible with an open source simulator. You may request for an unencrypted model with the vendor, perhaps you may get it after signing a NDA.


#3

Hi Holger, thanks for your reply.

I have already read the into you mention but it refers to Windows and Linux. No mention of MAC. I have already downloaded and installed ngspice-30, but it only seems to work in terminal mode, no GUI.

Can you advise how I can implement ngspice-30 on a MAC
. That would be exceedingly helpful. I’m not much of a computer geek, only just starting to learn spice directives out of necessity to fulfil myself and the forthcoming objectives of the course I am following.

Many regards.

M


#4

Standard ngspice for MAC is a console application, it does not have a GUI. But nevertheless it should be o.k. for learning spice. You may have a look at my tutorial http://ngspice.sourceforge.net/ngspice-tutorial.html for standard ngspice or use KiCad with external ngspice (see http://ngspice.sourceforge.net/ngspice-eeschema.html#external).

ngspice-30 for KiCad is now available in the current nightly for Windows towards KiCad 6 (see https://bugs.launchpad.net/kicad/+bug/1821520). The macOS package maintainer hopefully will consider this as well (or he has to be alerted to do so). I cannot provide a macOS shared library of ngspice-30.


#5

ngspice-30 is now distributed with the stable release 5.1.2 and all KiCad nightlies (5.1.2 and 6) for Windows.
I am not sure about the macOS stable and nightlies. Could somebody with a MAC check it out?
stable
https://kicad-downloads.s3.cern.ch/index.html?prefix=osx/stable/
nightly 5.1.2
https://kicad-downloads.s3.cern.ch/index.html?prefix=osx/testing/5.1/
nightly 6
https://kicad-downloads.s3.cern.ch/index.html?prefix=osx/nightly/

To get the ngspice version from inside KiCad, you have to do a trick:

Open empty eeschema window.
Edit a text box (T from the right column) and type in the following:

.op $  just a dummy command here
.control
version
.endc

.op just gives a simulation command, the .control section will return the ngspice version.
Now do Tools–>Simulator–>Run Simulation
and you will see the ngspice version.


KiCad V5.1.2 Stable Quietly Updated for Windoze
#6

Unfortunatly, KiCad 5.1.2 stable in macOS (downloaded last month) seems to ship with ngspice26. (I’m not in front of my computer to check the exact version string). I have a homebrew installed ngspice30 but can’t seem to link that to kicad.


#7

The change to ngspice-30, if at all, may be two days old.

KiCad stable for MAC has not changed since April, but we have recent nightlies.


#8

It seems to me that homebrew is not offering the shared library version of ngspice-30 that is required for linking with KiCad. libngspice version 28 is available, but that’s not quite what I would recommend. Maybe you can urge the homebrew people to upgrade their libngspice?

The only thing you can do for now is using Eeschema with external ngspice-30 (see http://ngspice.sourceforge.net/ngspice-eeschema.html#external).


#9

I have asked on the dev list for a re-packaging of the 5.1.2 stable for macOS, including libngspice 30.
See https://lists.launchpad.net/kicad-developers/msg40948.html


#10

You are always welcome to patch the build scripts, test it and submit a pull request on https://github.com/KiCad/kicad-mac-builder


#11

TBH, I have never tried building Kicad from source - the instructions seemed rather daunting and I have generally been happy with either the latest stable or testing the odd nightly build of what would become 5 & 5.1 when nearly mature in the development cycle. I have not played much with the simulator yet - it is clearly making a lot of progress but I have tended to fall back on LTSpice and QUCS for something with a GUI on macOS. Patching build scripts in any way that doesn’t involve spoon-feeding me the instructions is probably, sadly, outside my skillset. :frowning:


#12

@John_Pateman using the build scripts with build.py --target package-kicad-nightly should work out of the box. Then you can patch the relevant file and retry.