I attach a basic simulation combining standard spice models, Xspice models, verilog using yosys and c-code using the d_process method. It’s my way of giving back as I’ve been using Kicad professionally and privately since version 4.
The example is based heavily on The Easiest Way of Simulating C/C++ Code Together with an Analog & Digital Spice Simulation — ISOTEL. Hopefully between the two examples there should be enough for most people to understand what’s happening.
I only use Linux so the instructions will need modifying for Windows and possibly MacOS. Apologies for not being able to help with that. If anyone can get it running on those two, it would be appreciated.
The basic circuit is a simplified buck converter with a current controller. Switches are just switches with anti parallel diodes. No input/output capacitors, just voltage sources.
Target current is set in the buck_controller_msp430.c file and P and I gains are in the buck_fw_msp430.lib file.
You need Kicad 8.0.1, Yosys (tested with 0.23-6 on ubuntu), git and gcc.
To run, extract the files into a folder. Change to the folder and run “git clone GitHub - Isotel/mixedsim: Hardware Design Tool - Mixed Signal Simulation with Verilog” to get the Xspice models for yosys. Then run ./compile_all.sh. This will compile the c and verilog code. d_process.h has been copied from the ngspice source code.
Having done this, you can open the schematic, modify the control line “cd ~/Electronics/holger_sims/buck_msp430” with the folder that you put the files in and run the simulation as normal.
If you open Kicad from a terminal then you can monitor the stderr output as simulation runs.
A big thank you to all of the Kicad team! @holger I am always impressed and grateful for the help you give for how to use the simulation features on these forums. The improvements in ngspice over the last few years have also been very impressive. You’re welcome to take this sim and integrate it into your list of examples. You can also modify it as much as you want.
buck_example.zip (548.3 KB)