Adding wrdata statement in a schematic

I added the following control section as text to a schematic of a simple rc lowpass filter:

set nobreak
set wr_singlescale
wrdata ldf.dat vdb(/2)

Unfortunately when starting the simulation the line wrdata ldf.dat vdb(/2)) results in:
PPerror: syntax error

I tried out alternatives like: wrdata ldf.dat db(ac.v(/2)) … but the error doesn’t disappear and the expected file ldf.dat is not produced. Could anyone here tell me how to accomplish the wrdata statement being executed?

kind regards,

This is the complete listing of the circuit:
Circuit: KiCad schematic
KiCad schematic

1 : kicad schematic
2 : .global gnd
4 : r1 /2 /1 15k
5 : c1 /2 0 2.2nf
6 : v1 /1 0 dc 0 ac 1
7 : .save @r1[i]
8 : .save @c1[i]
9 : .save @v1[i]
10 : .save v(/1)
11 : .save v(/2)
12 : .ac dec 20 100 100k
13 : .print ac vdb(/2) vp(/2)
14 : .control
16 : set nobreak
18 : listing
21 : run
22 : display
26 : set wr_singlescale
27 : wrdata ldf.dat vdb(/2))
31 : .endc
33 : .end

I’m using Version: 5.1.4-e60b266~84~ubuntu18.04.1, release build

Two actions are required:

The wrdata command (and others) interpret the ‘/’ character as a ‘divided by’. To avoid that, you have to enclose the token with “”. So the wrdata line should read
wrdata ldf.dat vdb("/2"))

When you do so, the syntax error should have gone. But then another thing will pop up: The vector v("/2") may be empty. This is a consequence of the multi-threading approach of the eeschema-ngspice interface. The simulation is started, but at the same time the statements in the .control section are executed, even if the simulaton is not yet ready or barely has executed its first steps. To avoid that, you have to put the statement
set controlswait
at the beginning of your .control section. This will tell ngspice to delay the .control section commands following the statement to wait until the simulation has finished.


An additional remark:
You have included the ‘run’ command into the .control section. This is not required, because eeschema is sending a run command anyway. It will probably lead to running the simulation twice. So better not include it except you know in detail why you would need it.

1 Like