PDA

View Full Version : audio frequency tone detection in software



mlmccauley
- 22nd May 2010, 04:15
I have an old (1983) Heathkit clock that synchronizes itself to the time code information broadcast by US radio station WWV (the 5, 10 & 15 MHz signals, not VLF like new consumer type clocks) that I am interested in improving the performance of.

A weak aspect of the original design is the use of 70's vintage NE567 PLL ICs to detect the 100Hz and 1000Hz tones in the WWV data stream. In poor signal to noise ratio conditions (like now, at the bottom of the sun spot cycle) the PLLs go fairly flaky, especially the 100Hz portion of the circuit.

This problem is compounded by the interference produced by almost every modern electronic gadget made, which makes picking up a quality shortwave AM signal difficult even under the best of conditions. When the clock was designed in '83, the world was a lot more RF quiet than it is today.

I strongly expect that timing pulse width (PULSIN) isn't going to afford the noise immunity I need to significantly improve the design.

Does anyone have any tips on how best to implement such a detection scheme using a PIC?

Thanks for the help!

Mike

Acetronics2
- 22nd May 2010, 10:28
Hi, Mike

IF a NE567 isn't sufficent to filter the signal ... I do not see what a simple PIC could do better ...

May be a DSPic ... if any amplifier was available in it ...

That said it's a problem of cleaning the signal before filtering it ... and I , personnaly, would add a little signal filtering card before the 567 Input ...

Alain

mlmccauley
- 22nd May 2010, 21:13
Thanks for the reply, Alain.

A simple single op amp bandpass filter is used in both the 100 and 1KHz segments prior to the NE567s. I haven't swept them using a variable oscillator and a scope, but I'm sure they're fairly broad. Better than nothing, though, as you say.

I have heard that the Goertzel algorithm

http://en.wikipedia.org/wiki/Goertzel_algorithm

can be used to do this job on a moderately fast (10+MHz clock) uP, but I have no experience with coding such a thing. And as you can see at that URL, the math is not trivial.

A DSP PIC would probably do a great job in this application, but I have no tools to program those chips, and wouldn't even know where to start with trying to do so in assembler. Whatever I do will have to be done in PBP or C.

At any rate, thanks for your reply,

Mike

Acetronics2
- 23rd May 2010, 13:48
Hi, Mike

This filter requires floating point calculations ... trig functions are not exactly PbP's best feature nor ...

so, I do not think it could be a good Idea ... ;)

Alain

ScaleRobotics
- 23rd May 2010, 14:53
I agree with Alain, sounds pretty difficult. But decoding can be done. Here is one dtmf decoding example in assembly: http://dtmf.voipintouch.net/content/dtmf.htm . It uses a 16F877, and a modified version of the Goertzel algorithm. Of course you would have to modify it to detect the time code tone for your application.

Attached is microchips dtmf decoding app note AN257 (assembly) for PIC18F chips

mlmccauley
- 23rd May 2010, 20:22
Thanks for the files.

The problem that I see right off is that the PDF says that the worse case s/n ratio for that design is 23dB. That's quite reasonable for working with DTMF signals off a phone line, but not a source picked up using an AM shortwave radio.

You guys have just about convinced me that any scheme using a plain digital PIC isn't gonna fly.

There are lots of DTMF decoder chips, but I expect that they require a s/n ratio similar to that normally found on a phone line i.e. pretty good. Plus, hacking them to do 100 and 1000Hz might be a big problem seeing as how they were designed from the ground up to do DTMF.

Other than the NE567s already in use, does anyone have any other ideas? Suggestions on development tools for DSP PICs that don't have a huge learning curve?

Thanks again,

Mike

Normnet
- 23rd May 2010, 20:33
Suggestions on development tools for DSP PICs that don't have a huge learning curve?

Thanks again,

Mike
Would a "pulse divide by" logic chip slow the pulse timing down enough to be of use to an 8 bit PIC?

Norm

mlmccauley
- 24th May 2010, 00:13
The problem is not the speed/frequency of the signal. 100Hz and 1000Hz isn't all that fast, especially to a 30+MHz clock PIC. The signal is analog, not digital, and it's not at all clean.

If it were a nice clean square wave, PULSIN would do the job great. But it's a distorted sine wave combined with a great deal of white noise.

Thanks for the reply, at any rate,

Mike

ScaleRobotics
- 24th May 2010, 00:32
Thought you might be interested in this thread as well. Here a guy measures the note for a guitar using a pic. But he uses a "sustainer" which filters out harmonics, etc, so his sound wave is very clean. Just thought you would be interested.

http://www.picbasic.co.uk/forum/showthread.php?t=12813

Walter

mlmccauley
- 24th May 2010, 06:25
Thanks, Walter. That's interesting stuff, but as you say that guy was working with a very clean sine wave at a high s/n ratio. Relatively speaking, I'm trying to process some real junk.

Although I'm still interested in anyone's comments regarding doing this with a PIC, either conventional or DSP, I've started looking at general purpose switched capacitor filter ICs to use as replacements for the single op amp RC tuned bandpass filters. The thinking there is that the NE567s would probably work way better if less trash was being shoved into them.

Thanks again,

Mike