I have a battery-powered boost converter and I'm attempting to measure the maximum input (battery) voltage droop under various load conditions of high current draws (different duty-cycles/periodicities) in addition to over several battery types (various voltages/internal resistances).

Since I'm simulating such a (relatively) large amount of operational time the simulation files are getting pretty substantial, not to mention they take a while. I would like to automate LTspice so that I can change component values programatically and rerun simulations and capture data (values of things like voltage or current). I know that:

  • WAV files can be used to input/output data from the program
  • The program can be run from the command line

So far my best option seems to use a combination of these two options along with my own code/script in a fashion that accomplishes my goals, but I just wonder if there is a better way already out there.

Has anyone automated LTspice or know if there has been any kind of automation API written for it (either by the manufacturer or by 3rd parties)?

Ideally I would like to have a solver, such that I give it the desired parameters and it tries various component values until it has found the "optimal" solution to my constraints.

  • 1
    \$\begingroup\$ What did your Linear FAE say? I'd ask them first. \$\endgroup\$ Commented Oct 13, 2011 at 0:22
  • 2
    \$\begingroup\$ Do you know about the .STEP and .PARAM commands? Not sure if it would achieve exactly what you want, but I will post an answer with a couple of examples if you are interested. \$\endgroup\$
    – Oli Glaser
    Commented Oct 13, 2011 at 10:49
  • 2
    \$\begingroup\$ Does it need to be LT Spice? I believe the heart of SPICE is a command line tool. \$\endgroup\$
    – dext0rb
    Commented Jun 18, 2014 at 18:12
  • 17
    \$\begingroup\$ @LeonHeller on WHAT planet is SPICE not a part of design? \$\endgroup\$ Commented Jun 18, 2014 at 18:21
  • 2
    \$\begingroup\$ You'll find that Monte Carlo options are perfectly suited to this. You can Schmoo different parameters and it also can display the variations. LT-Spice MAY have disabled this by SPICE natively supports this. Start there \$\endgroup\$ Commented Jun 18, 2014 at 18:23

6 Answers 6


Running a simulation multiple times and changing multiple component values is a bit more involved than just changing one (which is not so bad)

Here is the concept for changing one value:

  • Add a .param statement using the SPICE directive icon on the far right, e.g. for a resistance value .param X=R
  • To use it you would enter {x} into the resistor value, then include e.g. .step param X 100 500 50 to step the value between 100 and 500 in increments of 50.


Step Example



For multiple values, the only way I found to work was using a list of values for X, and using the table statement. This is probably best explained with an example (reading the help for the commands used will probably be helpful here). But note that the table command syntax is in the form table(index, x1, y1, x2, y2, .... xn, yn), takes index as input and returns an interpolated value for x=index based on the supplied x,y pairs.

In one of my simulations I needed to perform 12 simulations whilst changing 3 different component values, here are the commands:

.step param X list 1 2 3 4 5 6 7 8 9 10 11 12
.param Rin1 = table(X, 1, 1,1p, 2, 1p, 3, 1p, 4, 4478, 5, 4080, 6, 3400, 7, 2200, 8, 1p, 9, 1p, 10, 1p, 11, 1p, 12, 1p)
.param Rin2 = table(X, 1, 4997, 2, 4997, 3, 4997, 4, 499, 5, 897, 6, 1577, 7, 2777,  8, 4997, 9, 4997, 10, 4997, 11, 4997, 12, 4997)
.param Tval = table(X, 1, 56, 2, 56, 3, 27, 4, 1G, 5, 1G, 6, 1G, 7, 1G, 8, 1G, 9, 330, 10, 330, 11, 120, 12, 120)
.param Kval = table(X, 1, 316, 2, 147, 3, 147, 4, 6340, 5, 6340, 6, 6340, 7, 6340, 8, 6340, 9, 6340, 10, 825, 11, 825, 12, 316)


Gain Example

Hopefully you get the idea, you could maybe produce a script that would produce the necessary SPICE commands when you fill in your desired values. Or just create a template (e.g. I just copied and pasted the above into a few different simulations and changed the values)

If the above doesn't do what you want, then maybe look at something like NI's multisim (I think it has some batch simulation options, although I'm not sure how useful they are) It may also be helpful to ask on the LTSPice forum and see if someone knows of a better way of doing things.

  • 3
    \$\begingroup\$ This is not as clean as I'd like it to be, but for free software, I can only be grateful that they threw me a bone. Thanks for demonstrating this technique. This will definitely get me closer to what I'm looking for. \$\endgroup\$
    – Joel B
    Commented Oct 25, 2011 at 15:41
  • 1
    \$\begingroup\$ Thank you, this helped me figure out my simulation. Now I have to figure out how to put a legend on the plot so I can tell which simulation is which. \$\endgroup\$
    – user59731
    Commented Dec 5, 2014 at 0:40

I think it is actually possible to run LTSpice from the command line and have it run a transient simulation:

On Windows:

cd <wherever LTSpice is installed on your computer>
scad3.exe -Run -b MyCircuit.asc

On Linux:

cd ~/.wine/drive_c/Program Files (x86)/LTC/LTspiceIV
wine ./scad3.exe -Run -b MyCircuit.asc
  • 2
    \$\begingroup\$ This is an excellent find! I'm now brainstorming how i can use this for automated design. \$\endgroup\$
    – Joel B
    Commented Dec 31, 2014 at 17:37
  • 2
    \$\begingroup\$ @JoelB : yes, that's also what I use it for. There are unfortunately a few shortcomings: 1) Unlike in the GUI, the solver runs single-threaded, so it's slower 2) You don't have any "progress report" like in the GUI \$\endgroup\$ Commented Jan 6, 2015 at 11:00
  • \$\begingroup\$ scad3.exe is no longer part of LTspice starting with XVII. If you check justinmassiot's post below you'll see a link to a program called LTspice Queue Manager. Scrolling down to the bottom you'll see the problem described in more length. \$\endgroup\$
    – pfabri
    Commented Mar 3, 2023 at 19:26

