Electronics > Projects, Designs, and Technical Stuff
Signal processing - getting exact frequency from short ADC sample
coppice:
--- Quote from: David Hess on December 14, 2019, 03:09:02 am ---
--- Quote from: coppice on December 14, 2019, 03:04:26 am ---You can get the exact frequency of any pure sine wave using 3 perfect samples - i.e. no amplitude noise, no timing noise (i.e. timing jitter), and masses of resolution. The snag comes when you realise how incredibly sensitive to noise the three sample approach really is.
--- End quote ---
Sampling noise is not bandwidth limited so it causes aliasing making the solution indeterminate. If you use all of the samples, then the noise is integrated out increasing accuracy.
--- End quote ---
I didn't say the three sample approach was the most practical. However, it is widely used in things like speech analysis. See the Teager Kaiser Energy Operator (TKEO).
David Hess:
--- Quote from: coppice on December 14, 2019, 03:16:20 am ---I didn't say the three sample approach was the most practical. However, it is widely used in things like speech analysis. See the Teager Kaiser Energy Operator (TKEO).
--- End quote ---
I just meant to point out the type of algorithm to use. In the analog domain it was common to phase lock a clean reference signal to the signal to be measured and then measure the clean reference signal at only a few points. The continuous phase comparison did the integration. But that is not feasible for burst measurements.
nfmax:
Another approach might be to use an FFT and Hilbert transform to construct the (complex) analytic signal. Since your pulse is fairly narrow-band, the argument of this is a good approximation to the phase of the original. After unwrapping it, fit a straight line to the phase (possibly with some weighting based on amplitude or SNR, and down weighting the end regions). The slope of the fitted line is the frequency estimate.
Choice of windows and weighting functions may be important. You can also try fitting a higher order polynomial, and using its linear term as your estimate.
I have used this technique to analyse optical interferograms. The SNR was high, but we needed very high 'frequency' (actually fringe spacing) resolution.
Kleinstein:
With just 200 samples I would go for the brute force least squares fit. This is rather close to the best possible suppression of noise. So the main weakness to worry about it the computational effort. Writing the "sine" function to fit not at A*sin(wt+phi) but as A1*sin(wt)+A2*cos(wt) the least square fit can be linearized quite well. So it does not need many iterations (maybe 2 or 3) if the starting point is good.
It kind of depends on the HW used. An a PC and for tests one could use the fitting function of a plotting program or math-lab. So one could try with real data sets what to expect.
Chances are a 100 MHz ARM based µC could to the math as fast as the data are coming in. For a similar task I reached that point with a 60 MHz Pentium CPU and a not very efficient program.
hamster_nz:
Made some bogus data, with an amplitude of +/- 75% at 10,000.0 Hz and 10,000.1 Hz. You can draw your own conclusions:
With 12-bit resolution:
--- Code: --- -99, 632, 633
-98, 1203, 1203
-97, 1656, 1656
-96, 1946, 1947
-95, 2047, 2046
-94, 1946, 1946
-93, 1656, 1655
-92, 1203, 1202
-91, 632, 632
-90, 0, 0
-89, -632, -633
-88, -1203, -1203
-87, -1656, -1656
-86, -1946, -1946
-85, -2047, -2046
-84, -1946, -1946
-83, -1656, -1655
-82, -1203, -1202
-81, -632, -632
-80, 0, 0
-79, 632, 633
-78, 1203, 1203
-77, 1656, 1656
-76, 1946, 1946
-75, 2047, 2046
-74, 1946, 1946
-73, 1656, 1655
-72, 1203, 1202
-71, 632, 632
-70, 0, 0
-69, -632, -632
-68, -1203, -1203
-67, -1656, -1656
-66, -1946, -1946
-65, -2047, -2046
-64, -1946, -1946
-63, -1656, -1655
-62, -1203, -1202
-61, -632, -632
-60, 0, 0
-59, 632, 632
-58, 1203, 1203
-57, 1656, 1656
-56, 1946, 1946
-55, 2047, 2046
-54, 1946, 1946
-53, 1656, 1655
-52, 1203, 1202
-51, 632, 632
-50, 0, 0
-49, -632, -632
-48, -1203, -1203
-47, -1656, -1656
-46, -1946, -1946
-45, -2047, -2046
-44, -1946, -1946
-43, -1656, -1655
-42, -1203, -1202
-41, -632, -632
-40, 0, 0
-39, 632, 632
-38, 1203, 1203
-37, 1656, 1656
-36, 1946, 1946
-35, 2047, 2046
-34, 1946, 1946
-33, 1656, 1655
-32, 1203, 1203
-31, 632, 632
-30, 0, 0
-29, -632, -632
-28, -1203, -1203
-27, -1656, -1656
-26, -1946, -1946
-25, -2047, -2046
-24, -1946, -1946
-23, -1656, -1655
-22, -1203, -1203
-21, -632, -632
-20, 0, 0
-19, 632, 632
-18, 1203, 1203
-17, 1656, 1656
-16, 1946, 1946
-15, 2047, 2046
-14, 1946, 1946
-13, 1656, 1656
-12, 1203, 1203
-11, 632, 632
-10, 0, 0
-9, -632, -632
-8, -1203, -1203
-7, -1656, -1656
-6, -1946, -1946
-5, -2047, -2046
-4, -1946, -1946
-3, -1656, -1656
-2, -1203, -1203
-1, -632, -632
0, 0, 0
1, 632, 632
2, 1203, 1203
3, 1656, 1656
4, 1946, 1946
5, 2047, 2046
6, 1946, 1946
7, 1656, 1656
8, 1203, 1203
9, 632, 632
10, 0, 0
11, -632, -632
12, -1203, -1203
13, -1656, -1656
14, -1946, -1946
15, -2047, -2046
16, -1946, -1946
17, -1656, -1656
18, -1203, -1203
19, -632, -632
20, 0, 0
21, 632, 632
22, 1203, 1203
23, 1656, 1655
24, 1946, 1946
25, 2047, 2046
26, 1946, 1946
27, 1656, 1656
28, 1203, 1203
29, 632, 632
30, 0, 0
31, -632, -632
32, -1203, -1203
33, -1656, -1655
34, -1946, -1946
35, -2047, -2046
36, -1946, -1946
37, -1656, -1656
38, -1203, -1203
39, -632, -632
40, 0, 0
41, 632, 632
42, 1203, 1202
43, 1656, 1655
44, 1946, 1946
45, 2047, 2046
46, 1946, 1946
47, 1656, 1656
48, 1203, 1203
49, 632, 632
50, 0, 0
51, -632, -632
52, -1203, -1202
53, -1656, -1655
54, -1946, -1946
55, -2047, -2046
56, -1946, -1946
57, -1656, -1656
58, -1203, -1203
59, -632, -632
60, 0, 0
61, 632, 632
62, 1203, 1202
63, 1656, 1655
64, 1946, 1946
65, 2047, 2046
66, 1946, 1946
67, 1656, 1656
68, 1203, 1203
69, 632, 632
70, 0, 0
71, -632, -632
72, -1203, -1202
73, -1656, -1655
74, -1946, -1946
75, -2047, -2046
76, -1946, -1946
77, -1656, -1656
78, -1203, -1203
79, -632, -633
80, 0, 0
81, 632, 632
82, 1203, 1202
83, 1656, 1655
84, 1946, 1946
85, 2047, 2046
86, 1946, 1946
87, 1656, 1656
88, 1203, 1203
89, 632, 633
90, 0, 0
91, -632, -632
92, -1203, -1202
93, -1656, -1655
94, -1946, -1946
95, -2047, -2046
96, -1946, -1947
97, -1656, -1656
98, -1203, -1203
99, -632, -633
100, 0, 0
--- End code ---
With 14 bits:
--- Code: --- -99, 3797, 3800
-98, 7222, 7225
-97, 9941, 9943
-96, 11686, 11687
-95, 12288, 12287
-94, 11686, 11685
-93, 9941, 9939
-92, 7222, 7219
-91, 3797, 3793
-90, 0, -3
-89, -3797, -3800
-88, -7222, -7225
-87, -9941, -9943
-86, -11686, -11687
-85, -12288, -12287
-84, -11686, -11685
-83, -9941, -9939
-82, -7222, -7220
-81, -3797, -3794
-80, 0, 3
-79, 3797, 3800
-78, 7222, 7225
-77, 9941, 9942
-76, 11686, 11687
-75, 12288, 12287
-74, 11686, 11685
-73, 9941, 9939
-72, 7222, 7220
-71, 3797, 3794
-70, 0, -2
-69, -3797, -3799
-68, -7222, -7224
-67, -9941, -9942
-66, -11686, -11687
-65, -12288, -12287
-64, -11686, -11685
-63, -9941, -9939
-62, -7222, -7220
-61, -3797, -3794
-60, 0, 2
-59, 3797, 3799
-58, 7222, 7224
-57, 9941, 9942
-56, 11686, 11687
-55, 12288, 12287
-54, 11686, 11685
-53, 9941, 9939
-52, 7222, 7221
-51, 3797, 3795
-50, 0, -1
-49, -3797, -3798
-48, -7222, -7224
-47, -9941, -9942
-46, -11686, -11687
-45, -12288, -12287
-44, -11686, -11686
-43, -9941, -9940
-42, -7222, -7221
-41, -3797, -3795
-40, 0, 1
-39, 3797, 3798
-38, 7222, 7223
-37, 9941, 9942
-36, 11686, 11687
-35, 12288, 12287
-34, 11686, 11686
-33, 9941, 9940
-32, 7222, 7221
-31, 3797, 3796
-30, 0, -1
-29, -3797, -3798
-28, -7222, -7223
-27, -9941, -9941
-26, -11686, -11686
-25, -12288, -12287
-24, -11686, -11686
-23, -9941, -9940
-22, -7222, -7222
-21, -3797, -3796
-20, 0, 0
-19, 3797, 3797
-18, 7222, 7223
-17, 9941, 9941
-16, 11686, 11686
-15, 12288, 12287
-14, 11686, 11686
-13, 9941, 9940
-12, 7222, 7222
-11, 3797, 3796
-10, 0, 0
-9, -3797, -3797
-8, -7222, -7222
-7, -9941, -9941
-6, -11686, -11686
-5, -12288, -12287
-4, -11686, -11686
-3, -9941, -9941
-2, -7222, -7222
-1, -3797, -3797
0, 0, 0
1, 3797, 3797
2, 7222, 7222
3, 9941, 9941
4, 11686, 11686
5, 12288, 12287
6, 11686, 11686
7, 9941, 9941
8, 7222, 7222
9, 3797, 3797
10, 0, 0
11, -3797, -3796
12, -7222, -7222
13, -9941, -9940
14, -11686, -11686
15, -12288, -12287
16, -11686, -11686
17, -9941, -9941
18, -7222, -7223
19, -3797, -3797
20, 0, 0
21, 3797, 3796
22, 7222, 7222
23, 9941, 9940
24, 11686, 11686
25, 12288, 12287
26, 11686, 11686
27, 9941, 9941
28, 7222, 7223
29, 3797, 3798
30, 0, 1
31, -3797, -3796
32, -7222, -7221
33, -9941, -9940
34, -11686, -11686
35, -12288, -12287
36, -11686, -11687
37, -9941, -9942
38, -7222, -7223
39, -3797, -3798
40, 0, -1
41, 3797, 3795
42, 7222, 7221
43, 9941, 9940
44, 11686, 11686
45, 12288, 12287
46, 11686, 11687
47, 9941, 9942
48, 7222, 7224
49, 3797, 3798
50, 0, 1
51, -3797, -3795
52, -7222, -7221
53, -9941, -9939
54, -11686, -11685
55, -12288, -12287
56, -11686, -11687
57, -9941, -9942
58, -7222, -7224
59, -3797, -3799
60, 0, -2
61, 3797, 3794
62, 7222, 7220
63, 9941, 9939
64, 11686, 11685
65, 12288, 12287
66, 11686, 11687
67, 9941, 9942
68, 7222, 7224
69, 3797, 3799
70, 0, 2
71, -3797, -3794
72, -7222, -7220
73, -9941, -9939
74, -11686, -11685
75, -12288, -12287
76, -11686, -11687
77, -9941, -9942
78, -7222, -7225
79, -3797, -3800
80, 0, -3
81, 3797, 3794
82, 7222, 7220
83, 9941, 9939
84, 11686, 11685
85, 12288, 12287
86, 11686, 11687
87, 9941, 9943
88, 7222, 7225
89, 3797, 3800
90, 0, 3
91, -3797, -3793
92, -7222, -7219
93, -9941, -9939
94, -11686, -11685
95, -12288, -12287
96, -11686, -11687
97, -9941, -9943
98, -7222, -7225
99, -3797, -3800
100, 0, -3
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version