Would it be nice if symbol for simulation can include the KiCad schematic act as spice model?

I would think if would be nice if we can draw simulation schematic model, and attach it with the symbol as spice subcircuity model right?
This would allow one to may a comprehensive simulation.

This can be done with hierarchy schematic, but hierarchy schematic are very low in graphical… they all just a rectangular block.

There are already feature requests on gitlab to be able to attach a schematic file to a symbol instead of using a “rectangular hierarchical block” It’s been mentioned in the issues for “Design blocks”.

It’s also got 72 “thumbs up”, which may make it the most popular feature request.

1 Like

I saw there is a Embedded file for the symbol… but not sure how that use toward to embedding the spice netlist, or a kicad schematic as a sub circuit model for spice. I think this is only make sense for simulation work.

I would not see it make sense to do this for making the PCB board with Symbol been hierarchy for sub schematic…

So, another way of saying what you want is to create a .subcircuit from a schematic, so you can use it to attach it to a schematic symbol.

A bit of clicking around: KiCad already has: Schematic Editor / File / Export / Netlist and that has options to export a Spice netlist, and I also see a a tab for “Spice Model”. I am not sure what that exports though. My knowledge of ngSpice is very minimal.

I think you can get pretty close to the behavior you want if you combine this export with some whittling in a text editor.

Right - but if the is not export involve from the user. Like simulation model, we can pick the .cir file for spice netlist, or the .kicad_sch file as the model.
So the symbol would have Sim.Params to modify the model in the spice netlist, or the .kicad_sch file.

I have done this several times, for example in More simulation examples for KiCad/Eeschema/ngspice - #2, The venerable ICL8038.

Draw the circuit in Eeschema
Don’t put power supplies or any other external device onto the canvas (or do it for testing, but remove it before exporting).
Put global lables on all nodes you want to use as connection to the outside in your new spice model (eg node1 node2 node3 …).
Export the circuit into a spice netlist
Open this netlist file in a text editor
Create a subcircuit from this netlist:

  • Add a line .subckt subname node1 node2 node3 morenodes as the top line in your file
  • node1 node2 node3 … are the node names from the nodes with global labels in the circuit
  • subname is the name of the subcircuit model
  • Add a line .ends as the last line in your file

Save this text into a file mymodel.lib
Create a symbol with the appropriate number and sequence of nodes, attached the new subcircuit model to the symbol

2 Likes