Driving a headphone jack?

I have been toying with the idea of programming an Uno for sound generation, using waveform-data for various instruments. The question is as follows:

how can I drive a headphone jack, electrically, with minimal equipment, that is, no "shields"?

I plan to use a 7-bit linear digital potmeter (128 steps), using a timer loop, and for each "tick" modify the resistance of said digital-pot. Whether a poor atmega328p can manage a frequence of 44100 updates per second (CD quality) is doubtful, though that side of things is my problem.

Letting the digital potmeter form the lower (or upper?) half of a voltage divider, and assuming I get at least some thousands updates per second, how do I convert this varying voltage signal into current driving some headphones? Will a simple transistor do the trick, and in that case, what type?

The digital potmeter is as follows:

http://docs-europe.electrocomponents.com/webdocs/1380/0900766b81380cc8.pdf

It is programmed by SPI.

No code to show as of yet.

Hi,

Hmmmm...

driving some headphones

Headphones vary a lot.

  • What is the actual load impedance of the headphones you will be using?
  • What is "Loud Enough"?? (You may want to connect the headphones to another source and measure the voltage applied for "Loud enough". ) OR maybe there are specs on your Headphones.

I think you need "some kinda amplifier"...

What power / voltage do you have available to power an amplifier?

One of the low-cost 5VDC or 12VDC "Class D" modules available might be easiest.

terryking228:
Hi,

Hmmmm...

Headphones vary a lot.

  • What is the actual load impedance of the headphones you will be using?
  • What is "Loud Enough"?? (You may want to connect the headphones to another source and measure the voltage applied for "Loud enough". ) OR maybe there are specs on your Headphones.

I think you need "some kinda amplifier"...

What power / voltage do you have available to power an amplifier?

One of the low-cost 5VDC or 12VDC "Class D" modules available might be easiest.

Most devices with a headphone jack work with most headphones, so I guess they are quite similar. Something like 32 ohms impedance? Think I've seen that number somewhere.

Of course, once we have a signal within the voltage and current range expected by headphone jacks, I may plug it into a discrete amplifier, to do with as I please.

The digital potmeter comes in different variants, I believe mine is 0-10K ohms, and putting it between GND and a top resistor of a few hundred ohms to limit current draw, while still retaining a resulting divided voltage in the range from GND to close to 5V.

So not very much amperage, say 0-10 mA, and basically a 0-(close to 5V) signal. If that is too much, of course increasing the top resistor will lower max output voltage from the divider.

I do not know the voltage and amperage requirements of headphones. Read somewhere that headphones are more about current than voltage.

Rupert909:
I do not know the voltage and amperage requirements of headphones. Read somewhere that headphones are more about current than voltage.

The important part is impedance. 32ohm is common.
That's 16ohm for the two sides parallelled.
Too low for an Arduino pin.
Leo..

I agree, you need a headphone amplifier...

The Arduino output pins are rated for 40mA absolute maximum, so with 5V that means the minimum load resistance/impedance is 125 Ohms.

Most headphones are 32-64 Ohms but as Terry says they vary quite a bit. So to be perfectly safe, put a resistor greater than 125 Ohms in series with the outputs(s).

  • The headphone will probably be loud enough with the resistor depending on the sensitivity of the headphones, their impedance, and how loud you like it... So, you probably need a volume control. A headphone amp with a volume control solves that.

  • The headphone impedance will "interact" with your 7-bit digital pot 'DAC' making it non-linear, unless the pot resistance is much lower than the load (the headphone and the series resistance). With a 10K pot and a ~100 Ohm load, it ain't gonna' work at all... :frowning: A headphone amp (with a 100K or greater input impedance) solves that too.

Whether a poor atmega328p can manage a frequence of 44100 updates per second (CD quality) is doubtful, though that side of things is my problem.

Probably, as long as your other processing doesn't eat up too much CPU time. Your 7-bit DAC isn't "CD quality" either... :wink:

P.S.

For experimental purposes, I recommend powered computer speakers. Typically, they will have an input impedance of 10k or more and they have a volume control.

Then if your project works-out and you're getting some nice synthesized sounds, you can think about adding a headphone amp or speaker amp.

DVDdoug:
P.S.

