On Fri, May 22, 2009 at 1:14 PM, Peter Restall wrote: > > > I've now decided to bandpass the 60KHz signal and then sample at 26.7KHz > and run it through Goertzel's algorithm - seems to work alright in the > Octave simulations, and gives oodles of spare cycles for updating my LCD, > spitting out the time over RS232, monitoring for push-buttons, etc. The > circuit is basically a 3-pole LC bandpass, two quad op-amps to provide > incremental gain (one of which is wired as a VGA), and all that feeds into > the dsPIC. Still need to write the firmware though. Or perhaps I should > just > look at the appnote as it looks far more sensitive and I could probably > remove yet more external components... > > Regards, > > Pete Restall > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > Pete, You can't detect a 60kHz signal with a 26.7kHz sample rate. I just ran an Octave simulation of the Goertzel algorithm and I was able to get good results with something like this: ### GNU Octave code # Goertzel algorithm to detect 60kHz signal clc; clear; n=1; s_prev = 0; s_prev2 = 0; rate = 120000 # sample rate f = 60000 # injected signal frequency ft = 60000 # signal to look for samples = 1000 # number of samples to test sig_amp = .01 # arbitrary signal amplitude fnorm = ft/rate # normalized frequency (% of sample rate) # Calculate Goertzel coefficient coeff = 2*cos(2*pi*fnorm); # Create signal to examine t = linspace(0,samples/rate,samples); x = sig_amp*sin(2*pi*f.*t); while (n < samples) s = x(n) + coeff*s_prev - s_prev2; s_prev2 = s_prev; s_prev = s; n++; endwhile power = s_prev2^2 + s_prev^2 - coeff *s_prev2*s_prev -- Martin K. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist