3
\$\begingroup\$

I have an STX-3790-5N 3.5mm stereo switching headphone jack in my circuit. http://www.kycon.com/Pub_Eng_Draw/STX-3790-5N.pdf

The intention is for the audio signal to flow from the ATmega328 pin 9 to the LM386 opamp and out to the speaker while the switch is closed. When a headphone cable is plugged into the jack, the switch should open, cutting off the audio signal from the LM386, while the audio signal continues out to the headphones.

This works fine in the open position. The audio plays through the speaker with no issues. Now...when I plug in a set of headphones to the STX3790 audio jack, the chip seems to reset or brown out or short out, the audio stops playing through the speaker and in the headphones I hear either a loud buzzing, nothing, or a very high pitched tone. When I remove the cable from the jack, the circuit remains in this stalled out state until I cycle the power. If I turn the power off, insert the headphone cable, then switch the power on, the result is the same.

Very strangely, if I plug in a plain stereo 3.5mm male-male cable that is not connected to headphones or anything else, the issue described above does not happen. The audio is still audible from the speaker, though just barely, very faint and quiet.

I've attached a snippet of my schematic here. The "audioout" signal here is coming directly from digital pin 9 on the ATmega328. Also the audio source is mono, I'm only using a stereo jack because this style of part seems more common and easier to source.

Thank you in advance!!

UPDATE

I can confirm that without the cable plugged in, pins 1-4 all have continuity with each other, which is what I want (given that this is mono audio), and all read an appropriate voltage. None have continuity with pin 5, which is ground/sleeve. When I plug in a phono cable, pins 1 and 4 still have continuity, which is good. Pins 2 and 3 have no continuity with any other pins, which is also good. This should cut off the signal to the opamp & speaker. HOWEVER, in this state, pins 1 and 4 now have continuity with pin 5 (gnd), which is not expected.

There are three of the same model headphone jacks on this board, the other two connect directly to 328 pins 2 and 10 respectively. I can confirm that one of them has the same shorting problem and the other does not. In the one that does not have this problem, the software pinmode is set to OUTPUT, whereas the other two are set to INPUT.

UPDATE 2

I can also confirm that if I switch the pinmode of the atmega328 pin connected to the other problematic headphone jack to INPUT instead of OUTPUT, it no longer shorts the board. But this breaks my functionality, so it's not a solution, just a clue.

ALSO if I leave the pinmode set to OUTPUT on that same pin WHILE the board is connected to my AVR programmer (which is connected to my desktop PC via USB) that secondary problem headphone jack DOES NOT cause the board to short when a headphone cable is plugged into it. Another clue. This has me thinking about grounding issues, but I'm not sure. Normally, the board is powered by 4 AA batteries, so not grounded on the Earth.

Audio circuit schematic

\$\endgroup\$
15
  • 1
    \$\begingroup\$ physically confirm the actual pinout of the headphone jack \$\endgroup\$ – jsotola Jun 14 at 22:37
  • \$\begingroup\$ @jsotola do you mean by testing with a multimeter to verify? \$\endgroup\$ – cody blanchard Jun 14 at 23:00
  • \$\begingroup\$ yes ........... \$\endgroup\$ – jsotola Jun 14 at 23:24
  • \$\begingroup\$ Headphones need amplifiers too... You should have your jack after the amp not before. \$\endgroup\$ – Majenko Jun 15 at 7:43
  • \$\begingroup\$ Sounds like a schematic error or schematic<->PCB missmatch. \$\endgroup\$ – winny Jun 15 at 9:56
1
\$\begingroup\$

To answer the question, stereo headphones, when connecting both left and right in parallel as a load for GPIO output pin, is too much load and this causes the MCU to draw too much current and supply voltage may drop too much so the MCU resets or browns out.

The IO pins are rated for about 10mA when used at 3.3V. This is about a load of 330 ohms or higher. A single headphone element might be down to 16 to 32 ohms. This will easily exceed the absolute maximum ratings and may cause permanent damage to the MCU.

And speakers or headphones will also not tolerate DC voltages. Headphones are also not rated to be fed with 3.3V signals.

The obvious fix is to have the phones connector after the amplifier, switching between phones and speaker. Or at least the MCU output should be AC coupled and limited with resistors higher than 330 ohms. The level must be brought down to about max level of 0.4V for the amplifier input anyway, to prevent damage to the amplifier. It should really be much below 0.3Vpp to avoid clipping at supply voltage of 6V and gain of 20.

Protection from plugging in a mono plug to a stereo jack could be done with for example 10 ohm resistors.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks for you time on this, @Justme !! \$\endgroup\$ – cody blanchard Jun 18 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.