Head-Fi.org › Forums › Misc.-Category Forums › DIY (Do-It-Yourself) Discussions › Idea: active headphone protecting circuit
New Posts  All Forums:Forum Nav:

Idea: active headphone protecting circuit - Page 2

post #16 of 46
Thread Starter 
I didn't think about the reset port, this would limit the 8 pin chips to 5 IO lines. I want to avoid HV programming if possible - an STK500 board costs about 220$ here in switzerland, or 80$ + 35$ shipping + ??$ customs from digikey.
Olimex has an ISP programmer for a mere 9.95$. Another option would be this: http://elm-chan.org/works/avrx/avrxp8.png.

Yes, the ATtiny24/44/84 looks good - but I can't find a place where I could buy it (and remember, 35$ shipping fee from digikey...). Guess it's either attiny45 or attiny26 for me - the first can most likely also be substituted by a n attiny25, the second should be compatible with the upcoming attiny261 (26 is 'not recommended for new designs', but not yet marked as 'obsolete'. looks like full scale production for 261 is just starting)

So, how to use the pins?
3 Vcc, GND, Reset
2 ADC inputs
1 LED indicator
1 power on sense
1 relay trigger (we don't really need to adress the two relays separately)
This gives 8 pins. The power on sense could be replaced by a trimpot if the chip is powered by the same power supply as the amp.
With a 14 or 20 pin uC, there would be the additional possibility for:
2 io for pushbutton on/off
1 for trimpot
1 for serial out (not for debugging the code, but more for seeing the actual values the ADC generates. in the 8pin version, they could also be stored in the eeprom and then read out by the programming adapter)
2 additional LEDs, or 3 without serial out

Quote:
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.
or maybe not - connect it to the normal power supply, and use a transistor to turn on the following amp circuit. I also don't know if a power-sense port is really needed - if the protecting circuit is on the same psu it's not needed, and if the pushbutton function is used it's also not needed. It would be needed if you want to install it into an existing amp with minimal changes necessary (just hook the power-sense line anywhere where there's power if amp is turned on)

But I think people get confused if there are 15 different versions of a design of which they have to choose one. So an all-in-one solution, which would also be reusable in another amp without having to reprogram it would be the best thing in my oppinion. And I think that you can cram all of this on a double sided 1x1 inch board - even with a 20 pin soic (which are wider than 8 and 14 pin soic). With a 14/20 pin uC you can also have a start-up time trimpot. Pretty much first thing that happened to AMBs circuit was that someone modded startup time to 30s.

Quote:
Well, currently you're only attached to the amp outputs...different problem entirely I would say...
ok let's quickly forget about the attenuator idea for now



Quote:
but you can't ignore negative offsets
Yes, but I pretty much did until now . The circuit, how I described it in my posting above, would only work for positive DC currents... it would work for negative voltages if you refer the inverting input of the opamp to a negative voltage source. But where to get this negative voltage source? either 'borrowing' from the power supply, or using a voltage inverter to create it from the +5V supply. but then you'd loose the ability to apply any gain - it would overload the ADC. (the output would basically be DC offset +5v). Another idea: something like a rectifier bridge - but this would have a voltage drop, not a good idea if you measure in the mV range. Anybody got an idea how to solve this?
post #17 of 46
Quote:
Originally Posted by balou View Post
I didn't think about the reset port, this would limit the 8 pin chips to 5 IO lines. I want to avoid HV programming if possible - an STK500 board costs about 220$ here in switzerland, or 80$ + 35$ shipping + ??$ customs from digikey.
Olimex has an ISP programmer for a mere 9.95$. Another option would be this: http://elm-chan.org/works/avrx/avrxp8.png.

Yes, the ATtiny24/44/84 looks good - but I can't find a place where I could buy it (and remember, 35$ shipping fee from digikey...). Guess it's either attiny45 or attiny26 for me - the first can most likely also be substituted by a n attiny25, the second should be compatible with the upcoming attiny261 (26 is 'not recommended for new designs', but not yet marked as 'obsolete'. looks like full scale production for 261 is just starting)
I'll probably be placing a DigiKey order sometime in the next few weeks; I could tack on a few ATtiny44 and mail them to you. I think these parts are fairly easy to get for most of us . If you plan to sell boards, you should probably plan to offer preprogrammed uC's though, so maybe it is a serious consideration. Though if you go with an 8pin uC, users will probably want to change things like offset threshold and power-on delay, and there's not really any way to offer that. I think I like going with the 14 pin uC best, but if the 20pin is all that's available to you...

