Plotting variables from code models to the graphs

I’ve been using code models with verilog to simulate various power electronics ( Mixed mode simulation including C code and verilog - #22 and Another, tidier, mixed mode simulation model. Dual phase IPT buck converter - #8 ).

I’ve just got a power factor stage running with a proportional resonant controller and am probably starting to run into the limits of how things currently are. I just wanted to see if there are any useful features that I’m not familiar with yet before I put some feature requests in.

I think the most important thing that I’d like is a way to send variables from the c-code back to the graph (to plot controller errors, states etc). For now I could save them to a file with a timestamp and post process it in octave and plot the spice output at the same time but ideally I’d be able to display it on the kicad graph at the same time as the simulation.

  1. Is it possible for the kicad simulation graph to read in other files to plot at the same time?

  2. If not, is this out of the question?

  3. Is these another way we could do this?

More for @holger and I probably ought to address this via ngspice forums but is there a way to send floating point values from c-code back to spice? I think that the verilog PWM generation slows down when the clock gets too high and it would be nice to do some simulations by setting pulsed voltage sources rise/fall times instead. Not essential but I think it might run faster.

I appreciate that I’m very much pushing the limits of what this tool can do. When ngspice was integrated I don’t expect that anyone thought “Yes, kicad will become a digitally controlled power simulation tool as well as a PCB design tool” but I am very grateful to everyone who has made possible!

No, it is not possible.
Its not out of question, but it will need a KiCad developer to implement it. It might be necessary to express this wish at Issues · KiCad / KiCad Source Code / kicad · GitLab .
I am not aware of any other way to put outside data into the KiCad graph.

However, you might use a ngspice script to plot the data with gnuplot or gtkwave without intermediate saving. See for example full adder comparison from Simulation examples for KiCad8/KiCad9/Eeschema/ngspice.

This is indeed a question to be asked in the ngspice forum, as the originator of this code is not reading the KiCad blog.

Thank you @holger , I had a feeling that those were the answers. I’ll put a feature request in.