Ngspice meas statement

I wonder why the meas command in the following control section put as text in
in my schematic fails to work:
.control
set controlswait
meas tran vrptp pp v("/out") from 10m to 40m
set wr_singlescale
set wr_vecnames
wrdata ‘vb1ngspicekicad.dat’ v("/in") @d1[id] v("/out")
.endc

When running the simulation (a transient analysis) I get the following message:
No. of Data Rows : 812
bad syntax of ??
meas tran vrptp pp v("/out") from 10m to 40m failed!

the file vb1ngspicekicad.dat is created correctly however

What is going wrong here?

kind regards,
Hugo

I am looking into it. It may be a bug in ngspice.

1 Like

Well, it’s not a bug.

The correct syntax of the meas statement (see manual 15.4.7) is

meas tran vrptp pp v("/out") from=0m to=40m

(see the ‘=’ signs added!).

Maybe we can improve the ngspice error message.

1 Like

I have uploaded a patch to the ngspice pre-master branch. The error message now will read:

bad syntax. equal sign missing ?
meas tran ypp pp v(/out) from 0 to 150n failed!
1 Like

Holger wrote:

meas tran vrptp pp v("/out") from=0m to=40m

(see the ‘=’ signs added!).

Maybe we can improve the ngspice error message.

Thanks a lot for pointing out my mistake. I also noticed I have to remove the double quotes around /out i.e. v(/out) in stead of v("/out"), the reason I did it like this was because I tried to be consistent with the statement: wrdata ‘vb1ngspicekicad.dat’ v("/out") …

kind regards,
Hugo

Well those are different contexts. wrdata takes a filename, whereas v() takes a node name and already has a pair of delimiters, namely the ().

One has to be careful with the ‘/’ token.
KiCad has decided to use it to denote hierarchical node labels. So if you place a local ‘out’ node label, you will get a ‘/out’ as ngspice input.
ngspice has several commands (I guess including wrdata) that allow not only to place vectors (simulation results) for specific nodes, e.g. like V(out), but also equations of results (e.g. like V(out)/2) as their arguments. You even might give only out/2 as an argument (instead of V(out)/2).
Now what to do with V(/out)? /out as a node name is o.k. for ngspice, as a command argument it may be not. So we have to use V("/out") to survive the equation parser.
This is unfortunate, has been discussed with the KiCad devs, but for the moment there is not a really good solution at hand.