1
\$\begingroup\$

I want to find fundamental frequency of a periodic signal (non-sinusoidal) in certain time window using the .meas command in LTSpice.

I was using the following code to calculate frequency (in kHz).

.meas tran T1 find time when V(OUT)=0 rise 1000 .meas tran T2 find time when V(OUT)=0 rise 1100 .meas tran Frequency param 100/(1000*(T2-T1))

This works fine for certain cases, but when I do the parametric sweep, it gives inaccurate readings because of two issues:

Here, I assume at 1000th cycle, signal reaches its measurement window (say from time=4ms) but sometimes it doesn't. Therefor, I want to specify the absolute time for the measurement. from 4ms in this case, I have added a sample voltage waveform as below (with parametric sweep)

enter image description here

The zoomed waveform from 4ms is

enter image description here

My questions is

Is it possible to specify the starting time for the above code so that it will count cycles from the specified time? ( I tried to use trig-trag and from-to commands but failed)

\$\endgroup\$
  • \$\begingroup\$ If you are only interested in the harmonics, the .four command may be for you \$\endgroup\$ – PlasmaHH Apr 6 '18 at 8:45
  • \$\begingroup\$ @ PlasmaHH, Thanks, But how can we use .four when the fundamental frequency is unknown? Primary goal here to measure the fundamental frequency in a specified time window \$\endgroup\$ – Pojj Apr 6 '18 at 9:16
  • \$\begingroup\$ It sounds a bit like mission impossible: you don't know the fundamental (ok, that's your goal), but you don't know how your circuit will behave (settling time), or how many harmonics it will have (can't rely on .meas). The only thing I see is to run your simulation and then View > FFT, and then decide which one is your fundamental, but this is not an automated process. You say you have a parametric sweep. Can't your harmonics, or anything that you can cling to, be related to the swept parameters? Some correlation? \$\endgroup\$ – a concerned citizen Apr 7 '18 at 7:00
  • \$\begingroup\$ Thanks, actually, the settling time is known. I do not care about harmonies either. Basically, I want an automated way to get an approximate value close to the fundamental from view > FFT - for a zoomed window (e.g. from 1.4ms to 1.5ms) \$\endgroup\$ – Pojj Apr 8 '18 at 14:44
  • \$\begingroup\$ @PlasmaHH, I narrowed down the question. Would you have any recommendations? \$\endgroup\$ – Pojj Apr 16 '18 at 7:01
1
\$\begingroup\$

It looks like you know your final simulation time, and the waveforms are about settled at the end of it, so, considering what I see in your picture, you can consider 4.4ms a mark from which you can measure, like this:

.meas t1 find time when v(out)=0 cross=1 td=4.4m
.meas t2 find time when v(out)=0 cross=3 td=4.4m
.meas T param t2-t1

Looking more closely (the grey-ish waveform), it looks like you have skewed sines in there, which will account for harmonics, so you can't really rely on this measurement for detecting the fundamental, only its apparent period. Just thought I should add this.

\$\endgroup\$
  • \$\begingroup\$ Great! this is what I was looking for. \$\endgroup\$ – Pojj Apr 16 '18 at 7:44
0
\$\begingroup\$

If I understood correctly your signal is periodic, therefore I would expect a command like this to properly measure your fundamental period:

.MEAS TRAN TRise TRIG when v(out) = 1.65 CROSS = 1 TARG when v(out)=1.65 CROSS=3

where: out is the name of your output pin, CROSS=1 and CROSS=3 stands for "the 1st and the 3rd time the signal crosses the specified value", in this case vdd/2 assuming vdd = 3.3V. I use this to evaluate the propagation delay, also in .param simulations and it worked so far.

Hope this helps! Andrea

\$\endgroup\$
  • \$\begingroup\$ Thanks, But this will also have the same two issues associated with my code in the question. \$\endgroup\$ – Pojj Apr 6 '18 at 9:20
  • \$\begingroup\$ Ok, I think I misunderstood your question then. May I ask you to add to the question a waveform screenshot of the signal you'd like to study? \$\endgroup\$ – a_bet Apr 6 '18 at 11:45
  • \$\begingroup\$ Please refer to the edited question \$\endgroup\$ – Pojj Apr 16 '18 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.