Electronics > KiCad

Kicad simulator model incorporating c functions, xspice and verilog

(1/2) > >>

Slh:
I managed to get a c code model running in the kicad 8.0.1 simulator. It enables you to include algorithms that would run on your microcontroller in your simulation. Potentially you can then debug is with gdb (or printf  if you're a bit more like me :) )

The example model is just a simple current controller with a half bridge and inductor.

See link for full details and the model: https://forum.kicad.info/t/mixed-mode-simulation-including-c-code-and-verilog/49752

djsb:
This is interesting, but could you make something simple like blinking an LED or putting current through a resistor so we can understand how it all works. I've still not got my head around the standard use of ngspice simulation yet.

Slh:
I might get around to doing a simpler one however realistically this currently requires pretty detailed SPICE simulation knowledge (including writing your own models) to set up your own models so I don't know how useful such a basic model would be. Between my example and the original that I started from (linked in the kicad forum post) there should be enough information for an experienced user to get whatever they want running.

Once the microcontroller model is made (including the c-code main function) it should be easy to use but given how many functions microcontrollers have nowadays unless you use the same peripherals then you'll have to modify the model. Longer term, I expect that the c-code main function could be generated from a script.

My main reason for getting it working was for power electronics simulation (similar to PLECS or PSIM) hence why I made a basic buck converter. It runs fast enough at the moment for me to be happy using it. I look forward to seeing how it fast it is with CLLC and DAB converters.

JohnG:
This looks like some really nice work, thanks.

I find it interesting that ngspice has many of the same features of QSPICE, but in a completely open-source form. I don't know how the two compare performance-wise.

John

Slh:
Thank you. I'd love to see how it compares to Qspice speed wise but until Qspice runs on Linux I can't run it.

The c code function has only just been merged into ngspice so I'm hoping that now there's an example it will inspire better software folk than me to integrate it better into kicad (and maybe ngspice) but for now it's good enough for me.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod