# Audio Jack Short Circuit Detect

In our current design we are using a 3.5 mm headset jack with a normally open switch. The jack is waterproof, now in the scenario when the jack is filled with water, assuming salty water the switch will close (contact established by water). In that case, we will need to detect it as fault and not enable the headset left and right output.

How do I detect that kind of scenario?

• it's not very waterproof if it's filled with water :) Make sure you are not overthinking this design. Do you really need to ensure the headset jack is not powered when underwater (faulted) as you describe it? What harm will it cause? I would think that the water, even salt water, is less of a load then the actual speakers are with copper wire. – Brian Onn Feb 19 '14 at 18:18
• I meant the Jack won't allow the water to go onto the PCB. – Ash Feb 20 '14 at 5:38

Let's see if we can tell the difference between an open and a closed switch in salty water.

A hard closed switch in free air will have just a few milliohms of contact resistance, which could range from 1 m$\Omega$ to 25m$\Omega$, depending on the switch quality. So what will be the resistance between the contacts of an open-switch in salty water? For the purpose of this exercise, let's assume sea-water, but even sea-water has differing levels of salinity, so just be aware of that for now.

Let's assume that the switch contact area is $1$ mm2 and the separation between the open contacts is just $1$ mm. According to Wikipedia, the resistivity $\rho$ of sea water is $\rho = 2 \times 10^{-1} \Omega\cdot m$. So an area $1$ mm2 across a distance of $1$ mm has a resistance of:

$$R = {\rho {l\over A}}$$

where $l$ is the length (or distance) across the resistive region and $A$ is the cross-sectional area of the region. So, perhaps your contact, when open in salt water, has a resistance like this:

$$R = {\rho {l\over A}} = {(2\times 10^{-1})\Omega\cdot m {1\times 10^{-3}m\over {1\times 10^{-3}m^2}}} = 2\times 10^{-1} \Omega \text { or 200}m\Omega$$

So it would seem that a small open switch in sea water, depending on the assumptions I made about contact area and separation, is very close to a closed switch and might be indistinguishable from a closed switch. In this case, given my assumptions, the open switch has a resistance of $200 m\Omega$ whereas the closed switch might have a resistance of $10 m\Omega \text{ to } 20 m\Omega$. You can use this fact with a current source to detect the voltage difference between a closed switch and an open switch in salt water with leakage resistance like this. You basically create a specific milliohmmeter that can detect above and below a threshold, perhaps anything above $50 m\Omega$ is considered an open switch and when below $50 m\Omega$ is a closed switch.

Next, what about capacitance? The capacitance equation for two plates separated by a gap filled with a dielectric is:

$$C = {k \epsilon_0 A \over d }$$

where $k$ is the relative permittivity of the dialectric (sea water) between the plates, $\epsilon_0 = 8.854 \times 10^{-12} F/m, A = 1\times 10^{-3}m^2 \text{ and } d = 1\times 10^{-3}m$

Using the Klein-Swift model for relative permittivity of sea water, and some matlab code from Professor Joel T. Johnson at Ohio State University, and some help from GNU Octave, we can come up with a value of approx $k = 79$, at freq $f = 1$ kHz, $20\,^{\circ}{\rm C}$ and $4.5$ g/kg salinity

octave:3> sea_eps(1000,20, 4.5)
ans =  7.89719e+01 - 1.28469e+07i


$$C = {k \epsilon_0 A \over d } = {(79)\cdot (8.854 \times 10^{-12}) {F\over m}\cdot (1\times 10^{-3}m^2)}\cdot {1\over {1\times 10^{-3}m}} \approx 700 pF$$

So the theoretical capacitance is $700$ pF, but the switch is not a very good capacitor, since it has such a low parallel resistance, we calculated above at about 200m$\Omega$

So, detecting the open or closed switch using the capacitance of the contacts is not going to be easy, because the extremely low parallel resistance of 200m$\Omega$ overwhelms any useful capacitance there might be.

So your switch looks like this underwater: What can we do with a parallel RC? According to Wikipedia:

The parallel RC circuit is generally of less interest than the series circuit. This is largely because the output voltage $V_{out}$ is equal to the input voltage $V_{in}$ — as a result, this circuit does not act as a filter on the input signal unless fed by a current source

That page indicates that the transfer function from an input current to an output voltage is:

$$\frac{V_{out}}{I_{in}} = \frac{R}{1+sRC}$$

or

$$V_{out} = \frac{R}{1+sRC} \cdot {I_{in}}$$

So this tells me that the voltage out $V_{out}$ is inversely proportional to the capacitance, and so if you fed your switch with an AC current source above audible ranges, you could get an AC voltage out that would be filtered as the capacitance of the switch changes. In this case, the capacitance of the switch starts high, perhaps above $700$pF even, and decreases to 0, which basically means the voltage starts out low and increases to max voltage developed across the R according to Ohms law, $V_{out} = I_{in} \times R$

This is can work but provides no additional benefit above the milliohmeter style of detection I suggested up first above. So I don't suggest using the switch capacitance as a detection method like this, but the exercise above was academic, nonetheless.

So perhaps the best way is just to pass a small DC current through the switch and measure the voltage drop, as stated first. If you rely on the changing DC resistance of the switch, and just allow that anytime the DC switch resistance is less than perhaps $50 m\Omega$ then consider it on. If you KNOW that your specific brand of audio jack has switch contact resistance of less than $2 m \Omega$ then you can make your resistance threshold even tighter.

Finally, the inherent problem with this method is that the resistances involved are so low that you need a high current in order to have a detectable voltage; If your device is battery powered, then high currents are not feasible, and with battery-saving low currents you'll end up with just $10$'s of microvolts. This is fine, however you will need to add an op-amp gain stage to make it measurable. One option here is to pulse a higher current and synchronize your micro with the pulse to detect the voltage drop and determine if the switch is < $50 m\Omega$ or more than that threshold. Unfortunately, it's not going to help, for if you pulse a $10$ mA pulse every second through the switch you still only get $500\mu$V from it, and you still need to gain it up and you have a $1$ second max delay to detecting an audio jack insertion event.Plus the energy consumed per pulse at $10$mA is far greater than the energy consumed by a steady $500\mu$A current across $200{\rm m} \Omega$ It's probably better to just have a constant $500\mu{\rm A}$ current and gain up the voltage drop detect when it is above or below a voltage threshold.

references used
1. http://hyperphysics.phy-astr.gsu.edu/hbase/electric/pplate.html
2. http://en.wikipedia.org/wiki/Resistivity
3. http://en.wikipedia.org/wiki/RC_circuit#Parallel_circuit
4. http://rime.aos.wisc.edu/MW/models/kleinswift.shtml
5. http://www2.ece.ohio-state.edu/~johnson/5010/progs/sea_eps.m