• .
  • Willkommen im Forum!
  • Alles beim Alten...
  • Du hast kaum etwas verpasst ;-)
  • Jetzt noch sicherer mit HTTPS
Hallo, Gast! Anmelden Registrieren


THD-über-Frequenz Darstellung in LT-Spice mit ltspdisto
#9
Hab nochmal an potentiellen Stolperstellen einen ergänzenden Kommentar hinzugefügt und so ### gekennzeichnet.


Helmut Sennewald, 09/12/2006
V0.51
This program can plot the THD versus frequency.

You need Perl on your PC to run this application. See the links at the end.
Additionally I recommend the text editor "PSPad" for syntax highlighting.

### Perl installieren => http://www.perl.org/get.html
### Optional Notepad++ installieren => http://notepad-plus-plus.org/download/v5.9.3.html

1.
Before you can run it, you have to set the correct path to the LTspice
executable "scad3.exe". This path has to be set in one of the first lines
of the Perl-script "ltspdisto.pl".

$ltspice = '"C:\Programme\LTC\SwCADIII\scad3.exe" -b' ;

Change it to your installation, e.g. as shown below.

$ltspice = '"D:\programs\LTC\SwCADIII\scad3.exe" -b' ;

### Ist in Zeile 16 zu finden. Wichtig ist, falls der Pfad angepasst werden muss, die einfachen Hochkommata sowie das -b zu erhalten.

2. Generate a netlist from your schematic.
Therefore set the option to keep the netlist.
Control panel Kartenreiter Operation -> set "Automatically delete .net files" to NO.
Run one simulation with the schematic or use the View->SPICE netlist from the
menu to generate the netlist file (.net).


3.
Open a command window (cmd) in XP.

Now run the Perl interpreter with the script.

perl ltspdisto.pl amplifier.net disto.cir DEC 20 20 20000

### Wichtig: Zuvor in das Verzeichnis wechseln, in dem die Simulationsdatien liegen.
### Beispiel:
### cd c:
### cd meinVerzeichnis\meinUnterverzeichnis
### ENTER drücken
### Die Zeile mit dem Aufruf (perl ltspdisto.pl amplifier.net disto.cir DEC 20 20 20000) in die Zwischenablage kopieren und in der CMD-Box mittels rechter Maustaste einfügen und ENTER drücken.


This example will generate 'disto.thd' and 'disto.raw' with the netlist
'amplifier.net', e.g. from the schematic 'amplifier.asc'.
It could be any pure netlist too. The only requirement in the
schematic/netlist is one line exactly written as shown below.

--------------------------------------------------------------


Some more details how the program works.

There is one specific param-line necessary in the netlist.

.param F1=

This line is altered from run to run by the Perl-script.
1. run: .param F1= 1000
2. run .param F1= 1137
3. run ...


DEC 20 20 20000 means sweep from 20Hz to 20000Hz with 20 steps/decade

A source in the schematic should use this parameter F1 as the
frequency and a .FOUR command should use this parameter too.

.FOUR {F1} V(out)

V1 10 0 SINE(0 1 {F1})


The Perl-program performs multiple simulation runs while
incrementing the parameter F1(normally frequency) from run to run.
After every run, the result of the FOUR-analysis is read from the
log-file and written to a text-file and at the end to a raw-file
too. The advantage of this method is that you will get the full
accuracy of the FOUR-analysis. The output text-file can be used
with any other program like MS-Excel or OpenOffice-Calc.
Another big feature is the raw-file. It allows you to use the
waveform viewer to view the magnitude (and the phase) of the
distortion.
I have uploaded a screenshot to the 'Photos' section of this group.
"Distortion plots with 'ltspdisto.pl'"
There is also a screenshot for a short time frame available.
Files > Temp > disto.raw

The zipped version of this program together with an example is
available from the Files section.

Files > Util > ltspdisto.zip

I am a novice with Perl. So please no bad comments about my
Perl-style. Just improve the program by yourself. lachend

There are free of charge Perl interpreters.
I have used Perl 5.8.8. Msi(x86) from the next link.
http://www.activestate.com/Products/Down...ActivePerl
A smaller Perl.
http://tinyperl.sourceforge.net/


This THD-meter is not limited to step only the frequency. The
parameter 'F1' can be used to vary any parameter in your circuit
to plot e.g. THD versus some bias current, but then at a constant
frequency.

A detailed specifiaction can be found in the header of the Perl-
program 'ltspdisto.pl'.

Best regards,
Helmut

PS:
The waveform viewer can format the result.
Plot V(THD)/1V to remove the unit V.
Plot I(k2)/1A*1deg to get the unit degree for the phase of k2


Und so sieht das Ergebnis dann aus: [Bild: 920_perl_batch.PNG]
 
  


Nachrichten in diesem Thema
[Kein Betreff] - von kahlo - 23.09.2011, 09:56 AM
[Kein Betreff] - von Calvin - 23.09.2011, 10:11 AM
[Kein Betreff] - von alfsch - 23.09.2011, 10:14 AM
[Kein Betreff] - von Calvin - 23.09.2011, 10:24 AM
[Kein Betreff] - von kahlo - 23.09.2011, 11:47 AM
RE: - von voltwide - 23.09.2011, 02:28 PM
RE: - von Rumgucker - 23.09.2011, 02:31 PM
[Kein Betreff] - von e83cc - 23.09.2011, 07:19 PM
RE: - von Rumgucker - 23.09.2011, 08:11 PM
[Kein Betreff] - von Calvin - 24.09.2011, 11:06 AM
[Kein Betreff] - von e83cc - 24.09.2011, 12:24 PM
[Kein Betreff] - von Calvin - 24.09.2011, 12:36 PM
[Kein Betreff] - von e83cc - 24.09.2011, 12:43 PM
[Kein Betreff] - von Calvin - 24.09.2011, 12:52 PM