Does anyone know of a proper headphone circuit/driver from a microcontroller? - Page 1
Forum section: electronics / projects

author: alank2
author_rank: Super Contributor
timestamp: July 15, 2017, 03:24:00 am
content: Hi,From an AVR (5V) - if I wanted to drive a 3.5mm jack to a level that headphones/earphone would supply. My goal is to make it be like an earphone jack on many of the portable cassette deck's from decades ago. One of them had a specification 8-100 ohms.Thanks,Alan

author: NiHaoMike
author_rank: Super Contributor
timestamp: July 15, 2017, 04:08:16 am
content: If you just want to play some tones using the PWM, a 1k resistor in series with a 1uF capacitor will do. Adjust the resistor value up or down as needed to get the right volume level.

author: Ian.M
author_rank: Super Contributor
timestamp: July 15, 2017, 11:07:52 am
content: Seehttp://www.rane.com/pdf/old/note100.pdffor typical headphone power levels. A MCU pin cant supply enough drive to get an adequate power level. Options include using a headphone amp chip like theTDA1308Tthat can run from as little as 3V, and feeding it a low-pass filtered signal from the MCU, or if you want better energy efficiency, PWMing a low voltage MOSFET H-bridge chip, with the headphones + a passive low pass filter connected as the load.

author: NiHaoMike
author_rank: Super Contributor
timestamp: July 15, 2017, 02:17:13 pm
content: Quote from: Ian.M on July 15, 2017, 11:07:52 amNot true, when 0dBm into a pair of modern headphones gives on the order of 100dBA output.

author: Ian.M
author_rank: Super Contributor
timestamp: July 15, 2017, 03:04:40 pm
content: Quote from: NiHaoMike on July 15, 2017, 02:17:13 pmIf you select high sensitivity headphones of appropriate impedance, then, yes, you can drive them direct from a MCU, but if you need a max output level similar to the original Sony Walkman TPS-L2 personal cassette player, of 15mW, because you want it to work well with low sensitivity headphones, which are often in the 30 to 50 Ohm range, you'll need nearly 32mA peak drive to them, which is more than most MCUs can reliably output.The problem gets worse if you have to support 8 Ohm mini-speakers. Lets suppose 25mA abs max drive capability from the MCU, which gives a max RMS current of 17.7mA and only 2.5mW into an 8 Ohm load.Its even worse if L and R are wired in parallel from a single mono output . . . .

author: Zero999
author_rank: Super Contributor
timestamp: July 15, 2017, 04:05:41 pm
content: Quote from: NiHaoMike on July 15, 2017, 04:08:16 amSkip the resistor and put the headphones in series with a muchlowerhigher value capacitor: 470µF to 1000µF. The inductance of the headphone will act as its own low pass filter. If there are EMI problems, then add an inductor.

author: alank2
author_rank: Super Contributor
timestamp: July 15, 2017, 04:21:02 pm
content: I am making a cassette interface for a retro computer, so I am attempting to duplicate what a cassette recorder would output. The TDA1308 is interesting, but like an opamp it requires many external parts, I only need a mono channel, so can I just use a regular opamp like I am using for the mic. Then I could get a quad op amp instead of using two ic's. Assuming we are talking about a generic opamp, what would be a good circuit? In the TDA1308 they use 3.8k for both resistors to determine the gain, would that mean that are doing a 1 gain? But, do I want a 1 gain? My microcontroller pin will be at 5V and I was reading that earphone level is around 1V which I am not sure is true. If I were going to add a volume control via a POT, where would that be added in the schematic? What type of POT? 10K? Would it be to the left of C4 or the right of C4?

author: Ian.M
author_rank: Super Contributor
timestamp: July 15, 2017, 04:39:37 pm
content: That's a completely different set of requirements. It was common to have to mod tape players to reduce the level at the headphone socket to get a clean enough signal for computer data input from cassette. An OPAMP buffer will probably do the job, however as some old home computers echo the signal from tape in to tape out, you shouldn't use a single quad OPAMP for both input and output due to the risk of crosstalk causing instability. Put the volume control after any filtering but before the buffer or hedphone amp IC.

author: alank2
author_rank: Super Contributor
timestamp: July 15, 2017, 06:23:11 pm
content: I can see some leaking of the tape in signal to the tape out, but just noise I think, I didn't see any discernable signal. The input on the computer (connects to EAR) is 27 ohms to ground. The output on the computer (connects to MIC) is 100 ohms to ground. I've attached the circuit a friend helped me come up with for the MIC. It amplifies the 15mV to a very nice square wave. I couldn't believe how much the second op amp stage cleaned it up. I am using some LM358's I had in a tube from electronic gold mine so far.Some testing shows the tape deck playing back the signal at around 5.6V, with the computer connected though it was 1.6V (this is on maximum volume). I've been able to successfully load programs using half of this volume though. I'll start playing with another opamp circuit like my mic one, but this time use unity gain. Any thoughts on what size capacitor I need to use on the opamp output? Ceramic or Aluminum? If Aluminum, + side towards the opamp? Should I use a pull down resistor after the cap? Any idea on size?

