Amazingly: there is no math at all in the final algorithm. I am having real fun doing this stuff by the way.
In short words the math formula of DFT is a simple comparision of two bits in N samples, when the sample is passed through a 1bit A/D converter (Zero cross detector for example).
What the algorithm does is:
Code:
if RealSample = StoredExpected then
Energy = Energy + 1
else
Energy = Energy - 1
endif
The stored expected is a representation of 1`s and 0´s of the signal, considering the samplig frecuency.
i.e. Stored Expected
11111000001111100000111110000011111000001111100000 111110000011111
This must be done with each sample and one can choose like 114 samples (any number, the bigger the better).
The final Energy its a great representation of the existence of the Detected Frequency in the signal. a simple excel worksheet amazed me, this is really a great filter!!
You could even try to trick the algorithm by adding two or three more frequencies at the same time and it will GET the result!
Result so far:
I am getting the greatest energy around 300 with a F applied of 350. Possible problem with optimization of code or large interrupt routine.
I am attaching the excel sheet that amazed me in case someone is interested, you can move frequency and phase of two frequencies and watch the resultant Wave, and also watch the resultant energy, wich would show that the frequency is detected.
Will post code so far tomorrow
Bookmarks