[time-nuts] New algorithm, better ADEV

Li Ang lllaaa at gmail.com
Wed Jan 14 15:55:53 UTC 2015


Hi
    Just now, I changed the way to calculate frequency and get a better
ADEV chart.
http://www.qsl.net/b/bi7lnq/freqcntv4/test/20150114/0114.gif
http://www.qsl.net/b/bi7lnq/freqcntv4/test/20150114/newway.tim
http://www.qsl.net/b/bi7lnq/freqcntv4/test/20150114/oldway.tim


    Thanks to John Miles's reply in the thread about ADEV.

> If you feed in frequency samples, it will convert them to phase-difference samples internally, so the
> program itself doesn't really care.  The use of frequency data has a few drawbacks such as less accurate
> ADEV plots due to the counter's dead time between readings, but it's the easiest way to get started and is
> perfectly usable for many purposes.
>
>
Old way:
//reset counter every second to avoid the overflow issue
while (1) {
     reset_fpga_counter();
     trigger_and_read_cnt(&refA, &sigA);
     delay_1s();
     trigger_and_read_cnt(&refB, &sigB);
     Freq = Calc_freq(refB - refA, sigB - sigA);
}


New way:
//The counter keeps running. The software takes care of the overflow issue.
No dead time.
trigger_and_read_cnt(&ref_prev, &sig_prev);
while (1) {
   delay_1s();
   trigger_and_read_cnt(&ref_curr, &sig_curr);
   ref_delta = (ref_curr > ref_prev) ? (ref_curr - ref_prev) : (0xffffffff
- ref_prev + ref_curr);
   sig_delta = (sig_curr > sig_prev) ? (sig_curr - sig_prev) : (0xffffffff
- sig_prev + sig_curr);

   Freq = CalcFreq(ref_delta, sig_delta);
   ref_prev = ref_curr;
   sig_prev = sig_curr;
}


BTW: I've put the counter into a box.
http://www.qsl.net/b/bi7lnq/freqcntv4/pic/20150114_212857.jpg
more pictures: http://www.qsl.net/b/bi7lnq/freqcntv4/pic/



More information about the Time-nuts_lists.febo.com mailing list