Heads up for beginners for SPICE simulation

With my first attempt at SPICE simulation with KiCad I run into a trivial problem that took a few hours to sort out.

My first trivial exercise with the Simulation_SPICE/NPN transistor from the library worked just fine.
But then I wanted to use a real transistor model (2N3904).
As we know KiCad comes without SPICE models so I located that from the web and attached them to the schematic symbols and everything worked just fine.

For the next exercise I thought I’d grab the 2N3904from the library and attach the spice models to that symbol. And nothing in the simulation made sense. Since this exercise had more components and a different circuit which I was not too familiar with it took me quite some time to figure out where the problem was.

The problem is that the schematic symbol for NPN transistor in Simulation_SPICE/NPN and Transistor_BJT/2N3904 components have different pin numbering,

Both specify in Sim.Pins 1=C 2=B 3=E but the KiCad schematics symbol has different numbering for the pins for those two symbols so of course it does not work.

The symbol pin numbering is made according to the data sheet and the numbering given by the manufacturer. This may vary with the package/footprint chosen.

The simulator always wants to see the sequence C B E, thus the numbering has to be adapted.

There has been a discussion to add the ngspice numbering to the symbol, in addition to the footprint numbering. I am not sure what the status of this effort might be.

This is the inevitable consequence of the fact, that we have a PCB design system controlling a simulator.

An introduction is available at KiCad Eeschema as GUI for ngspice, tutorial for setting up the simulation, made for KiCad 6, but still valid for various simulation aspects. As soon as KiCad 8 is out, I will care for an update.

If you have any further questions, just ask in this forum.

Thanks.

Yes, I agree that this is more or less inevitable to occure, hence my heads up for beginners.

Nice that there are tutorials, highly appreciated, though the modern way seems to just plunder along and google as you go :wink:

Incidentally I had seen this tutorial and skimmed through but again in the modern fashion had missed that warning about the pin numbering.

I like KiCad, it is pretty good, the UI is effcient even if it is different from well everything and requires some getting used to.

The biggest ‘complaint’ is that you cannot just grab a real life component like 2N3904 and simulate it and get on with the PCB. Two issues, I am sure this has been discussed ad nauseam, the separation of schematic component and the padstack and that the SPICE models have to be harvested separately.

I cope and I appreciate and use and love that we have an awesome tool like KiCad and I don’t expect things to change so I’m good. But it surely would help beginners to cross the threshold if it would be possible to just pick real components from the library simulate and get on with the PCB without the extra steps.

Thanks for everyone who contributes here and in the code base and in testing.

Yea we would bundle SPICE models if we could but manufacturers have to be willing to allow it.
Many have signed deals with propertiary simulators and want to push users solely to those tools.

I don’t know how others, but it never happened to me to have a need to simulate the same circuit that I want to have at PCB. And I’m pretty sure it will never happen.

1 Like

Interesting. I seldom develop ideas in isolation. I always have context in which I want to test/simulate something. Perhaps not as a part of a complete/complex schematics but definitely with real components. So what I said that would be nice to have still holds.

I am not going to pretend to be a expert here as SPICE is a topic I have always wanted to be more familiar with but, 20 years later its as strange as JAVA to me.

Suggestion to consider. AI generated SPICE models. Since not all developers actually generate SPICE for their parts, a user must either consult a IEEE with familiarity in SPICE or figure it out on their own. I have tinkered with SPICE generated by AI and it seems promising. But that experience is with maybe 6 parts and I never complimented the spice to test the results.

I am also not trying to plug for a product and that’s why I am not dropping names.

But I do think that if AI or Machine Learning can be utilized to analyze developer data and create SPICE models, this would be a powerful tool in bridging the gap.

1 Like

Here’s another point of view from another camp and maybe a bit upsetting for some but I don’t understand why Kicad has a simulator in the first place. There are loads (enough) free and mature SPICE simulators out in the wild already, surely ? I have wondered why it exists but I only got here at the end of version 4 so don’t no the origin.
:mouse:

Well, for one KiCad is available for macOS. MicroCap UI better but not available for Mac. Also closed source not developed further so who knows what is going to happen. LTSpice … did not persist enough to really try it out but the UI to enter schematics was crap IMO compared to KiCad. What else is out there if you are a Mac user without deep pockets. Or with deep pockets even.

Also, I prefer good integration (of simulation) with the schematic entry system I’m using. KiCad is a bit lacking in that respect but I expect it will get better. And it is very usable already.

I was not writing about not real components. But set of components I had to use in simulation has small common part with components used in design.
For example for simulating supply filters I made models (including parasitic components) for serie of chokes and capacitors.
Idea is like this: In Spice library I have long serie of chokes without footprints. In PCB library I have only the selected one with its footprint, but I have there many ICs without spice models.

I’m not quite following. What should be the input for the training set?

The training set would be a primmer about the component family. That is Resistors, Transistors, Capacitors. AI have reach the point where we really don’t need to feed them data on one specific component family. I have worked with one that astounds me every time I use it. I am sure its based on one of the chat engines, but its been trained on millions of documents for components. It does make mistakes, but if you point our the error it will apologize and correct the mistake, even accept user sourced info for the session. Again I am not plugging for that developer. But conceptually, a developer with a good mind for this for sort of thing could develop an AI specific for the task. And KiCad isn’t the first circuit simulator to be in need of Spice Data to make components functional, but it is the most current.

The one issue is when developers are not very forthcoming with their data. This now requires an AI with more expanded data and a greater understanding of the technology even physics. Now with real world data supplied by testing done by a user, the AI could generate a very precise SPICE data sheet for a simulation that matches real world behavior. -This might even be more favorable, since a MFG sourced SPICE data will likely to sim only ideal, not real world.