# LTspice parameter sweep and sampling

Setup

I am trying to run a parameter sweep in LTspice in order to generate STDP curves for a memristor.

I'm doing this by sweeping a time-delta parameter dT between -50 and +50 ms, in order to run 100 transient analyses with the "post-synaptic" voltage source shifted w.r.t. to the "pre-synaptic" at each one.

.param dT=-50m
.step param dT -50m 50m 1m


The pulse that is seen around 200 ms is to read the current through one of the probes of the device I'm measuring.

The problem

I would like to sample each of the simulations by taking the current at one of the electrodes of my device at 206 ms, in order to compile them into a classical STDP graph with dT as x-axis and current as y-axis.

Solution:

.meas res find ix(u1:te) at 206m did the trick to be able to measure the current through the device. I was then able to plot my quantity of interest by View > Spice Error Log > Right click on res > Plot step'ed .meas data .

• I haven't read what you wrote well enough to feel I understand all of it. But have you looked at the .MEAS card, yet?
– jonk
Sep 20, 2021 at 9:44
• I have and I was thinking of using .MEAS <probe> AT 206m. Does that make sense? Sep 20, 2021 at 10:36
• @ThomasTiotto You're on the right track, but you'll have to use something in the lines of .meas <probe> find <quantity> at 206m, where <quantity> can be either time or any signal or math with signals (i.e. v(out)**2). Then open up the error log, RClick and select plot step'ped data (or similar). Sep 20, 2021 at 15:17
• @aconcernedcitizen .meas <probe> find <quantity> at 206m did the trick. I was then able to plot my quantity of interest by View > Spice Error Log > Plot step'ed .meas data Sep 21, 2021 at 7:54
• @ThomasTiotto If you omit find <quantity> and just write .meas <name> when <condition>, it is implied that it's using .meas <name> find time when <condition>. That's why <quantity> explicitly uses <quantity> for finding. Sep 21, 2021 at 13:29

.meas res find ix(u1:te) at 206m did the trick to be able to measure the current through the device. I was then able to plot my quantity of interest by View > Spice Error Log > Right click on res > Plot step'ed .meas data .