It would be fine if you designed around ATtiny45, the price difference is only about $0.40 in singles, and if the code fits in an ATtiny25 (which it should), it would be fully compatible anyway.

ok let's quickly forget about the attenuator idea for now



Quote:
Yes, but I pretty much did until now . The circuit, how I described it in my posting above, would only work for positive DC currents... it would work for negative voltages if you refer the inverting input of the opamp to a negative voltage source. But where to get this negative voltage source? either 'borrowing' from the power supply, or using a voltage inverter to create it from the +5V supply. but then you'd loose the ability to apply any gain - it would overload the ADC. (the output would basically be DC offset +5v). Another idea: something like a rectifier bridge - but this would have a voltage drop, not a good idea if you measure in the mV range. Anybody got an idea how to solve this?
Assuming a single-ended +5V supply for the opamp here, this will cause some problems I hadn't really thought of earlier either. Most opamps won't really tolerate inputs below/above their rails, so this might even break the opamp. Also, don't forget to clamp the inputs to VCC/GND with diodes so that 'high' voltage AC signals don't kill it either. I can't think of a way to handle this without a dual supply.

Oh, and none of these have a hardware UART - you want to implement serial in software just to see the ADC values? Use your multimeter and trust the microcontroller
post #18 of 46
I just did up a layout and it's definitely possible to fit everything necessary in 1"x1" of PCB with a SO20 microcontroller. The layout's not the greatest but it's definitely passable.

I'll post it in a couple days, it's my birthday and I'm late for my own party
post #19 of 46
Thread Starter 
Quote:
none of these have a hardware UART
you sure? I thought they did.

Quote:
I'll post it in a couple days, it's my birthday and I'm late for my own party
Congratulations. The situation looks awfully familiar to me

I think I found a (partial) solution to the negative voltage problem.
First: the board will require at least 12v. Digital power supply is from the upper 6v, using a LDO regulator (or normal reg if you have at least 14v). opamp is +-6V.
You configure it as a differential amplifier, with a negative bias current of 100mV on the inverting input. Gain of 5.5. This yields an output of 0-1.1v if input is between -100 - 100mV.
You must of course add some clamp diodes to it. I just dont know yet where. I also dont know yet how to generate the -100mV.

Oh, error401: how are you going to programm a directly soldered on SOIC chip? Looks like theres a need for an ICSP connector on the 1x1" board...
post #20 of 46
Quote:
Originally Posted by balou View Post
you sure? I thought they did.

Congratulations. The situation looks awfully familiar to me

I think I found a (partial) solution to the negative voltage problem.
First: the board will require at least 12v. Digital power supply is from the upper 6v, using a LDO regulator (or normal reg if you have at least 14v). opamp is +-6V.
You configure it as a differential amplifier, with a negative bias current of 100mV on the inverting input. Gain of 5.5. This yields an output of 0-1.1v if input is between -100 - 100mV.
You must of course add some clamp diodes to it. I just dont know yet where. I also dont know yet how to generate the -100mV.
Trimpot voltage divider? It doesn't have to be super accurate...could always use a zener to get the voltage to divide too. That's pretty much how I was thinking of doing it.

