Idea: active headphone protecting circuit
Aug 23, 2007 at 10:41 PM Thread Starter Post #1 of 46

balou

500+ Head-Fier
Joined
Apr 7, 2007
Posts
563
Likes
10
After hearing horror stories about fried headphones (fried expensive headphones), and not wanting to include DC blocking caps on my sources/amps, I thought about possible remedies... and one would be an active headphone protecting circuit, which disconnects the headphone if it measures high enough DC voltage across it. There are already soft-start and delay circuits, but those only protect from start-up thumps and not from amps going suddenly berserk (which was that amp that could produce massive dc voltage if the battery got low?)

So... let's start with some technical details I'm thinking of:
On/off switching would be of course done with relays - they seem to disturb the audio quality the least (well, it's just a switch closed by the help of a magnet).
I envisioned two different routes, analog and digital.
Analog: A comparator (either a dedicated one or an opamp misused as comparator) is hooked up to the signal line. Add a resistor between signal and comparator input to increase the impedance and thus decrease the load and effect on the audio line. Of course, a low pass filter has to be added, to prevent that the circuit triggers on audio.
Then you just need, let's say a 20mV voltage source on the other comparator input. The comparator directly drives a relay (or via a transistor, depending on the comparator/opamp output capability and the relay current requirement). Thus, if DC voltage is above 20mV, the relay gets closed and the headphones are protected from DC.
One problem could be the 20mV voltage source. Anybody got an idea how to create such a low voltage source? zener reference voltage followed by an adjustable resistive voltage divider?

Digital:
instead of a comparator, you could just use a microcontroller with an integrated ADC (Atmel has some cheap [1-2$] in the ATtiny range). this would save quite some parts, and you could easily implement stuff like a 5s shutdown period after an high DC incident (would also be possible on the analog variant with a NE555 timer, but would be more complex), and for example a frantically blinking led. you could even add a simple bar graph to display the current dc offset

So... I'd be glad to hear any comments/questions/etc about this idea from you. Have I missed something serious? What could be a source for a 20mV reference voltage? Would you use such a circuit?
wink.gif
 
Aug 23, 2007 at 10:59 PM Post #3 of 46
hmm 20mV is a small value and im pretty sure it will be triggered by audio even with filtering because of that. I was thinking to put a ac coupled buffer at the ouput and a dc coupled buffer as well and compare the outputs of these buffers. So no need for references. ofc we'll need a low offset and very fast comparators.
 
Aug 23, 2007 at 11:07 PM Post #4 of 46
oookay, it was implemented before
rolleyes.gif

I knew of the e12, but I thought it was start up protection only. But it'll be interesting anyway, looking how AMB implemented the circuit.
But a digital protection circuit has most likely not been implemented yet. It surely has endless useless possibilities that cannot be done with an analog circuit like the e12
tongue.gif
 
Aug 23, 2007 at 11:14 PM Post #5 of 46
Yeah, this sort of thing has been the norm in speaker amps for a long time.

The protection circuit in my beater Akai power amp is so sensitive that it'll throw the relays if the audio is clipping.
 
Aug 24, 2007 at 1:02 AM Post #6 of 46
Quote:

So no need for references.


that'll be also the advantages of using a digital circuit.

Another advantage: adaptive offset detection. If a headamp has a DC offset of 0.5mV, and it suddenly goes up to 10mV, then there must be something wrong inside the amp. A digital protection circuit could detect this, and either blink out a warning or shutting off the connection

Quote:

hmm 20mV is a small value and im pretty sure it will be triggered by audio even with filtering because of that.


Quote:

The protection circuit in my beater Akai power amp is so sensitive that it'll throw the relays if the audio is clipping.


this can be conquered by measuring the DC offset for some time. a clipped 20hz tone will have a flat output voltage (=dc) for quite some time. a squarewave 20hz for 1/20s, clipped sine for a bit less (depending on amount of clipping).
 
Aug 24, 2007 at 1:13 AM Post #7 of 46
Good idea, and should be fairly easy, small and cheap to implement. A $2 ATtiny, $3 TQ2 relay, maybe $2 for an input buffer, a $0.20 MOSFET and some very cheap passives and you've got a good protection circuit for under $20.

Doing 'absolute' continuous DC offset observation would be really trivial to implement, a few minutes to figure out the right register values to enable and a few more minutes to figure out a good threshold and you'd be done. Doing digital filtering or adding fancy features would take longer, but not be hard either. This should be a fairly simple project.
 
Aug 24, 2007 at 1:31 AM Post #9 of 46
Quote:

Doing digital filtering


do you mean stuff like FFT or more like 'look at some consecutive values'? first would be nearly impossible, second easier.

I also thought about voltage-dependent modes - say if DC is 0.01-0.5v, sample a few times. If the value is above, shut down immediately.
Turn-on delay could be done with several methods:
-if on same psu as amp: do not turn on until 3 seconds after poweron
-via dedicated power-on indication line. guess it could be fairly easily modded into most amp designs
-failback: normal circuit breaking after dc is high enough

turn off delay:
-internal brown out detector at 4.7. if supply drops below that (which it will fast because no cap is after the 5v regulator), chip resets and turns all ports off
-detector line
-failback (both as above)

Btw, PIC microcontrollers suck - low RAM, no ADC, no free C compiler

edit: what does 'nt' mean?
confused.gif


edit2: I forgot:
ADC in attiny13 is 10bit. absolute precision is spec'd at 8bit (no linearity/gain/nonlinearity/noise/other errors). internal reference voltage is 1.1V, 1.1/2^8 gives 4.3mV steps. A sampling frequency of 1khz should be possible. May be lowered to 50hz, because 1khz might be just to much (also because of 'dc' components of clipped, low-frequency or both audio signals)
 
Aug 24, 2007 at 1:56 AM Post #10 of 46
nt = no text, often used in forums when comments are made simply through the subject line ("nt" is included in the subject line). It saves users from having to click on the message to read something that's not there.

EDIT: Just as an aside, you seem to treading the same ground walked by Amb tonight - this and the regulated supply, too.
wink.gif
 
Aug 24, 2007 at 2:16 AM Post #11 of 46
Quote:

Originally Posted by balou /img/forum/go_quote.gif
do you mean stuff like FFT or more like 'look at some consecutive values'? first would be nearly impossible, second easier.


Yea, I'm thinking the middle ground between FFT/FIR and a simple value check or difference check. A rolling average, or maybe some simple integration/differentiation would be fairly simple.
Quote:

I also thought about voltage-dependent modes - say if DC is 0.01-0.5v, sample a few times. If the value is above, shut down immediately.
Turn-on delay could be done with several methods:
-if on same psu as amp: do not turn on until 3 seconds after poweron
-via dedicated power-on indication line. guess it could be fairly easily modded into most amp designs
-failback: normal circuit breaking after dc is high enough


Yea, for small offset maybe just a warning would be sufficient, flash the LED or something. For more serious issues obviously cut the output immediately. Similar: latch open for serious issues until power is cut, but return to service if minor issues are transient.

You've got turn-on delay nailed I think. The only other thing I can think of is automatically open the relay after so many seconds of no signal and then delay before turning back on after detecting signal again, but this can't reliably detect power on (ie. could turn the amp off and on again before the relay opens), and isn't easy to implement (compared to the rest of this circuit).

Quote:

Btw, PIC microcontrollers suck - low RAM, no ADC, no free C compiler


Very much in agreement there. The architecture is just weird (tm) as well, and not easy to work with. The only problem with Atmels is that there are less varieties of them available in nice DIP packages - but they're so much more flexible it's not really a downside. AVRStudio is way nicer than MPLAB...the list goes on. I often wonder why the DIY community is so fixated on Microchip parts...

Quote:

edit2: I forgot:
ADC in attiny13 is 10bit. absolute precision is spec'd at 8bit (no linearity/gain/nonlinearity/noise/other errors). internal reference voltage is 1.1V, 1.1/2^8 gives 4.3mV steps. A sampling frequency of 1khz should be possible. May be lowered to 50hz, because 1khz might be just to much (also because of 'dc' components of clipped, low-frequency or both audio signals)


I was thinking some gain would be beneficial in the input buffer (post filter). Maybe do a 10x gain to increase the resolution; it really doesn't matter if the opamp pins to the rail since this will obviously trigger the offset protection in either case. This would greatly increase the useful resolution at the ADC. If 100mV appear as almost a full-scale conversion I would think that's appropriate resolution.

I was thinking more of ATtiny25 which is DIP8 instead of DIP20 to save space. Don't really need the extra pins, but it's a few pennies more. I don't know if ATtiny13 has it, but there is also one ADC channel (the differential one) that can have gain applied internally (programmable) that might also be useful to use instead of gain in the buffer stage.

One more thing, since these Atmels have so many ADC channels, might be nice to throw a pot on one and use it to set the threshold.
 
Aug 24, 2007 at 4:00 PM Post #14 of 46
I think a buffer is definitely needed - I made some calculations with a 1M resistor (needed for the high input resistance) and a cap after it as a lowpass filter. Anybody got 100F caps at home?

An opamp would be most versatile - and its what most people here have lying around in masses
smily_headphones1.gif

A lowpass filter could be directly integrated in the feedback loop. Maybe a first-order or butterworth filter after the buffer stage. http://en.wikipedia.org/wiki/Low_pass_filter has a tiny section about a simple digital low pass filter. Looks like it could be easily realized into an Atmega.
And of course you would have the option to amplify with an opamp.

Quote:

latch open for serious issues until power is cut


good idea

Quote:

The only other thing I can think of is automatically open the relay after so many seconds of no signal and then delay before turning back on after detecting signal again, but this can't reliably detect power on (ie. could turn the amp off and on again before the relay opens), and isn't easy to implement (compared to the rest of this circuit).


Yep, some minimal offset should always be present if the amp is turned on. But I think that this would indeed need some measuring and debugging to get it right. But auto-off would of course be a great idea.
Quote:

it really doesn't matter if the opamp pins to the rail since this will obviously trigger the offset protection in either case.


but it also shouldnt be to high - a 4.3mv resolution seems quite good to me. It wouldnt be very good to lose the ability to tell between a minor and a major fault. 100mV could be a temporary fault, while 1V would be a good reason to implement your latch open response.


Quote:

I was thinking more of ATtiny25 which is DIP8 instead of DIP20 to save space. Don't really need the extra pins, but it's a few pennies more. I don't know if ATtiny13 has it, but there is also one ADC channel (the differential one) that can have gain applied internally (programmable) that might also be useful to use instead of gain in the buffer stage.


attiny13 is also 8pin - the 2313 is 20 pin. No, the 13 has no internal programmable gain. I couldnt find the attiny25 at my distributor, only the attiny26 and attiny45. I actually thought about replacing the 8 pin 13 with the 20 pin 2313 - if you want to guard both channels separately, you will soon have a problem with your available pins. 2 for power, 2 for each chan, 2 for each relay, 1 for the LED. This would work, but while debugging, a serial port displaying the current dc voltages would be very helpful. A 3 or 4 led display of current dc offset would also not work, and a digital pushbutton power on like in dakillers design would also be nice (hey, if you already got a microcontroller, why not use its full potential
wink.gif
). An external crystal also takes up two ports - this could be necessary for the serial port, the internal RC oscillator isnt what you could call high precision. So, for the debug version, I´d say more pins would be beneficial. For the "production" version, 8 pins might work out. Quote:

One more thing, since these Atmels have so many ADC channels, might be nice to throw a pot on one and use it to set the threshold.


had the same idea last night
smily_headphones1.gif


Dakiller: nice analog circuit! I will steal as much as needed from it and use it in my evil and cold digital circuit
evil_smiley.gif


hey it looks like this is evolving into an all-you-need-digital-amp-controller
cool.gif
has anybody mentioned yet relay-based digital attenuator?
icon10.gif


edit: d´oh, the attiny2313 hasnt got an ADC. but the attiny26 does - and this one is also 20 pin (and only 20 pin, no 8pin version availabe)

edit2: ok, attiny45 is the 4kb version of the attiny25. this chip has some nice ADC features. You can select, while the chip is running, between 1.1v, 2.56v and Vcc reference voltage (Vcc being 5v). And gain of either 1 or 20. This would enable quite a high range of possible measurements. But only 8 pins... well, this would require some thoughtful consideration on how to use the different pins
 
Aug 24, 2007 at 6:06 PM Post #15 of 46
Quote:

Originally Posted by balou /img/forum/go_quote.gif
Yep, some minimal offset should always be present if the amp is turned on. But I think that this would indeed need some measuring and debugging to get it right. But auto-off would of course be a great idea.
but it also shouldnt be to high - a 4.3mv resolution seems quite good to me. It wouldnt be very good to lose the ability to tell between a minor and a major fault. 100mV could be a temporary fault, while 1V would be a good reason to implement your latch open response.



I'd consider 100mV a pretty serious issue myself, but I do see your point. Some gain would probably be useful, but tuning it would depend on your goals for the circuit. If you do a gain of 5x, you still get much better absolute resolution and 200mV upper limit, and like you say, the ATtiny25 has multiple available references so if you see that the output has hit the rail you could change references and do another conversion, which should really get you the best of both worlds (if you have 250mV offset I don't think you care about the 1mV accuracy anymore...). At 5x and 5V single ended supply a 500mV offset would hit the opamp rail (rail-to-rail amp obviously), which should be enough for most. I'm just worried that we're talking about headphone amps here, and a 4.3mV offset could be considered a problem that you'd want to be alerted to (most recommend trying to keep offset < 1mV from what I've seen) - but this is only 1LSB away from 0 in your scheme. It's also not very granular - 4.3->8.6->12.9 are pretty big steps for a headphone amp. Finally, don't forget that if you're using a single-ended supply you're effectively halving the resolution since your offsets could be +/- around Vcc/2 (which may require some extra finagling now that I think about it - the ADC won't like having 2.5V of DC offset itself with a 1.1V reference, but you can't ignore negative offsets)

