Keyboard Shortcuts
ctrl + shift + ? :
Показати всі комбінації клавіш
ctrl + g :
Не доступний для безкоштовних груп.
ctrl + shift + f :
Знайти
ctrl + / :
Сповіщення
esc to dismiss
Лайки
Пошук
Putting a .FOUR statement in a measurement script
It used to be possible to do .FOUR in post-post processing by putting the
Fourier parameters in a file and use the menu command File=>Execute .MEAS Script after the simulation ran. Am I remembering correctly? This doesn't work in the LTspice 17.1.15 that I have. It still works to put .param statements in the script, but lines with ".four" and ".fourier" are silently skipped. (Actually, what I'm really after is the THD of a signal, a by-product of .FOUR.) -marcel |
marcel wrote:
"It used to be possible to do .FOUR in post-post processing by putting the Fourier parameters in a file and use the menu command File=>Execute .MEAS Script after the simulation ran. Am I remembering correctly?" I do not remember that this was ever possible. As far as I know, the .FOUR command can only be in the main simulation schematic (or netlist), not part of post-processing after the simulation is done. It is possible to "make your own" Fourier transform using .MEAS commands. Tony Casey does this, and has presented his commands a few times in this group. Unfortunately I don't recall where he did that (which file) so I can't give you a pointer. Andy |
I also had to have at least one valid .meas statement in the script and I could not use a .param statement to set the fundamental Fourier frequency. This worked on LTspice XXVII version 17.0.37, but not on LTspice XXIV 24.0.12
The script file was: .meas TRAN IR2_RMS RMS I(R2)
.four 50 25 -1 V(of)
The output appears as follows: N-Period=all
Fourier components of V(of)
DC component:2.3594
Harmonic Frequency Fourier Normalized Phase Normalized
Number [Hz] Component Component [degree] Phase [deg]
1 5.000e+01 2.412e+00 1.000e+00 177.39° 0.00°
2 1.000e+02 9.397e-02 3.896e-02 84.88° -92.51°
3 1.500e+02 5.771e-03 2.393e-03 7.97° -169.42°
4 2.000e+02 1.895e-02 7.858e-03 79.77° -97.63°
5 2.500e+02 2.160e-03 8.954e-04 22.49° -154.90°
6 3.000e+02 8.303e-03 3.443e-03 75.06° -102.34°
7 3.500e+02 1.045e-03 4.331e-04 29.31° -148.09°
8 4.000e+02 4.846e-03 2.009e-03 72.72° -104.68°
9 4.500e+02 5.748e-04 2.383e-04 73.07° -104.32°
10 5.000e+02 3.680e-03 1.526e-03 68.87° -108.53°
11 5.500e+02 1.103e-03 4.572e-04 15.74° -161.65°
12 6.000e+02 2.407e-03 9.978e-04 59.16° -118.23°
13 6.500e+02 6.861e-04 2.845e-04 6.09° -171.30°
14 7.000e+02 1.726e-03 7.158e-04 56.45° -120.94°
15 7.500e+02 2.273e-04 9.423e-05 47.42° -129.97°
16 8.000e+02 1.419e-03 5.884e-04 52.60° -124.80°
17 8.500e+02 3.452e-04 1.431e-04 152.60° -24.80°
18 9.000e+02 1.189e-03 4.928e-04 48.52° -128.87°
19 9.500e+02 6.373e-04 2.642e-04 -179.79° -357.18°
20 1.000e+03 1.050e-03 4.353e-04 42.88° -134.51°
21 1.050e+03 8.384e-04 3.476e-04 -177.88° -355.28°
22 1.100e+03 9.054e-04 3.754e-04 45.22° -132.18°
23 1.150e+03 1.034e-03 4.288e-04 -176.26° -353.66°
24 1.200e+03 7.843e-04 3.252e-04 42.13° -135.26°
25 1.250e+03 1.205e-03 4.996e-04 -179.82° -357.21°
Total Harmonic Distortion: 4.010271%(108.263139%)
IR2_RMS: RMS(I(R2))=0.135886 FROM 0 TO 0.11 |
On 30/06/2024 22:10, Andy I wrote:
I do not remember that this was ever possible. As far as I know, the .FOUR command can only be in the main simulation schematic (or netlist), not part of post-processing after the simulation is done.It's never been possible to do this. Helmut Sennewald wrote a PERL script for semi-automating plotting of THD from .FOUR results in the log file. I submitted a feature request some time ago for tweaking the output text of the .FOUR directive (in the log file) to a format that could be used in the usual "Ctrl-L > Plot .step'ed meas data" routine. While this was received enthusiastically, it was never implemented. (So far.) I've experimented with quite a number of methods of plotting THD without leaving LTspice. Some of them are quite slow, others a bit faster. The one I mostly use these days uses a Wien bridge notch. It's not perfect, because any method (including real world ones that you can build) involving notches, causes a small but finite error in the level of the harmonics due to the finite Q of the notch. I've also used methods of cancelling the carrier by calculating the amplitude and phase of the fundamental in the output waveform and generating an an anti-phase waveform. These methods can be slow, and in practice are not actually better, or often, as good as a simple Wien notch. I have experimented at length for the optimum Q of a notch in terms of the measurement time and accuracy. There are several trade-offs. A high Q rings for a long time when suddenly subjected to an input. A low Q does not ring much, but attenuates the harmonics, giving an inaccurate result. I like the notch methods, because for for free, you get the residual of the output signal. The best compromise I found was by ramping up the amplitude of the input signal to reduce ringing and using a Q of around 5-10 in the notch. Of course, you also need to take care that you also simulate the circuit for long enough that bias levels in the circuit you're testing, have settled. This applies to all methods. As does the use of .OPTIONS plotwinsize=0. In addition, you also need to set an appropriate figure for the maximum time step. In this regard, please refer to https://groups.io/g/LTspice/files/z_yahoo/Files%20sorted%20by%20message%20number/msg_95986/LTspice_THD_Measurement_Test_Results.pdf. For the notch method, I uploaded an example here: https://groups.io/g/LTspice/files/z_groups.io/Examples/Apps/THD%20Notch%20Filter/THD_Notch_Test.zip This doesn't incorporate the latest improvements described above, which haven't been disclosed in detail. Older methods include my Audio_Distortion_Analyser, which was copied and published elsewhere by someone else. -- Regards, Tony |
On Sun, Jun 30, 2024 at 12:35 PM, BRUCE108 wrote:
I don't understand why you can't put the .four statement on the schematic.1. Quite often I don't know exactly what measurements I need, 2. Sometimes a measurement parameter follows from the outcome of the simulation, e.g., the base frequency of say a Colpitts oscillator, 2. I almost never get the syntax right on the first try, 3. Sometimes I want to do new measurements on a simulation I did before (to compare with a modified circuit, or for writing a report). As I never throw away .raw files, certainly not when it takes more than 5 minutes to run them, creating a new script saves me a lot of time and gives qualitatively better results. -marcel |
On Sun, Jun 30, 2024 at 07:23 PM, Mathias Born wrote:
Is it possible to publish release notes on the download page so that we can see which essential improvements a new version will bring? -marcel |
On 09/07/2024 00:32, mhx@... wrote:
Nothing is essential, but some things are desirable. I guess the salient changes will be included in the Change Log, as usual.On Sun, Jun 30, 2024 at 07:23 PM, Mathias Born wrote:Soon, LTspice 24.1 will be released where all this will work. You can then just run the original netlist via "Execute .meas" and it will run all .meas, .four, and .step and get all the parameters right as well.Is it possible to publish release notes on the download page so that we can see which essential improvements a new version will bring? --
Regards, Tony |
On 09/07/2024 08:51, mhx@... wrote:
I would have thought the download page is mainly for new users. Most current users will surely just go to Help > Check for LTspice Updates.On Mon, Jul 8, 2024 at 11:45 AM, Tony Casey wrote:Nothing is essential, but some things are desirable. I guess the salient changes will be included in the Change Log, as usual.A summary on the download page saves the time of a backup and possibly a restore. -- Regards,
Tony |
Повідомлення
Меню
Додаткові параметри
Більше
to navigate to use esc to dismiss