LTSpice can be run in batch mode with the -b command line switch.

From the LTSpice Help file:

-b: Run in batch mode. E.g. "scad3.exe -b deck.cir" will leave the data in file deck.raw

How to read and interpret the .raw output is left as an excercise for the reader.

Also note, among the command line switches:

-ascii: Use ASCII .raw files. Seriously degrades program performance.

  • \$\begingroup\$ How exactly do I run it though? In command line mode that is. I'm not usually a windows user and have no idea how to do this on a windows machine. \$\endgroup\$ Commented Jun 18, 2014 at 20:56
  • 1
    \$\begingroup\$ I've never run it that way. You'll have to try it out for yourself. You can either open a command window ('cmd.exe' on the Start menu) or run it from whatever language you are using to sequence your tests. \$\endgroup\$
    – The Photon
    Commented Jun 18, 2014 at 21:09
  • 1
    \$\begingroup\$ If your using matlab, they have a script to convert .raw files mathworks.com/matlabcentral/fileexchange/… \$\endgroup\$
    – Voltage Spike
    Commented Oct 6, 2017 at 17:31

Have you tried "LTSpice Queue Manager"? (The link redirects to my own website where you can download the software but I'm not its author, who originally shared the program on a forum that is today closed. Sharing it through my website is a way to revive it).

This tool has been of much help to me in the past. You can prepare many simulation files and run them in a queue fashion.

LTSpice queue manager

  • \$\begingroup\$ Queuing is not automation. \$\endgroup\$ Commented Mar 16, 2018 at 19:26
  • 2
    \$\begingroup\$ If the automation you need is queuing, it certainly is! This addresses OP's problem directly. \$\endgroup\$
    – Daniel
    Commented Mar 16, 2018 at 19:34
  • 3
    \$\begingroup\$ If this is closed-source software that you didn't write, I would expect users to be understandably leery of running it. \$\endgroup\$
    – Dave Tweed
    Commented Mar 18, 2018 at 11:21

PyLTSpice seems to be the hero of the day:

PyLTSpice is a toolchain of Python utilities designed to interact with LTSpice and NGSpice Electronic Simulator.

It's shipped as a bouquet of different modules. The one most relevant to your needs appears to be sim_batch.py.


Excerpt from its description:

This module is used to launch LTSPice simulations. Results then can be processed with either the RawRead or with the LTSteps module to read the log file which can contain .MEAS results.

The script will firstly invoke the LTSpice in command line to generate a netlist, and then this netlist can be updated directly by the script, in order to change component values, parameters or simulation commands.

Different models can be simulated in a single batch, by using the following instructions:

  • set_element_model('D1', '1N4148') - Replaces the Diode D1 with the model 1N4148
  • set_component_value('R2', '33k') - Replaces the value of R2 by 33k
  • set_parameters(run=1, TEMP=80) - Creates or updates the netlist to have .PARAM run=1 or .PARAM TEMP=80
  • add_instructions(".STEP run -1 1023 1", ".dc V1 -5 5")
  • remove_instruction(".STEP run -1 1023 1") - Removes a previously added instruction
  • reset_netlist() - Resets the netlist disarding all edits made to it.

A Full Example for a Similar Use-Case

...again, copied from the Pypi repository:

import os
from PyLTSpice import SimCommander

def processing_data(raw_file, log_file):
    print("Handling the simulation data of %s, log file %s" % (raw_file, log_file))

# Select spice model
LTC = SimCommander("Batch_Test.asc")

# Set default arguments
LTC.set_parameters(res=0, cap=100e-6)
LTC.set_component_value('R2', '2k')
LTC.set_component_value('R1', '4k')
LTC.set_element_model('V3', "SINE(0 1 3k 0 0 0)")

# Define simulation
    "; Simulation settings",
    ".param run = 0"

for opamp in ('AD712', 'AD820'):
    LTC.set_element_model('XU1', opamp)
    for supply_voltage in (5, 10, 15):
        LTC.set_component_value('V1', supply_voltage)
        LTC.set_component_value('V2', -supply_voltage)
        # overriding he automatic netlist naming
        run_netlist_file = "{}_{}_{}.net".format(LTC.circuit_radic, opamp, supply_voltage)
        LTC.run(run_filename=run_netlist_file, callback=processing_data)

    "; Simulation settings",
    ".ac dec 30 10 1Meg",
    ".meas AC Gain MAX mag(V(out)) ; find the peak response and call it ""Gain""",
    ".meas AC Fcut TRIG mag(V(out))=Gain/sqrt(2) FALL=last"


# Sim Statistics
print('Successful/Total Simulations: ' + str(LTC.okSim) + '/' + str(LTC.runno))

The repo has seen 10 updates between 2022-2023 so be sure to check out its most current documentation and version: PyLTSpice


If it just has to be LT Spice and you can't get past the GUI I would recommend the script program AutoIt. I've used it to automate some critical Windows applications which were lacking active-x-DDE-COM.dll-whatever. You can set it up to wait for files, push windows buttons, menuitems, call programs with arguments, etc.

Have a look at:



I would go for Winbatch if you want to pay for a script program.


Not the answer you're looking for? Browse other questions tagged or ask your own question.