Electronics > Projects, Designs, and Technical Stuff

Signal processing - getting exact frequency from short ADC sample

<< < (13/18) > >>

Kleinstein:

--- Quote from: ogden on December 17, 2019, 08:50:23 pm ---
--- Quote from: KE5FX on December 17, 2019, 08:36:15 pm ---Optimizing the SNR performance of this sort of measurement usually comes down to reducing the measurement bandwidth, given that the target signal is a narrowband signal embedded in noise whose spectrum is potentially (DC-daylight].  It's easy to implement a narrowband filter near DC, not so easy to implement it at any arbitrary RF carrier frequency. 

This is is true nowadays as it was for Major Armstrong in 1918.

--- End quote ---
Near DC means very limited (narrow) range of input frequencies, big group delays of filters, thus long sampling/processing periods. If this method is so good for RF, then why all frequency counters uses zero crossing count method instead? ;)

--- End quote ---

Filtering the signal to a narrow band does not have to run as a classical FIR or similar filter. Frequency sensitivity can be a inherent more hidden feature. If one is only interested in the frequency one does not care about group delays per se. However the group delays have to be kept in mind when using a classical narrow band filter, especially for the important beginning and end. The data points at the ends are the most valuable. Use them just for filter settling is a bad idea.

The usual frequency counters use the zero crossing method. This is because it is very easy and can be used at rather high frequencies.
However microwave range "counters" do use different methods, like first mixing the input signal and down conversion to a, much lower frequency that is than analyzed in a different way. I don't know the details, but in modern implementation it could be well possible to use some kind of digital analysis like describes in the articles cited here. 

nctnico:

--- Quote from: Berni on December 17, 2019, 07:32:44 pm ---It shows these methods being fed sinewaves with various types of noise and distortion applied to them. One of them being my proposal that is here named as "Signal demodulation". On page 13 and on you will find figures 9 to 17 showing graphs of the results, notice how graph D (showing the demodulation method) is always rock solid on the right frequency no matter what kind of noise is injected into the signal, nor does it show any quantization steps.

--- End quote ---
I wouldn't say that. SDM shows weird startup behaviour in several graphs and it seems that the ZC (zero crossing) is determined over one period only. If you filter the input signal to a frequency band of interest and average the ZC over multiple periods (which is very applicable to the OP's intended use) you'll get very good results as well. You have to keep in mind that the paper is about tracking mains frequency which is a continuous signal and not a burst. Besides that tracking mains frequency seems to be time sensitive as in needing the answer as quickly as possible.

Berni:

--- Quote from: ogden on December 17, 2019, 08:18:13 pm ---
--- Quote from: Berni on December 17, 2019, 07:32:44 pm ---As for the Phasor angle estimator, i agree. If you convert the signal into a phasor you know its exact frequency and job done. However can you recommend a simple and reliable algorithm for turning ADC samples into a phasor?

--- End quote ---
Cartesian to polar coordinate transform. I think paper in the link below may answer this question as well.

--- End quote ---

Yes i agree that's what my approach uses to turn a quadrature I/Q signal into phase and magnitude.

But since the ADC is only spitting out real number samples where do you get the imaginary component to plug into the Cartesian input value? Or is the polar phase always just 0° or 180° ?


--- Quote from: ogden on December 17, 2019, 08:18:13 pm ---
--- Quote ---I'm sorry if i am being annoying with this, not trying to argue or anything but just trying to get on the same page with this phasor approach.

--- End quote ---
Don't be sorry at all. This is interesting topic, thank you for arguing. I believe that there is no single "ultimate" solution, every approach may have it's strong and weak points. I think following paper will give some insight into phasor approach. https://www.researchgate.net/publication/323628162_Implementation_Techniques_for_Frequency_Phasor_Estimation_in_Phasor_Measurement_Units_PMUs

--- End quote ---

I do agree there is no single best method. As it usually is in engineering every solution has its own sets of different advantages and disadvantages.

Yep that paper does describe the approach to turning a sequence of real samples into a phasor:

--- Quote ---MATLAB model of Phase Measurement Unit is
developed using recursive and non-recursive DFT algorithms
to get the required phase and magnitude of the signal.

--- End quote ---

And it uses DFT to do it. So its pretty much just doing FFT of the ADC signal and then picking out the bin of interest, checking its phase. Doing another FFT of a signal sometime in the future, getting the phase of that too, finnaly calculating the difference between the two phases to get the full phasor.

