Electronic – LTspice – Measuring the resonant frequency

ltspice

I would like to measure the resonant frequency automatically in LTspice, i.e. with the command ".meas" of the following waveform. Is it possible to do it by using the FFT plot? I have tried something, but it seems to me to be relatively complicated and I think there is a better way 🙂

enter image description here

Here is the schematic if it can help you.

enter image description here

Thank you very much and have a nice,

Best Answer

There are a few ways you could do it. One would be with the FFT. If you only need a quick result, you could simply perform an FFT analysis straight on the waveform, as it is. You'll see something like this:

FFT

This is the resultof a 1024 points FFT, without binomial smoothing. It's ugly, because no special care has been taken care of -- it's an exponentially decaying waveform, not an exact number of periods, compression is on, no imposed timestep, bla, bla -- for which the cursor reads 1.6Hz. Given the resolution, it's close enough to 1.59 Hz.

If you want more precise numbers, .measure is the way to go. Then you could use these commands (using the previous picture as reference, since I can't read the axes in your picture):

.meas t1 find time when v(x)=0 cross=2
.meas t2 find time when v(x)=0 cross=4
.meas t3 find time when v(x)=0 cross=6
.meas t4 find time when v(x)=0 cross=8
.meas f1 param 1/(t2-t1)
.meas f2 param 1/(t3-t2)
.meas f3 param 1/(t4-t3)

I started with cross=2 to avoid possible mis-readings due to the initial zero response (it looks like you, also, have something like that). To avoid re-running the simulation (sometimes they can take days and many GB of data), you can add those lines ina text file, save it in some meaningful name, then use the File > Execute .MEAS script (with the waveform window active). For this example, these are the readouts:

t1: time=1.31504 at 1.31504
t2: time=1.94466 at 1.94466
t3: time=2.57432 at 2.57432
t4: time=3.20397 at 3.20397
f1: 1/(t2-t1)=1.58826
f2: 1/(t3-t2)=1.58817
f3: 1/(t4-t3)=1.58817

which, again, given no special care has been taken (compression, timestep, numdgt), it's close to the real result. Note that using the .meas commands implies knowing beforehand how the waveform is and where to measure. That's why using an external script is a good choice.

Or you could concoct your own frequency detector, but that would imply burdening the matrix solver with yet another payload.

PS: You, too, have a nice dot