4

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,

winny
  • 13,064
  • 6
  • 46
  • 63
Jess
  • 2,694
  • 1
  • 18
  • 46
  • If you posted a schematic of what your circuit is, it's more likely to be explained. – Andy aka Aug 03 '20 at 11:51
  • In the added schematic you have written in blue "resonant frequency = 15M87" and that is about right so, where did that expression come from and why can't you use it? – Andy aka Aug 03 '20 at 12:15
  • Yeah this is the right frequency but I measured it thank to cursors and I do it manually ... – Jess Aug 03 '20 at 14:17
  • But you can calculate it so easily from the values in your circuit - it's 15.915 MHz just by using simple calculations. How accurate do you need it to be? – Andy aka Aug 03 '20 at 14:34
  • You re right ! I made this simulation for seeing how to size a snubber. In this case, i set arbitrarly the output mosfet capacitance. Nevertheless, later I would like to set a Mosfet model where I do not know the output capacitance and other parameters that may influence how the ringing frequency evolve. Actually I do not know how are modelized MOSFET in LTspice but I hope that the different capacitance of the MOSFET are function of the voltage applied across it. In any case It will always be an approximation as it is not really representative of a real board/temperature ... – Jess Aug 03 '20 at 14:58
  • What do you think about this idea ? – Jess Aug 03 '20 at 14:59
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/111366/discussion-between-jess-and-andy-aka). – Jess Aug 03 '20 at 15:09
  • 1
    @Jess If you look in the help file, in `LTspice > Circuit Elements > M. MOSFET`, you'll see exactly how the VDMOS has the nonlinear capacitance modeled. – a concerned citizen Aug 03 '20 at 15:32
  • Ok :) I have a lot of things to learn actually and it is really a lot of time to take ! – Jess Aug 03 '20 at 18:29

1 Answers1

7

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

a concerned citizen
  • 21,167
  • 1
  • 20
  • 40
  • 1
    Thank you very much for this help ! Thanks for the dot :) And thanks for the tips about external script. I didn't know it ! It could be helpful one day ! – Jess Aug 03 '20 at 14:30