How to shut down (LT) Spice after calculation

Thread Starter

arben

Joined Mar 10, 2014
1
Hello everyone

I use Matlab to create netlists for LTspice, then I call LTSpice multiple times form Matlab using the "system" comando. Until now, I have to quit every LTSpice instance manually after calculations. Is there a way to do this automatically?
 

ActivePower

Joined Mar 15, 2012
155
I'm not sure if this fits the bill - just shooting in the dark here, but you could use MATLAB's timers to start and terminate system processes after specified amounts of time. This is just a hack but it'd probably work.

To check, I just wrote a MATLAB script to automatically start and end a process under Windows 7.

Here's the script (in entirety):
Rich (BB code):
% HandleProcess.m
% MATLAB Script to automatically initiate and close system processes
% OS: Windows 7 (64-bit)
%
% System commands:-
%   View all processes:     tasklist
%   Kill process by name:   taskkill /IM
%
% Usage (from Command Line or another script)
%       >> global PROCESS;
%       >> PROCESS = 'ltspice.exe';
%       >> HandleProcess();

%% Function to start process

function [] = HandleProcess()
    
    sysTimer = timer('TimerFcn', @(x, y)pause(1), 'Period', 10);
    
    % Start system process (Important: Append '&' to make it a background process otherwise timer won't terminate)
    global PROCESS;
    proc = [PROCESS, ' &'];
    system(proc);

    sysTimer.StopFcn = @(~, ~)KillProcess;
    start(sysTimer);

end

%% Function to kill processes 

function [] = KillProcess
    
    global PROCESS;
    cmd = 'taskkill /IM ';
    command = [cmd, PROCESS];
    disp(command);
    disp('Killing process!');
    system(command);

end
Maybe you could adapt it for your purpose.

Hope this helps.
 
Last edited:

tshuck

Joined Oct 18, 2012
3,534
Running it in batch mode might make it exit on completion (I'd have to look to be sure).

There is a batch mode command line option (-b, if I remember right).
 
Top