How does a sound card determine if headphones are plugged in?

9,086

Solution 1

The audio ports detect that something has been plugged in by monitoring for a change in resistance across the port. When nothing is plugged in the resistance is infinite, but when a coil is plugged in (speaker or mic) there is now a measurable resistance, and the computer pops up and asks you what it is you plugged in.


EDIT: I've been digging, and instead of trying to figure out what the audio adapter manufacturers are doing, I decided to look at the jack manufacturers to figure out if there are internal mechanical switches, as well as perhaps suggested uses.

Turning to Digi-key, I found that there are a few different mechanical ways the jacks provide for detection. The most common DOES seem to be a separate, internal switch circuit based on the position of the inner-most blade in the barrel; and they are only a couple cents more per unit than a non-switched jack. Here's a dual barrel surface mount by Tyco that I think looks similar to what can be on a motherboard.

Interestingly on many (most?) the detection switch is actually reversed. So the switch is closed until the plug is inserted, here's one by CUI.

This one by Schurter is crazy; it's a "stereo" jack that all three rings (including the ground) are switched. So it could tell you how deep the plug is pushed I guess ;) Only $6.50 each!

Using these switches DOES seem to be the more likely way they're doing it, and what I've been told in the past is probably incorrect, or at least not correct across-board.

I'm going to disect one Monday -- I gotta see if that switch is at least in the jacks Intel's been using. :)


If you are aiming to have the same sound on both headphones and speakers, then you may want to look into getting an audio jack y-adapter (splitter):

alt text

If you want different sounds on each a headphone and a speaker set then you're probably dependent on the abilities of the software mixer provided by your audio adapter's manufacturer, and/or the software you're using.

Depending on your situation, you may want to consider getting a secondary audio card as well, that way you can point different applications at each audio device.

Solution 2

As pipTheGeek stated, another option to the electrical resistance measurement is a mechanical switch.

Switch pushed down - something's plugged in.

You can test this by plugging a Y-adapter or size adapter into the jack. If the jack acts like there's something plugged into the port, you have a mechanical switch.

The adapter won't make any connections between the lines and ground so it shouldn't count as an output device to the resistance measurement.

Share:
9,086
Rook
Author by

Rook

Updated on September 17, 2022

Comments

  • Rook
    Rook almost 2 years

    This is actually two questions in one.

    1. First, how do soundcards (the cheap ones) "detect" whether the headphones are plugged in? By measuring resistance or by some other technique?

    2. Second, can I somehow have different sound outputs sent to the speakers and the headphones? I'm guessing no, at least no on the cheap ones. What does one need to accomplish that?

    (I've no idea about anything related to sound save of listening to mp3's, so this may be overly simple question to some.)

  • Kalaivani
    Kalaivani over 14 years
    I think the sockets actually have switches in that are operated when something is plugged into the socket. Its a standard part of most 3.5mm jack sockets.
  • Ernie Dunbar
    Ernie Dunbar over 14 years
    cough Actually, it's more to the effect that the plug-in acts as a switch. When something is plugged into it, it completes the circuit (just like a light switch) and a) your headphones work, and b) the sound card knows it's plugged in by the fact that the circuit is complete. You don't have to muck around with measuring the resistance of the connection - that's complicated. Mostly, the fact that the computer knows at all is in software and drivers.
  • Rook
    Rook over 14 years
    +A ... You've done your homework ... and there was little ol' me hoping for a (if) two sentence answer. Thanks mate ! Your nick serves you well :)
  • hyperslug
    hyperslug over 14 years
    @erniedwork, elaborate on part b) "the sound card knows". What kind of circuit mechanism are you suggesting does this detection?
  • quack quixote
    quack quixote over 14 years
    @hyperslug - i'm not sure, but i think he's talking about the fact that when plugged in, the signal path (the wires that make up channels L and R in a stereo signal) is a completed circuit -- soundcard -> jack -> headphones -> jack(GND) -> soundcard(GND)
  • hyperslug
    hyperslug over 14 years
    @quack, I'm asking how a controller would detect a completed circuit. Vcc and GND remain at constant levels regardless of load. Since @erniedwork mentioned a light switch, does a light switch have a detector that "knows" when a light bulb is screwed in or not?
  • Synetech
    Synetech almost 13 years
    Re: mechanical methods. Yup, this is how some jacks can mute the internal speakers when headphones are plugged in. I added such a jack to my television and had to examine how the thing worked so that I could wire it correctly. Now I can plug in headphones and listen to it while the rest of the room is silent.
  • Rob Cameron
    Rob Cameron about 11 years
    Hoping someone is still following this: how do you read a "switch" with only one pin? Is the voltage floating until the headphone jack plugs in and then it goes to 0v? Do you need some kind of pull-up resistor in there somewhere so you have a reference?