Quote:
Oh, error401: how are you going to programm a directly soldered on SOIC chip? Looks like theres a need for an ICSP connector on the 1x1" board...
Of course I placed an ISP connector and it still fits - but the board has some flaws. There is an LDO reg placed (DPAK package), it can supply 100mA, which should be enough to power a small signal relay and the board components. I suppose a larger capacity reg could be fitted, there is some room. I'm not sure what your whacky power scheme will require though, there may not be enough extra room. There is probably room to squeeze in one more relay driver transistor and another 2 pins of header, but it'd be tight. There is no bulk power decoupling, so a good regulator would be required; the 0.1uF should be enough to keep the uC running during any switching transients. There was, however, room for two SMD trimpots (one for power-on delay, but I didn't add the relay driver to handle that..hah..too lazy now..). All fits in 1x1. A better option would maybe be to put space for the relays on the board as well...

Anyway, here's how it looks with a generic opamp input circuit. All resistors are 1206, caps are 1210. Shouldn't be too difficult to build. Really just a proof of concept though, didn't think too hard about optimizing it, just wanted to see if it could fit, but this board should be usable...:






post #21 of 46
Thread Starter 
Board looks good so far - I won't comment on every detail because of its PoC status. I would maybe go for a single sided board (at least for the first prototype). I really want to home etch something

About the negative voltage problem: I have not really found an easy solution - best idea so far is a precision full wave rectifier. like a diode but without any voltage drop (or only insignificant drop). Being able to include a gain stage and an active filter would be good, but most likely quite complex. This would require a quad opamp. Six opamps if I can't figure out how to integrate filtering and gain stage into this existing circuit .....
post #22 of 46
Thread Starter 
another idea: forget that precision rectifier, use the differential ADC input - one pin with -100mV, and then reference the two other pins to this input. But I have to check if the attiny45 will allow that electrically
post #23 of 46
It might be easier to just generate +/-2V supplies for the uC's VCC/GND.
post #24 of 46
Thread Starter 
um yeah. I would never have thought of such an easy idea.
I'm not sure about the type of power supply. a lm317/337 would of course work - but might be overkill. zener regulation could also work if the current draw isn't to big - this would mostly depend on the current needed for the transistors

Well, at least no need for 4 or more opamps...
post #25 of 46
Quote:
Originally Posted by balou View Post
um yeah. I would never have thought of such an easy idea.
I'm not sure about the type of power supply. a lm317/337 would of course work - but might be overkill. zener regulation could also work if the current draw isn't to big - this would mostly depend on the current needed for the transistors

Well, at least no need for 4 or more opamps...
A switcher would be required for the -2V since we need to reference external 0V, and probably don't want to require +/- supplies. Maybe a LM317L set for 2.5V for the positive rail, and then maybe LT1617 (quick search) to generate the negative rail. Should be possible to do it fairly small. Expensive though, probably there are cheaper inverting regs that would be suitable.

The other option using this scheme might work out better; just move the ground down ~0.5V and then use the 1.1V ADC reference voltage. This should keep a nominal input around half of full scale, and allow enough resolution without having to deal with stripping off the 2.5VDC the ADC would otherwise see (that would reduce resolution severely). I'm not sure if you'll find a switcher that will work properly at this small voltage though, would have to simulate it. Otherwise gain on the opamp will be required and the Vcc reference will have to be used (though there's no reason not to use +/-1.6V and drop Vcc to 3.3V, other than relay drive).
post #26 of 46
Thread Starter 
Quote:
and probably don't want to require +/- supplies.
Well, why not? if it's inside an amp, it most likely has a +- supply

Quote:
and allow enough resolution without having to deal with stripping off the 2.5VDC the ADC would otherwise see
I'm not sure if I understand you right - do you mean the 2.5v relative to GND in the +-2.5v scheme proposed by you? If you add a properly dimensioned voltage gain stage in front of it, you could get a full +-2.5v swing from the about +-100mV DC offset to be expected

edit: Sijosae used a LM2664 as voltage inverter in some of his amps. output current is 40mA - might be enough. But I think that you can take a dual psu more or less for granted
post #27 of 46
Quote:
Originally Posted by balou View Post
Well, why not? if it's inside an amp, it most likely has a +- supply

I'm not sure if I understand you right - do you mean the 2.5v relative to GND in the +-2.5v scheme proposed by you? If you add a properly dimensioned voltage gain stage in front of it, you could get a full +-2.5v swing from the about +-100mV DC offset to be expected
The ADC will 'see' 2.5V of DC offset in any properly configured setup (or rather Vref/2) since we need to centre the range at 0V. If that 'centre' is at 2.5V, then the largest ADC range must be used to encompass that offset, reducing resolution. That is, without other compensation. Not hard to deal with, just a consideration... it may be easier to make things asymmetric supply-wise, use the 1.1V Vref and don't do any gain in the input stage.

If negative supplies are considered this is trivial. For some reason I was fixated on using a single-ended supply for this, but I suppose you're right, this is amp protection, and we should be able to steal the +/-/gnd from the amp itself. I don't see any reason not to use a regulator; our V- rail is going to need to actually do some work and not just serve as a reference (it will be our 'ground') and thus the 'easy' solutions will end up being larger and not as good.

-2.5V - LM337 in SOT-223
+2.5V - LD1117 (fixed) or LM317 in SOT-223

Cheap, but requires a bunch of parts. There doesn't seem to be a suitable -2.5V regulator available (I found one on DigiKey, but it will only tolerate -10V input which would have to be preregulated, and is expensive). Would have to be careful with dissipation here; quiescent current should be fairly low, but with a couple of LEDs lit and the relay pulled in it may approach 100mA.
post #28 of 46
Thread Starter 
Quote:
then the largest ADC range must be used to encompass that offset, reducing resolution
It should not be a problem if you wire up the opamp correctly. Ground should be the headphone signal ground AKA the 2.5v offset voltage at the ADC. Then with a gain of 25, a signal of -100mV becomes -2.5v, meaning 0v at the ADC. The same on the other side. Maybe the opa can be powered with the +/-2.5v (AD823? and many CMOS opamps), or directly from the supply rails.

Calibration should also be trivial - measure the value on the ADC when the headphone and source is unconnected. This can then be used as the value for 0v. on the tiny26 you could use a separate io port for going into calibration mode (and save calibration value in eeprom). for the tiny44, I'm sure that there is a way to somehow signal this state - maybe reuse another port. could the led output port misused as a temporary input port? should maybe work if the led port on startup is treated as an input port. then the enduser could do it with a wirebridge from led_out to gnd or vcc.
post #29 of 46
Quote:
Originally Posted by balou View Post
It should not be a problem if you wire up the opamp correctly. Ground should be the headphone signal ground AKA the 2.5v offset voltage at the ADC. Then with a gain of 25, a signal of -100mV becomes -2.5v, meaning 0v at the ADC. The same on the other side. Maybe the opa can be powered with the +/-2.5v (AD823? and many CMOS opamps), or directly from the supply rails.
Yes, no problem, just something to consider.

Quote:
Calibration should also be trivial - measure the value on the ADC when the headphone and source is unconnected. This can then be used as the value for 0v. on the tiny26 you could use a separate io port for going into calibration mode (and save calibration value in eeprom). for the tiny44, I'm sure that there is a way to somehow signal this state - maybe reuse another port. could the led output port misused as a temporary input port? should maybe work if the led port on startup is treated as an input port. then the enduser could do it with a wirebridge from led_out to gnd or vcc.
I think the problem is that this requires the regulators to be very stable. If one drifts 10mV over a few hours, that will trigger the offset detection, even with user calibration. I haven't looked to see how stable these regulators are, but it doesn't seem beyond the realm of possibility that e.g. warmup could affect the output that much. A simple solution would be to make two measurements each time, one with an ADC channel connected to signal ground before measuring the signal. This requires another ADC pin be dedicated though.

And yes, the AVRs allow reconfiguring the pins in one cycle (though you might need a second to enable pullups), and I don't see any reason why the LED output could not be multi-tasked in this fashion. This could even be sampled periodically at runtime while maintaining the LED output, if necessary. I wouldn't do it with the ADC channels though, the LED may become forward biased by the signal which might affect the reading. With pullups enabled the LED would be forward biased as well with minute current, but the voltage at the uC output should still read 'high' (or low if grounded).
post #30 of 46
Thread Starter 
Quote:
I wouldn't do it with the ADC channels though
yeah, it doesn't have to be used with every single port. but combining binary input and led output should be possible.

Somebody in a uC forum has sent me an alternate, very simple circuit for measuring the +- voltages - have to look at it, maybe it's an alternative.

About the stability: I think the LM337/317 have quite a good stability - they shouldnt drift very far. And remember, at the uC there will be offset voltage times 20 or so. the opamp could be affected by noise in the power supply, but even cheapies have a PSRR of 100dB (tl072)

Quote:
A simple solution would be to make two measurements each time, one with an ADC channel connected to signal ground before measuring the signal. This requires another ADC pin be dedicated though.
Yes, this could be done. With a timer, this could also be done just every 30 secs or so. But thinking of it, why not every sample, there's plenty of time we have. The additional ADC pin would in turn free up a calibration-enable pin. And knowing there's no drift is better than just assuming it.

The ATtiny44 would have an internal temperature sensor - this could be used to either detect a shortcircuit in or near the uC, or a general overheating in the amp case. This leaves the question what would be still an "acceptable" temperature - this is also highly dependent on the amp topology.
New Posts  All Forums:Forum Nav:
  Return Home
Head-Fi.org › Forums › Misc.-Category Forums › DIY (Do-It-Yourself) Discussions › Idea: active headphone protecting circuit