Author Topic: 8 – 11 digits reciprocal frequency counter 0.1 Hz – 150 MHz  (Read 21701 times)

0 Members and 1 Guest are viewing this topic.

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14856
  • Country: de
Re: 8 – 11 digits reciprocal frequency counter 0.1 Hz – 150 MHz
« Reply #75 on: June 18, 2023, 04:00:01 pm »
The Linear regression type is good for phase noise - for white phase noise it should be the statistical best solution. However it is not that good for a more frequency type noise.

One gets phase noise from things like the quatization (limited clock frequency) and the trigger noise with a more rounded noisy signal.
One gets a more frequency type noise with many not so stable oscillators. In this case one still needs to define what frequency is considered the true value.

Ideally the linear regression can also give the residuals and thus a crude estimate for the phase noise. This can work at least for the cases with a not so good signal. With a stable signal it may just be the intrinsic quatization part. So the resolution for the phase noise may not be meaningful for a good signal. It still helps to know when the signal is not stable.
 
The following users thanked this post: tverbeure

Offline tverbeure

  • Regular Contributor
  • *
  • Posts: 67
  • Country: us
    • tomverbeure.github.io
Re: 8 – 11 digits reciprocal frequency counter 0.1 Hz – 150 MHz
« Reply #76 on: June 18, 2023, 04:55:24 pm »
good information. I used histogram method and now wondering what is better. When gaussian-like peak is added to high resolution 1d histogram array for each measurement, a final peak formed over the time. Linear regression seems a better option but only if measurements do not contain noises. What I tried to achieve is to not only count the pulses, but also detect noise or signal interruptions, while still providing correct measurement. Many frequency counters show wrong results if signal is too weak, I experienced it many times when used HMC363 prescaler with weak input signal.
I hadn’t heard about the histogram method. Does it work the same, by taking multiple samples within the same gate time, with an ever increasing number of reference clock cycles?
 

Offline Georgy.Moshkin

  • Regular Contributor
  • *
  • Posts: 177
  • Country: hk
  • R&D Engineer
    • How to become a Tech Sponsor
Re: 8 – 11 digits reciprocal frequency counter 0.1 Hz – 150 MHz
« Reply #77 on: June 19, 2023, 03:49:00 pm »
not some special method, just taking each measurement and adding it to 1d array.  E.g. 3 element kernel array {1,2,1}. First measurement gave 33, second measurement 34. Array elements from 32 to 35 become {1,3,3,1}. Third time measured 34 again. Array elements from 32 to 35 {1,4,5,2}. Fourth time measured 38. Array elements from 32 to 39 {1,4,5,2,0,1,2,1} and so on. Then finding peak, in the above array peak is at element  34 (hist[34]=5) and it is not affected by noisy "38" value, even if it was "138". Sorry for such explanation.
My next attempt was to use sliding window of measurements. Oldest measurement substracted from histogram, newest was added. This required more memory, but provided more responsive readings. Actually, significantly less advanced what you guys doing here.
Next idea was to use larger histogram, and then use gaussian blur on this 1d line of pixels (to make non-zero derivatives for peak finding algorithm). During these experiments I thought on other problem and had an idea than input data for Kalman filter type models should be always filtered by using histograms. And one important advantage of histograms is absence of computations, only addition of kernel array to histogram array around certain element in a loop.
Disappointed with crowdfunding projects? Make a lasting, meaningful impact by becoming a Tech Sponsor today. Visit TechSponsor.io to Start Your Journey!
 

Offline tverbeure

  • Regular Contributor
  • *
  • Posts: 67
  • Country: us
    • tomverbeure.github.io
Re: 8 – 11 digits reciprocal frequency counter 0.1 Hz – 150 MHz
« Reply #78 on: June 20, 2023, 07:06:57 pm »
Ok, that makes sense. When the incoming signal or the reference clock isn't fully stable, it will return the most likely value. But it will never increase the precision.
 

Offline Georgy.Moshkin

  • Regular Contributor
  • *
  • Posts: 177
  • Country: hk
  • R&D Engineer
    • How to become a Tech Sponsor