Quote:

attiny13 is also 8pin - the 2313 is 20 pin. No, the 13 has no internal programmable gain. I couldnt find the attiny25 at my distributor, only the attiny26 and attiny45. I actually thought about replacing the 8 pin 13 with the 20 pin 2313 - if you want to guard both channels separately, you will soon have a problem with your available pins. 2 for power, 2 for each chan, 2 for each relay, 1 for the LED. This would work, but while debugging, a serial port displaying the current dc voltages would be very helpful. A 3 or 4 led display of current dc offset would also not work, and a digital pushbutton power on like in dakillers design would also be nice (hey, if you already got a microcontroller, why not use its full potential
wink.gif
).


Oops, I saw the 20MLF package and assumed it was 20DIP as well. Quick skim, obviously...

I was thinking this could probably be done in 1"x1" with SOIC8 parts in a final version, so I was thinking to try and avoid superfluous features and parts. One dual channel opamp, some passives and the microcontroller, then a MOSFET and diode to drive the (external) relay could easily fit in such a small space. If you start adding all this extra stuff you're going to double or triple the board area requirements at least, but I don't know what your goals are with this. I like the amp power control idea though, and that means you need more pins (or no LED output), it solves both the power-on delay issue and the power-off muting - but does require an extra standby power supply for the uC.