For experimental purposes, I recommend powered computer speakers. Typically, they will have an input impedance of 10k or more and they have a volume control.

Then if your project works-out and you're getting some nice synthesized sounds, you can think about adding a headphone amp or speaker amp.

Good suggestion.

One other thing I've been thinking about, is that when varying voltage between 0 and 5 volts, current only flows in one direction. Since speakers and headphones are about moving air back and forth, I'd think that the output signal should be somewhat balanced, to move the speaker element in both directions, not just in one, thus relying on the springiness of the membrane or whatever, to bring the element back to "zero"-position?

Is this at least conceptually an issue, or what?

For this reason, I considered using two programmable resistors, in parallel setups as described, and by driving the two resistors in different directions, symmetric about the center, current will flow in both directions.

DVDdoug:
I agree, you need a headphone amplifier...

The Arduino output pins are rated for 40mA absolute maximum, so with 5V that means the minimum load resistance/impedance is 125 Ohms.

Most headphones are 32-64 Ohms but as Terry says they vary quite a bit. So to be perfectly safe, put a resistor greater than 125 Ohms in series with the outputs(s).

  • The headphone will probably be loud enough with the resistor depending on the sensitivity of the headphones, their impedance, and how loud you like it... So, you probably need a volume control. A headphone amp with a volume control solves that.

  • The headphone impedance will "interact" with your 7-bit digital pot 'DAC' making it non-linear, unless the pot resistance is much lower than the load (the headphone and the series resistance). With a 10K pot and a ~100 Ohm load, it ain't gonna' work at all... :frowning: A headphone amp (with a 100K or greater input impedance) solves that too.
    Probably, as long as your other processing doesn't eat up too much CPU time. Your 7-bit DAC isn't "CD quality" either... :wink:

Your input is greatly appreciated. And of course you're right that the 7-bit digital pot is not likely to produce fantastic sound.

I assume some tiny capacitor between the output lines will remove some of the ripple that near instantanous changes in voltage/current from the programmable resistor(s) will undoubtedly cause.

Another interesting item is how to represent a custom wave form within 2Kb or RAM. I did consider using external EEPROM or even external SRAM, but that induces additional cycles for communication, so the main wave form(s) must reside in SRAM for speed.

Looking forward to experimenting with this. I will add that I wrote an "addititve synthesizer" in Java, some years ago, and managed to create a waveform that sounded close to piano over about one and a half octave. :slight_smile:

Something like this, for balanced output, with current flowing both ways?

I did away with the "top resistor", of the initial single-sided approach, and instead added R1in series with the speaker. I will have to verify its value, as there sure is a limit to how much current (wattage) the digital pots can handle, haven't checked that yet.

However, perhaps the top resistors (between 5V and the digital pot) still have a function of bracketing the voltage span. I mean, between +5V and -5V, there is a difference of 10V, and that sounds a bit much?

:slight_smile:

Rupert909:
I assume some tiny capacitor between the output lines will remove some of the ripple that near instantanous changes in voltage/current from the programmable resistor(s) will undoubtedly cause.

Yes, but it is miles removed from a properly working anti-aliasing filter.

Thanks for the help. I realize that 7-bits resistors are not the best of DAC's. If I get something working, I may elect to go for an actual DAC from RS, something like this.

Now it's only about finding the time to experiment. I am a many-projects-at-once type of person, experimenting in robot indoor navigation and trying to find time to build a table-top CNC router using steppers and screw rods.

:slight_smile:

Rupert909:
Letting the digital potmeter form the lower (or upper?) half of a voltage divider,

A potentiometer is a voltage divider. That, by definition, is what it is.

Rupert909:
how do I convert this varying voltage signal into current driving some headphones? Will a simple transistor

To convert voltage into current, you use a resistor. Actually, the headphones are in fact, resistors.

The limitation of using a digital potentiometer to drive headphones is that its 5 or 10k resistance severely limits the output into the 32 Ohm headphones, except at the last few steps.

You clearly need an amplifier (or at least, buffer) between the digital potentiometer and the speakers, and a capacitor (47 µF and upward) between the output and the headphones.

Paul__B:
A potentiometer is a voltage divider. That, by definition, is what it is.

Yes, what I was talking about was a fixed resistor on top of the variable, so as to limit the voltage range from +/- 5V to something lower.