Hi Darrel.
Bad luck for me, the code is not that hard by the way.
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 (which you took the bother to take) 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!
The reason to tell you all this is because my project might need optimization, i am really bad writing that way. BUT YOU ARE A WIZARD, so i might be posting code to check
.
I Think a good include can come out of this.
By the way, is the EEPROM memory of 16f628 fast enough to be read? i am storing my Stored Expected in that memory but my result is not exact at the moment. I am getting the greatest energy around 300 with a F applied of 350.
I am attaching the excel form 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.
Bookmarks