I would do it thusly:

2 pins power, 2 pins ADC input, 1 pin signal relay, 1 pin power relay, 1 pin LED, 1 pin power switch. I can see why you'd want more pins though, first, I believe this configuration would preclude ISP since you'd have to disable the reset pin, and of course it would be nice to have another LED or two and a reset switch, and maybe your LED 'VU' meter. More IO is always handy...I just really like the idea of this being a minute and cheap board.

I don't think serial out is necessary at all, the code is going to be simple, and any algorithmic behaviour can easily be simulated, either with a machine simulator or just a regular C compiler.

Quote:

hey it looks like this is evolving into an all-you-need-digital-amp-controller
cool.gif
has anybody mentioned yet relay-based digital attenuator?
icon10.gif


Well, currently you're only attached to the amp outputs...different problem entirely I would say...

Quote:

edit2: ok, attiny45 is the 4kb version of the attiny25. this chip has some nice ADC features. You can select, while the chip is running, between 1.1v, 2.56v and Vcc reference voltage (Vcc being 5v). And gain of either 1 or 20. This would enable quite a high range of possible measurements. But only 8 pins... well, this would require some thoughtful consideration on how to use the different pins


ATtiny24/44/84 looks like a good compromise. It's a 14 pin device, has the same ADC features as ATtiny25/45/85 but lacks the 2.56V reference. Would allow more IO, isn't too large, and still gets you 1.1V and Vcc references. ATtiny26 is 'not recommended for new designs'. If you wanted a 20 pin device, ATtiny261 would be a better alternative, and does include all the same ADC features as ATtiny25 including 2.56V reference (and additional differential inputs as well).

Personally even with my illusions of a tiny device, I'd probably go with the ATtiny24.
 

Users who are viewing this thread

Back
Top