The DFT takes a horrendously large amount of computational work to calculate when you have decent sized inputs of >1024 samples. So anyone in the right mind would use FFT as it takes a lot less calculation to get the same result the DFT would give. On the upside there is no need for a input FIR filter to clean the signal since FFT can select the frequency it wants to look at, but even with FFT the computation for 1024 points takes around 25000 multiply operations and around 50000 sum operations(Or about 25 mul and 50 sum per sample). But since we are only interested in a narrow frequency window its not really necessary to calculate all of the spectrum, FFT unfortunately can't calculate just part of it, but DFT can do that. Yet if you look at what one frequency bin of a DFT actually does, you will find that its just correlating the signal against a sine and cosine of the given frequency, returning a complex number in rectangular form... much like a quadrature I/Q mixer does. Okay i admit if we are completely accurate here mixers don't do the same thing as correlation (that is integrating via sum, not via multiply), but the end result is pretty much the same thing, extracting the real and imaginary component so that it can be turned into a polar complex number.

You are going for the same idea as the approach i suggested, the only difference is that my suggestion takes a bit of a computational shortcut using a mixer.


--- Quote from: ogden on December 17, 2019, 08:50:23 pm ---Near DC means very limited (narrow) range of input frequencies, big group delays of filters, thus long sampling/processing periods. If this method is so good for RF, then why all frequency counters uses zero crossing count method instead? ;)

--- End quote ---

Its because DC is a real bitch to deal with. This is the reason why analog circuitry often uses AC coupling capacitors in the signal path as soon as they are not required to work down to DC. Makes designing the analog circuit in the real world so much easier.

This is also one of the reasons why mixers are usually not used with a local oscillator frequency that is identical to the signal of interest, you put the local oscillator off by a little bit on purpose so that your mixers output path can be AC coupled. Using this you move the signal of interest into an frequency area where your particular filter works best rather than the other way around for having to make your filter good where your particular signal is. In the case of FIR filters this means you need less steep of a filter, hence fewer coefficients hence easier to compute.

As for why frequency counters use zero crossing, its because its the easiest thing to do in hardware and we know how to make really fast GHz speed divide by 2 clock dividers. Also they usually don't try to focus on a frequency band of interest and are designed to measure any shape of signal, not just sine waves.

ogden:

--- Quote from: Berni on December 17, 2019, 09:38:41 pm ---But since the ADC is only spitting out real number samples where do you get the imaginary component to plug into the Cartesian input value? Or is the polar phase always just 0° or 180° ?

--- End quote ---
Yes. You prepare real waveform for complex DFT or FFT same way.


--- Quote ---And it uses DFT to do it.

--- End quote ---

Not what I wanted to say. My bad. Can't find *that* document anymore. Will try to explain, in brief, simplest possible approach that obviously can be " extended".

1) low-pass filter and normalize amplitude to (+/-) 1.0  2) run through "rising edge" zero-crossing detector to find first sample of sine period. As we have normalized waveform, calculate initial phase directly from amplitude: arcsin(amplitude1) 3) after enough (N) periods, thus zero-crossing detector "triggers", find final sample - and calculate final phase arcsin(amplitude2). 4) that's it. Calculate frequency f = (2*PI*N-arcsin(amplitude1)+arcsin(amplitude2))/(2*PI*delta_t). Example calculation for 1MSPS system, single period 10 samples, amplitude1 = 0.1 and amplitude2 = 0.2 here, result is 101.61 KHz. Frequency is higher than 100KHz because phase rotated more than 2*PI. You can plug 0.1 number into both arcsins to get expected 100KHz - period exactly 10 samples.

ogden:

--- Quote from: Kleinstein on December 17, 2019, 09:25:54 pm ---If one is only interested in the frequency one does not care about group delays per se. However the group delays have to be kept in mind when using a classical narrow band filter, especially for the important beginning and end. The data points at the ends are the most valuable. Use them just for filter settling is a bad idea.

--- End quote ---

Well, well. I would like to remind what is written in the Subject of this thread and OP:


--- Quote from: daqq on December 13, 2019, 09:48:55 am ---Assuming that I have data sampled at 100ksps @ 12bit, ignoring timing jitter, the sample size is 2ms (200 samples), is there any method that would enable me to determine the shift of a frequency of sine sampled using this with a large, 0.1Hz resolution? Basically doppler stuff, with the base signal being a pulsed sine at 10kHz. The expected shift is pretty small, 1 to 2 Hz max.

--- End quote ---

2ms means just 20 periods of the carrier signal. Nothing much you can downconvert, then low-pass filter in this case. You will hit end of the sample buffer long before low-pass filter settling. Berni may think about this as well.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod