Electronic – How to plot current in ngspice

current measurementlinuxsimulationspice

I wish to plot out the current and power in ngspice. In the case of voltage, for example, if I wanted to plot the voltage at node 1 I would use:

plot v(1)

Problem is, when I try i(1), the vector isn't recognized. Could someone provide a few examples on how to do this?

Best Answer

Oli gave a correct answer but the I(element_name) is an extension added only to the commercial SPICE versions.

In ngspice (which is based on Berkeley Spice 3) you can only plot currents through (independent) voltage sources. These are the only currents that appear in the circuit equations SPICE works from.

In an interactive Spice session or from a special block in the script (see also this question) you can use expressions like (v(1)-v(2))/1k when the current is through a 1kΩ resistor between nodes 1 and 2. For reactive elements (like a 1μF capacitor) something like (v(1) - v(2))/(2*pi*frequency*1u) should also work.