Electronic – Signal to the audio jack of a smart phone

audiodesignsignalsignal processing

I have a 3.3 V square wave that consists of groups of 5 pulses at either 12.5 khz and 15.625 khz. Each group of 5 pulses represents either a 1 or a 0. I would like this signal to be passed to a smartphone through the microphone input.

From what I have read (please correct me if I am wrong) the voltage will need to come down to a few mV, the signal will need to be AC coupled. Will the phone be able to consistently differentiate between the frequencies or will some sort of frequency change be required?

What circuitry would be recommended for accomplishing this task?

Best Answer

A simple voltage divider will bring the voltage down, though exactly what resistor values to use to be optimal for your phone will depend -- the input levels of phones are far from standardized. I would use a potentiometer and turn it until I was in range.

To detect the input pulses, you could use FFT-based techniques as discussed in other comments and answers. Here is a detailed introduction about how to do that with C code.

However, I urge caution with that approach, since you are detecting high frequencies, you will need a high sample rate, which will result in high computation overhead. This problem can be solved with Goertzel's algorithm in place of the FFT, but you still have an issue that with only 5 five pulses you need a good time resolution. This, too, can be solved with frequent overlapping of your windows, but in the end I think you should use a different technique:

  1. counting the number of times the signal crosses zero. With a little pre-processing (a band-pass filter tuned to the range of your expected frequencies) I would expect it to be easier to get robust results with that, simpler, technique.

  2. Another approach, mimicking how this would be done in the analog domain, is simply to design two band-pass filters and monitor the output of those. This might require a bit of post processing, but I think this would produce excellent results.

It's hard to say for sure, but I would probably lean towards technique #2. It depends on a few things I'm not clear on from your question, eg are the tones likely to appear at the same time (if yes, use #2), are you always going to hear one tone or the other, or sometimes silence, etc. If the spec was likely to change and I was going to have to differentiate between tones that were close together in frequency, I would lean towards #1.

If you need help designing filters, this might be a good place to start.