How to make measurements in KiCad ngspice simulator

Hi all.

I would like to do measurements ( for example average current) using the ngspice simulator available in Eeschema without using cursors . How could I do it?

Thanks

Hey hey! Give this a shot. Putting the following command as a text box on the schematic will tell the simulator to calculate the average voltage on a node I labeled on my schematic called “output”. It does this computation across the entire transient start/stop times.
.meas tran test1 AVG V(/output)

Current is a little goofier because the data vector is named less intuitively. A good way to check is to find the “Simulation->Show SPICE Netlist…” on the menu bar of the simulator. The .save commands in the netlist show how the simulator saves the data vectors so you can reference them later. Anyway, here is me doing the same average calculation for the current through R3/
.meas tran test2 AVG @r3[i]

And then it’ll print out the result of test1 and test2 at the end of the simulation log:


Might be a good idea to name them something better than test1 and test2 so you can understand what they’re trying to measure, especially if you’re going to make a lot of .meas commands.

Anyway, for more information, you can check out 15.4 of the ngspice manual.

1 Like