Thursday, 30 July 2015

pic - Reading frequencies without filters


Is it possible to read a set of frequencies with a PIC in such a way that for each frequency a different function is called?


The idea was to send multiple frequencies at different times (no overlapping or super positioning) over one carrier and reading them on the other end resulting in different outputs. I was hoping to avoid having to implement many band-pass filters to channel each frequency to a different pin allowing the PIC to distinguish between the inputs.


In the end there should be ~1000 different frequencies in the audible range, well distinguishable for a micro controller.


Thanks



Answer



As Brian mentioned, there is something called a FFT (Fast Fourier Transform). It takes a time snippet of signal and returns the amplitude of frequency components in buckets of predetermined frequency and bandwidth. The FFT algorithm is a computationally optimized general Fourier transform that operates on a power of two frequency buckets linearly spread from 0 to the high end of the frequency range it is configured for.


A FFT is computationally expensive, and can only be done on fixed chunks of time domain signal. If you want to get a general frequency content, then it can be appropriate. If you just want to detect the presence of a small number of specific and known frequencies, then it's probably not appropriate. A example of the latter would be DTMF (touch tone) decoding since there are only 8 specific frequencies and you generally want to do the tone decoding continuously, and the frequencies are fairly closely spaced.


To detect the amplitude of a specific frequency in a composite signal, multiply that signal by the sine and cosine of the desired frequency. Low pass filter each of these two product signals separately. The bandwidth of this filter is half the bandwidth the frequency of interest will be detected within. Another way of putting that is that this is the bandwidth of the resulting amplitude output. Now square the two low pass filtered signals and add them together. The result is the square of the amplitude of the signal of interest. You can see where I've simulated this with three adjacent DTMF tones:




The input signal was three adjacent DTMF frequencies for 50ms each with 50ms gaps between. The detection frequency was set up to match the center burst. The blue line is the resulting amplitude squared signal. The low pass filter time constants were adjusted to reject the adjacent frequencies, but still respond well enough within 50 ms (the minimum valid DTMF tone length).


If you need true amplitude, then you'd have to take the square root of the result shown here. For simply detecting the presence of a particular frequency, the magnitude squared is good enough. For other applications the true magnitude may be necessary.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...