author: alank2
author_rank: Super Contributor
timestamp: July 15, 2017, 06:53:13 pm
content: I put together a similar opamp circuit, but just the left half of my schematic above. I eliminated the 50M pullup and changed the 1.5M to 10K so it will be unity gain.I used a 1uF input and fed it with a 0-5V signal from my frequency generator. I could see it did indeed output a very similar amplitude waveform. I ended up putting that through a 68u and 220u cap and had to put a 10K to ground to pull it to ground after that.Then i tested it under the load of having the computer connected. It seemed to pull down the signal to a 1.6V for 5V just like my measurements from the tape deck, but when i lowered the voltage 4V, 3V, 2V, 1V, it didn't seem to still follow the same ratio. It wanted to stay at that 1.6V/1.4V area. I remeasured the tape and at lower volume like 50%, it was still going to around half of the unloaded output signal. For example, tape unloaded output 1.5V, loaded with computer 680mV. Any ideas why? My current on the op amp unloaded is around 1mA, but jumped to about 10mA when I connect the computer/load.

author: Ian.M
author_rank: Super Contributor
timestamp: July 15, 2017, 07:24:34 pm
content: 27 Ohms is a very low resistance for an OPAMP to drive with that magnitude amplitude. Try aLM386fractional watt single ended mono audio amp IC instead. It has a preset gain of 20 so will need an attenuator ahead of it. A few hundred K between the signal source and the top end of the 10K pit volume control in its typical application circuit should do the job. Choose the series resistor so a sinewave with the same peak to peak amplitude as your squarewave signal *just* starts to clip at max volume with a 27R load.The computer may have a clamping circuit to shunt the input if the amplitude is excessive so isn't a gool load for testing volume control response.

author: alank2
author_rank: Super Contributor
timestamp: July 15, 2017, 11:29:22 pm
content: Thanks Ian.M. I'll give that a try once I order some parts!In the meantime, if you have a moment, please help me understand things. I'm trying to learn as I mess with these things!When I tested the tape deck:Unloaded output at full volume was 5.6V, connected to computer dropped it to 1.7V (30% of original).Unloaded output at half volume was 2.8V, connected to computer dropped it to 0.9V (32% of original).Unloaded output at quarterl volume was 1.25V, connected to computer dropped it to 0.43V (34% of original).I retested my opamp (again what I have on hand, LM358):Unloaded output of 3.32V gives 1.36V loaded with 27 ohm to ground resistor. 41%Unloaded output of 2.80V gives 1.36V loaded with 27 ohm to ground resistor. 49%Unloaded output of 1.25V gives 1.25V loaded with 27 ohm to ground resistor. 100%Is the op amp output *stronger* than the tape deck output and so it holds up better under load?

author: Ian.M
author_rank: Super Contributor
timestamp: July 15, 2017, 11:51:32 pm
content: It would seem the tape player has an output impedance of about 57 Ohms. Its probably deliberate to protect it against shorted headphones, and if it has an internal speaker, may be as simple as a 56 Ohm series resistor in the headphone circuit.The OPAMP output impedance is much much lower, a fraction of an ohm, but it cant deliver enough current for much more than 1.25V out into a 27 Ohm load. Try adding a 56 Ohm resistor in series with the output to make it more like the tape player. However its still going to flake out on you somewhere between 3.5V and 4V unloaded: when you load it it will clip. To get the same performance as the tape player, you'll need the suggested LM386 with a supply voltage for it of at least 7V.You could also try two sections of a quad rail-to-rail OPAMP, in identical circuits, inputs paralleled and outputs linked via 110 Ohm resistors so they share the load evenly. (or 180R if you use three sections) That will give you double (or triple) the current and a significant increase in the output voltage before clipping.Please use a scope and test with a triangle wave or a sine wave, not a square wave, so clipping is obvious.

author: jaycee
author_rank: Regular Contributor
timestamp: July 17, 2017, 04:55:13 pm
content: All you really need is a single transistor amplifier stage. This is pretty much what any 80s home computer would have used.

author: alank2
author_rank: Super Contributor
timestamp: July 18, 2017, 08:17:05 pm
content: I finally made a cable today that has the 8-pin DIN the computer needs on one end and the three mono minijacks on the other, one for EAR, MIC, and REM (2.5mm motor control jack). Interestingly it would not work at first with the volume up on 8/10. It works at that volume with MIC disconnected, but if you connect MIC, you must lower the volume to 5. With MIC connected, it works even with the volume at 2, which is something it did not do with MIC disconnected. Is having both MIC and EAR connected somehow amplifying what the EAR circuit sees?

author: alank2
author_rank: Super Contributor
timestamp: July 19, 2017, 02:08:17 am
content: Schematic found!

author: Ian.M
author_rank: Super Contributor
timestamp: July 19, 2017, 08:56:46 am
content: I thought you said the input was 27 Ohms to ground. That schematic shows 10 Ohms to ground. I'd recommend an audio amp like the LM386 to drive it as an OPAMP isn't going to be able to drive a 10 Ohm load with enough amplitude.What's the make and model of the computer? It does sound like there's a feedback problem - the tape recorder's Mic input should be inactive during playback and on the other end, the computer's CMT IN should be disabled while saving programs or data.l

author: alank2
author_rank: Super Contributor
timestamp: July 19, 2017, 12:01:48 pm
content: Quote from: Ian.M on July 19, 2017, 08:56:46 am27 ohms is what I measured all right. I'll remeasure it. I've got a LM386 coming in today to mess with.Quote from: Ian.M on July 19, 2017, 08:56:46 amNEC PC-6001A - I agree, I don't see the input/outputs connected so I don't see how having the MIC connected helps the EAR, but could it be that they are connected somehow inside the cassette recorder?