Electronics > Projects, Designs, and Technical Stuff

Signal processing - getting exact frequency from short ADC sample

<< < (16/18) > >>

Marco:

--- Quote from: nctnico on December 18, 2019, 10:35:52 pm ---And quadrature mixing doesn't do anything for averaging readings from multiple periods (which is a big advantage of using zero crossing).

--- End quote ---

I kinda missed what quadrature mixing was supposed to do, it's mostly a way to get a complex signal near DC which you can use with the phase method (multiply each complex sample with the conjugate of the subsequent sample, sum them all up, take the angle of the result). The signal being near DC does do something for averaging though, any signal near DC can be trivially filtered through a simple window average before processing. Hilbert transform does not get you this.

nctnico:

--- Quote from: Marco on December 19, 2019, 08:03:57 pm ---
--- Quote from: nctnico on December 18, 2019, 10:35:52 pm ---And quadrature mixing doesn't do anything for averaging readings from multiple periods (which is a big advantage of using zero crossing).

--- End quote ---

I kinda missed what quadrature mixing was supposed to do, it's mostly a way to get a complex signal near DC which you can use with the phase method (multiply each complex sample with the conjugate of the subsequent sample, sum them all up, take the angle of the result). The signal being near DC does do something for averaging though, any signal near DC can be trivially filtered through a simple window average before processing. Hilbert transform does not get you this.

--- End quote ---
But a signal near DC also gets you into trouble with offsets. And due to aliasing you'll need to have both a bandpass filter in the analog and (at least a DC blocking filter) in the digital domain to remove any DC which gets into the ADC. All in all quadrature mixing doesn't give you any advantages because for a practical implementation you'll need just as much processing (filtering) compared to using the zero crossings method. And with quadrature mixing you can't do stuff like throwing away zero crossings which don't make sense (get rid of outlyers).

Berni:
Okay yeah i did forget about DC offset on the input, that would cause issues for a mixer.

But in terms of the aliasing filter that does need to a physical analog filter before the actual ADC. If the ADC acquires aliased samples there is no way to tell in the digital domain if the tone is a real tone or something higher that got aliased down.

And yes the mixer does spit out a useless result at zero crossing, but you would generally have your downsampling window large enough to cover more than one entire period of the signal since yeah there is a lot of the carrier still left in the output signal. Most of the reason i claim it as being computational cheep is because the filter can be combined with the mixer into one MAC operation that generally takes a single cycle to execute(And also works well with SIMD).

For when computational power is not so much of a concern i do admit that FFT is probably the best choice since not only does it have excellent noise resilience and selectivity, but it does it for the whole spectrum simultaneously (makes tracking multiple doppler targets easy) and the same FFT result can later be used to perform correlation of the input with the transmitted signal, since that's a nice fast way that can find an echo even when its buried under noise.

Kleinstein:
If computational effort is not a big problem, the best solution is usually (for white noise it is the best) the least square fit.  The time it needs for the fit depends on the implementation - general methods can be relatively slow. However in the right form only the frequency is a nonlinear parameter. Amplitudes and DC offset are linear and the linear approximation is thus quite good, so that the convergence can be quite good, so that only few (e.g. 2 or 3)  iterative steps are needed. Each step takes a little more than twice the time of the mixing method. Because of the similarity to the mixing method, chances are that even a single approximation step could be already as accurate as the mixing method with the best block size.

So the effort for the fit is not that high, if an adapted code is used and a reasonable starting point for the frequency is available.

hamster_nz:
Possibly useful observation...

If the frequency range of the desired signal is very narrow, and the data has been filtered, and your sample rate is a multiple of four for the desired frequency you can convert the real data into I+Q data very simply.

If the wavelength is 20 samples (+/- a smidgen) then:


--- Code: ---   data_i[i] = (data_r[i-5]-data_r[i+5])/2;

--- End code ---

So, if 'data_r' has 200 samples of clean, filtered, valid data the following works:


--- Code: ---   double phase10, phase190,change;

   // Calculate the quadrature component of the real data in data_r
   data_i[10]  = (data_r[ 10-(WAVELENGTH/4)]-data_r[10+(WAVELENGTH/4)])/2;
   data_i[190] = (data_r[190-(WAVELENGTH/4)]-data_r[190+(WAVELENGTH/4)])/2;

   // work out phase as close to the start and end of the data as possible
   phase10 = atan2(data_r[10],data_i[10]);
   phase190 = atan2(data_r[190],data_i[190]);

   // work out the change in phase per sample over 180 samples
   change = (phase190-phase10)/180;

   // print results.
   printf("Angle at sample 49 is  %10.6f\n",phase10);
   printf("Angle at sample 149 is %10.6f\n",phase190);
   printf("Change in cycles after 100,000 samples %10.6f\n", change*100000/(2*M_PI));

--- End code ---

The key requirement is that your sample rate has to be a multiple of four of the nominal frequency of the signal of interest so you easily access data a quarter of a cycle away from any given sample - so for 10kHz you might want to use 80kS/s or 120kS/s, rather than 100kS/s.

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