New Kicad user and forum member.
Can anyone please help with the following problem I’m having involving a custom pwl.
(The actual circuit is just a simple low pass filter with some caps and inductors).

I’m creating a “custom” waveform (i.e. impulse response) and it’s working fine.
The problem is I need the .csv file which I can export from the simulator to only have
results in steps of 22.67573us.
(i.e. 22.67572us 45.35144us 68.02716us etc up to 362.81152us in this case as per the .tran).

My pwl looks like this:
dc 0 ac 1 pwl (0 -0.000065v 22.67572us 0.000110v 45.35144us -0.000585v … 362.81152us -0.000065v)

My .tran as follows:
.tran 22.67573us 362.81152us

Yet the .csv file has many intermediate time/voltage steps which are are pain to manually delete.

Is there any way to do this? Perhaps in a .control section?

Do you have Microsoft Excel or similar spreadsheet software? I have just been doing what you describe:

You can set down the points in Excel and have it graph them. Excel provides drag-auto fill to get a series of steps with repeating interval. The graph tells you whether the points you are defining look like what you have in mind.

Once you have that, you can export to a text file or simply copy-paste into a text editor.

It did occur to me to use a spreadsheet (I use Libreoffice) but it’s still very error prone
due to the quantity of data and how ngspice rounds off the time stamps up or down.
Here is an example:

The above is just a small section from the generated csv file, there are around 500 samples/data points.

I cannot speak for what NGSpice does with the file that you feed it. But…how does that relate to how you produce it? In other words, how/why does it matter that you exported from a spreadsheet?

Does NGSpice accept engineering or scientific notation? Would that avoid the rounding issue?

BTW I like to use engineering notation (exponents are all multiples of three). I do not know whether Libre Office will do that…but scientific notation will also work to greatly reduce the number of zeroes you need to look at and figure.

If I need 270 pF, that is 270e-12 in engineering notation that is readable by Excel and LTSpice. Much easier than counting all of those zeroes. And it is a little better than scientific notation which would probably be 2.7e-10.

Good call on the use of engineering notation.
Ngspice seems to default to scientific notation but Libreoffice can take care of that
as it can convert the simulation data to engineering notation.

This may certainly make things less error prone.
Thanks for the tip, will try it out and revert back.

.control
set controlswait ; wait until simulation has finished
linearize ; interpolate the transient data from 0 to TSTOP on multiples of TSTEP, ngspice manual 17.5.40
wrdata file vectors ; write out the data, see ngspice manual chapter 17.5.98 for options
setplot tran1 ; switch back to plot tran1 to re-allow plotting with Eeschema (hopefully)
.endc

This should do the job, the interpolation interval data for the ‘lineariize’ command are taken from the .tran command. Of course not tested, may need some tweaking.

Thank you very much, “linearize” is the magic command I was looking for.
Can’t believe I missed it whilst reading the manual.
I shall now reach for the “special” cap and sit in the corner for a while…