Tuesday 30 May 2017

circuit analysis - LTSpice: How to use .meas command to find the fundamental frequency of non-sinusoidal signal?


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)



Answer



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.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...