Author Topic: Detecting audio from a headphone jack  (Read 1232 times)

0 Members and 1 Guest are viewing this topic.

Offline mezzopianoTopic starter

  • Newbie
  • Posts: 1
  • Country: 00
Detecting audio from a headphone jack
« on: July 03, 2018, 06:25:00 pm »
Hi there, friendly EEV gurus,

thanks for putting together all the information here! I've learnt a lot from lurking and reading your posts. Now it's time for me to make one myself -- I'd like to ask for your feedback on a circuit I've been playing with.

What I'm trying to do is detect the presence of an audio signal on a line-level headphone output (around +/- 1.5V between peaks). I'd like detection to be as precise as possible, in that it tracks both positive and negative peaks in the input signal. I thought I'd use a window comparator to detect deviations in either direction, and a simple timer circuit to 'fill in the gaps' for a few milliseconds while the signal passes through the neutral zone, so that the circuit outputs a continuous binary signal. To make things a bit harder, I only have a single-rail power supply, and ideally everything should work at both 3.3 and 5V.

To solve this, I thought I'd add a DC offset to the input, and define the detection window around that bias. Because the MAX931 comparator (https://datasheets.maximintegrated.com/en/ds/MAX931-MAX934.pdf) outputs a reference voltage, I thought I'd use that as the offset (It's a Zener-based voltage reference, which is probably not built for this, see below). Here's what I've been working with:



This works ok with some sources, but it's quite brittle and there's probably loads of room for improvement:
  • Some audio sources seem to add an offset voltage of their own, pushing the signal out of the detection window. How can I improve the high-pass input filter? (I've tried different input capacitors, maybe the range was too small?)

    (yellow is the input signal, red the offset signal [with the cursor at neutral voltage, and the trigger level where the reference voltage ought to be]. I thought I might be measuring incorrectly, but the offset remains even if I connect directly to the input signal, and disconnect all other probes)
  • There's some weird amplification going on, even for sources whose signal varies around the ground: The signal is way above the offset voltage, and even the neutral voltage is above what should be coming out of the reference:

    (as above, yellow is the input, red the offset signal, blue and green are the comparator outputs; the cursor is the neutral level of the signal, and the trigger level the intended offset at 1.18V)
  • After the sound ends, the offset input takes a bit to recover to the neutral point. Is that charge building up somewhere? How can I find and get rid of it?

    (capture as above, red/violet is the signal behind the offset)
  • As I mentioned above, I've been using the comparator's reference voltage as offset source, but from what I gather that's not a particularly good idea, as it's built to provide a few mV at most. I've been weary of setting up the comparators using voltage dividers, because these would shift with the power supply voltage. Is there a way around that? Can I amplify the reference somehow?

Here's some more things I've tried/thought about
  • Initially I thought I could (full-wave) rectify the input signal, and then apply a single positive threshold. That didn't work out because the rectifier I built only output half waves, and the signal was massively attenuated. Those might be due to my poor oscilloscope technique and the use of silicone diodes (I don't have Schottkys) -- but if you think this is a more promising way to go in general, I'll gladly pick it up again!
  • I've been toying with the idea of inserting an opamp in the input stage, because amplification is a natural next step, and I've read that an opamp could also provide an offset. However, I'm a bit overwhelmed by the number of different possibilities. I think my use case is case 1 in http://www.ti.com/lit/an/sloa030a/sloa030a.pdf (page 12, or 8 if you trust the numbering), is that right?
  • Of course, things would be much easier if I had an actual window comparator. That's going to have to wait for the next parts order!

Ok, I'd love to hear your thoughts -- even ideas or hints are very welcome, I'd be glad to investigate further. Thanks for taking the time to help a newb!


-mp
« Last Edit: July 03, 2018, 06:51:58 pm by mezzopiano »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf