Incorrect BJT pads order from Kicad to ngspice

I have been trying out the simulation in Kicad to check the resistor values I need for a push-pull transistor output. It is used to switch from TTL to 25V level.
I have this operational when I use BC546 and BC556 transistors. However I want to use SMD transistors and also tried to get this to work with BC846 and BC856 transistors. It took some time to find out why it didn’t work, but here is what I found…

Ngspice expects the BJT transsitor to be in the form: Ref nc nb ne …
So after the transistor reference ID, it wants to receive the node for the collector, base and emitter in that order.
The transistors look like this in Kicad:
image
As you can see the numbering of the nodes is different between the two transistors.
Apparently Kicad does not output the nodes for a BJT to ngspice in the order of collector, base and emitter, but in the order of 1, 2, 3.
So for the BC564 it is: c, b, e
And for the BC846 it is: b, e, c
This can be found by checking the generated net lists.

As ngspice expects the order to be c, b, e, there is a mismatch with the output for the BC846 transistor and as a result the simulation will not work.
The only way I got this to work is by creating a netlist in Kicad, changing the order of the nodes in that netlist and feeding the results manually to ngspice. In that way I get the correct simulation results, but obviously without using the simulator in Kicad.

Has anyone had the same experience? Or am I doing something wrong in Kicad?

Add the “Alternate node sequence” in the Spice Model Editor of the symbol

1 Like

KiCad is primarily intended to make PCB’s, so pin numbers in the schematic match pad numbers on footprints.

But for the spice simulation there is an “Alternate node sequence” to map KiCad’s pin numbers to the pin numbers that ngSpice wants.

Eeschema / (Select a symbol) / e to edit it’s properties / Edit Spice Model and then at the bottom of the screen.

Thanks for the quick responses. That’s a useful feature :grinning:

Tried it out and it works now.