LTSpice tutorials and threads

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
I want output a list power power dissipation and voltage drop across every resistor in my simulation. I would rather do this than click on every element and create a ref voltage point at half the junctures. Also I want this for not just the .op command.

Anyone know how to do this? I assume you write to the log somehow?
 
LTspice IV>Help> type in keyword .save

to put it on your schematic you have to use the <spice directive> button on the far right of the toolbar
 

Attachments

  • help.PNG
    help.PNG
    83.8 KB · Views: 289
Last edited:
you do turn off compression of the waveform data which LTspice does by default? - it will mess up higher resolution distortion measurement

for that I use the .option plotwinsize=0 directive on each schematic - if you do it in the control panel you will forget someday
 
.four, .meas, the waveform and fft viewers are all post processors - they work by reading the data saved in the .raw file after Spice is done running the simulation

no other Spice will work any differently

if you don't need the information on every node, branch V,I then you can use .Save to list just those that you want to keep for the analysis in post processing

for instance I just did a sim with one of my circuits that created 95M .raw file
with the directive:
.Save Is(M1)
the .raw is only 3.5M

if your circuit needs some time to settle from the turn on transient you can also cut the size of the .raw output by specifying in the .tran a time to start saving data - just save the last cycle of the analysis frequency of your .four fundamental

but the post processors all require the .raw saved data, no way around that


in the LTspice Yahoo Group you can find some optimizer scripts that modify the netlist and call LTspice, then grab the data needed from the .log file with text filters, and repeat with new calculated netlist values for the parts being optimized
in that mode the .raw never needs to be bigger than the single run instead of having 100s or 1000 .steps
 
Last edited:
I have made a python script to run LTspice in batch mode

Currently there is only one variable ({RA}) but I'll update it to use N variable

The output file is a CSV

Code:
import os
import subprocess

SPICEEXE='C:\LTC\LTspiceIV\scad3.exe '

INFILE='C:\PERSO\SIMULATION\LTSPICE\ZERO\MODBATCH.cir'
TMPFILE='C:\PERSO\SIMULATION\LTSPICE\ZERO\MOD_OUT.cir'

OUTFILE = open('C:\PERSO\SIMULATION\LTSPICE\ZERO\MOD_OUT.csv','w+')

RA = 1
RA_MAX = 10
RA_INC =1


while RA <= RA_MAX:
	fin = open(INFILE,'r+')
	fout = open(TMPFILE, 'w+')
	for line in fin:
		line = line.replace("{RA}", str(RA))
		fout.write(line)
	fin.close()
	fout.close()
	subprocess.call(SPICEEXE + TMPFILE+ " -b")
	LOGFILE = open('C:\PERSO\SIMULATION\LTSPICE\ZERO\MOD_OUT.log', 'r+')
	for log in LOGFILE: 
		if log.find('Distortion:') > 0:
			OUTFILE.write(str(RA) + ';')
			OUTFILE.write((log.split('Distortion: ')[1][:-2] + '\n').replace(".",","))
	RA = RA + RA_INC
OUTFILE.close()

Code:
RA;THD
1;0,013499
2;0,026174
3;0,039158
4;0,051854
5;0,064181
6;0,076044
7;0,087379
8;0,097919
9;0,107979
10;0,117220
 
Last edited:
halo mister
lot variable step is required to optimize the circuit
to look for maximum amplitude with low distortion
i want to analyze 5th order distortion to 2nd distortion
so the max amplitude not will low thd but have low higher odd distortion also
if the step not limited to 3, i m sure a more lot people want to use it
 

Attachments

  • A1.gif
    A1.gif
    45.4 KB · Views: 138
Ex-Moderator
Joined 2011
The part tolerances for tube amps are quite wide and drift with tube aging, so if you have to optimize 20 parameters just to get ultra-low distortion, then why not just stick with a pure SS design?

Also take a look at using the Monte Carlo function in LTSpice, I don't think there is a limit on the number of components that can be used, if there is, it is probably higher than 3.
 
Last edited:
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.