Re: 8 – 11 digits reciprocal frequency counter 0.1 Hz – 150 MHz
« Reply #79 on: June 21, 2023, 01:46:19 am »
Ok, that makes sense. When the incoming signal or the reference clock isn't fully stable, it will return the most likely value. But it will never increase the precision.
Well noted! And it does not help with resolution as well. During the experiments, I found it very interesting that many image processing algorithms can be applied to the spectrum (as line of pixels) and spectrogram (as a 2d image). E.g., curve tracing with subpixel curve extraction (parabola interpolation) easily runs in Realtime on STM32F446 mcu written in plain C (each 1024 points with sampling frequency around 40kHz / or each 25ms)

I am very interested in this precision improvement topic but do not feel experienced enough. I hope more experienced people may comment on below hypothesis. A little off topic background information first: when I researched the topic of object movement prediction, majority of sources used Kalman filter approach. What always bugged me is this "optimal" word added everywhere. It was obvious to me, that it is far from optimal if there is a significant noise in measurements. Especially if noisy values were biased and added up in some weak ghost-type measurement. For frequency counters, "ghost" measurement can emerge from power source noises if poorly designed or there is some hardware malfunction.

And now the hypothesis itself.
As in Kalman filtering, even based on very well-made model formula, linear regression (using least squares), uses formulas where information about (x,y) coordinates is lost during computations. It is lost in the sense that you can't re-build original noisy data by using result of linear regression. I think that this may indicate that input data is not used in an optimal way. So maybe input data needs to be pre-processed to achieve best results, e.g. by building 2d histograms before running linear regression. First step: 2d histogram is built. Can we rebuild input data? Yes, each point on 2d histogram tells us how many times (x,y) value occurred in input data. To me this means, that information on datapoint positions was used wisely, and we can move forward (we extracted some data, which is not used optimally during raw least squares method). Only relative time of point occurrence is lost. Second step: linear regression on resulting data. I think it is obvious that we can make many synthetic examples with artificial noise worsen linear regression and Kalman filter results by a measurable amount. At the same time, result of linear regression on pre-processed data in many cases may remain unchanged. In my above example, fourth measurement represents 25% of input data, a huge amount. Notice how easily it was filtered out, and not computationally intensive (may require a lot of RAM though). To sum up, my hypothesis is that there can be simple pre-processing step, which generally improves precision of least squares regression. If it is a foolish idea, I would be happy to hear why.
« Last Edit: June 21, 2023, 01:50:13 am by Georgy.Moshkin »
Disappointed with crowdfunding projects? Make a lasting, meaningful impact by becoming a Tech Sponsor today. Visit TechSponsor.io to Start Your Journey!
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14856
  • Country: de
Re: 8 – 11 digits reciprocal frequency counter 0.1 Hz – 150 MHz
« Reply #80 on: June 21, 2023, 08:01:21 am »
The optimal in methods for calculating values from a set of measurements usually means a method with the lowest sensitivity to noise. This comes from the statistics as the mathematical field dealing with such problems. Which method is optimal of cause depends on the type of noise or in the mathematical sense the statistical model. For the simple case of white (uncorrelated) phase noise the method with the linear regression is optimal in this sense and gives the lowest possible noise. This kind of carries over from the linear regrssion as the best method to calculate a slope.
By definition noise is unbiased and good calculation methods should not produce a bias when noise is added.

However when the type of noise changes (e.g. FM noise) than this can also change which method is best. In case of pure FM noise the mathematical best method is the simple reciprocal counter, looking only at the first and last time stamp.

A nice part in statistics is that one can often reduce the data quite a bit before doing the final math. So not having a way to calculate back the original data is no a bad thing. The point is to keep the important information and drop the irrelevant parts / noise. With a well defined statistical model this is often possible. For many problems this is the first step: find the relevant part (sufficient statistics) that has all the relevant information (within the model). The method to than calculate the result only has to look at these reduced data. In stimple cases the reduction can go that far that it is easy to than guess a good method (e.g. with the pure FM noise the only remaining data are the first and last point and the simple reciprocal counter thus the only sensible and thus best estimator).

A point that the math is not really solving is deciding which is  the right model or assumption for the noise. There are still methods to test if an assumed model is reasonable. So ideally one would also look at the noise and from these data decide if the noise is more white PM noise or contains more FM noise. One could see this as a more complex statistical model that allows for different noise parts. With such more complex models the mathematics is than often no longer able to find optimal solutions.
 
The following users thanked this post: tverbeure


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf