# How can I get the value of current from this NGSPICE Code?

I tried this code for a simple simulation with ngspice-30:

vcc 3 0 dc=10
vin 4 0 0.8
vdummy 1 2
R1 4 5 50k
r3 3 1 1k
Q1 2 5 0 mybjt
.model mybjt npn(IS=1E-16 VJE=0.7 CJE=2.6734e-11 CJC= 1.4040e-11 BF=200)
.control
op
dc vcc 0 10 1 vin 0.7 0.8 0.02
run
plot i(vdummy)
.endc
.end


But I always get a blank graph out of it. What could go wrong with my code?

• Are you sure the simulation is working at all? Do all of the other voltage signals look reasonable? – Elliot Alderson May 13 at 11:11

You forgot to start the NGspice code with a so called title line with the keyword netlist.
So, the first line should be something like "[your title] netlist".

Without that line, the simulation output shows a:
Fatal error: DCtrCurv: source / resistor vcc not in circuit
which explains there are no (relevant) datapoints for i(vdummy).

Using the following will give the desired result.

testcircuit netlist
vcc 3 0 dc=10
vin 4 0 0.8
vdummy 1 2
R1 4 5 50k
r3 3 1 1k
Q1 2 5 0 mybjt
.model mybjt npn(IS=1E-16 VJE=0.7 CJE=2.6734e-11 CJC= 1.4040e-11 BF=200)
.control
op
dc vcc 0 10 1 vin 0.7 0.8 0.02
run
plot i(vdummy)
.endc
.end