# Arduino Forum

## Using Arduino => Audio => Topic started by: scswift on Mar 11, 2012, 09:42 pm

Title: Having difficulty understanding power when dealing with speakers/amps.
Post by: scswift on Mar 11, 2012, 09:42 pm
Hey guys,

I'm looking at using this amp in my design:

And I will be pairing it with this dac:

And connecting the dac to the amp via a single ended output.

I have a 5v supply, and I understand that if I choose to put a low pass filter on my Vref line then the dac could be outputting only 3v, but for the sake of this discussion just assume I have no filter on Vref and the dac is outputting 5v, and the amplifier gain is 1:1.

Let's also assume I'm using a 4 ohm speaker.

With these parameters in mind I input 5v and 4ohms into the ohm's law calculator, and I get:
http://www.the12volt.com/ohm/ohmslawcalculators.asp

6.25W and 1.25A

Now look at the charts on page 5 of the amp's datasheet.  The numbers I see there don't match up. In fact, there's two sets of numbers for different total harmonic distortions.  How can this be?  If I have a 5v supply and a 4 ohm impedance, how can the output, according to these graphs, be either 2.75W or 2.25W?

And why is it these values are so low compared with what ohms law seems to say the power should be for 5v flowing through 4 ohms of impedance?
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: retrolefty on Mar 11, 2012, 10:05 pm
Let's also assume I'm using a 4 ohm speaker.

Quote
With these parameters in mind I input 5v and 4ohms into the ohm's law calculator, and I get:
http://www.the12volt.com/ohm/ohmslawcalculators.asp

6.25W and 1.25A

Now look at the charts on page 5 of the amp's datasheet.  The numbers I see there don't match up. In fact, there's two sets of numbers for different total harmonic distortions.  How can this be?  If I have a 5v supply and a 4 ohm impedance, how can the output, according to these graphs, be either 2.75W or 2.25W?

And why is it these values are so low compared with what ohms law seems to say the power should be for 5v flowing through 4 ohms of impedance?

To keep it simple you are comparing a DC power calculation to a AC (audio is a ac signal) power calculation. As the total supply voltage avalible is only 5vdc, the theoretical maximum audio power available where the whole peak to peak waveform can 'fit' within a 5vdc limit is: 5vpp = 2.5v peak = 1.767 volts RMS, and then audio watts would be (ExE)/R or (1.767X1.767)/4 ohms = 3.12 watts rms. As the chip's amplifier is not 100% efficient the 2.75 watt figure says it's running at 88% efficiency, not bad at all.

Lefty
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: scswift on Mar 11, 2012, 10:29 pm
Quote

To keep it simple you are comparing a DC power calculation to a AC (audio is a ac signal) power calculation. As the total supply voltage avalible is only 5vdc, the theoretical maximum audio power available where the whole peak to peak waveform can 'fit' within a 5vdc limit is: 5vpp = 2.5v peak = 1.767 volts RMS

I looked up RMS on Wikipedia and I found the following on it:
http://en.wikipedia.org/wiki/Root_mean_square
http://en.wikipedia.org/wiki/Amplitude

So what you're saying is if I input 0..5v into the amplifier it outputs -2.5..2.5v
And to calculate the power I need to calculate the RMS amplitude.  So I take the amplitude which is 2.5v, and I divide that by sqrt(2) which is 1.414, and I get 1.768v for my RMS amplitude.

Quote
and then audio watts would be (ExE)/R or (1.767X1.767)/4 ohms = 3.12 watts rms. As the chip's amplifier is not 100% efficient the 2.75 watt figure says it's running at 88% efficiency, not bad at all.

You lost me.

1.76^2 / 4 = 0.78146

I can't figure out how you got from there to 3.12 watts rms.  And if you made a mistake and the .78W figure is correct, why isn't that anywhere near the quoted 2.75W?

Hm...

3.12 * 4 = 12.48 and the sqrt of that is 3.53, and half that is 1.76...  So it looks like you did (1.76*2) ^ 2 / 4  = 3.12, but I don't know if that was a mistake or not, and if not, why you multiplied by 2, unless you're doubling the RMS amplitude because you need to account for both halves of the waveform?
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: retrolefty on Mar 11, 2012, 10:57 pm
I did rather mess that calc up didn't I.  :smiley-red:

And I can't explain their higher claimed audio power output when the chip is limited to DC power rails of +5vdc and 0vdc. I guess I will have to read the datasheet more careful to see what kind of magic they came up with.

Later:

Ok it's solved, that chip is using a full differential output stage, in effect it is two amplifiers 180 degrees out of phase driving the speaker load between their two outputs, so they can get double the power output that a single stage linear amp stage could wiring the speaker from output to ground. So the theoretical maximum audio output power would use the 5vdc as the peak value (not 2.5v peak) which equals 3.53 volts RMS which equals 3.12 watts into a 4 ohm load. This is again the 100% efficiency figure that the actual chip cannot meet or exceed.

Figure 33 of the datasheet shows this differential output stage with waveforms that should make it more clear how this magic is performed.

Lefty

Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: scswift on Mar 12, 2012, 04:45 pm
Okay, that all seems like it makes sense.  Thanks for that.

The only thing I'm wondering about now is that graph on page 5 which shows two different power levels based on the total harmonic distortion.  What's up with that?  Does that have to do with how much noise is getting into the amp or what?  Is it something I can control to keep it at 1%?
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: Grumpy_Mike on Mar 12, 2012, 05:02 pm
Quote
Does that have to do with how much noise is getting into the amp or what?

No, total harmonic distortion is a property of the waveform you are trying to amplify.
A pure sin wave has no distortion in it. This is of course impossible but it gives the lowest power output because the RMS calculation gives a direct power equivalent output to a DC power of the same value.
Try and think of it as a base level where the RMS voltage to peak voltage relationship you learned about earlier holds.
As the wave shape gets more distorted more energy is fed into the load and at a point of 100% distortion you will output the DC power levels you first calculated and were surprised did not match the data sheet.
For power calculation purposes it is assumed you have a pure undistorted sin wave at one frequency. As the wave gets more complex, it has more harmonics and pushes up the average power.
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: scswift on Mar 12, 2012, 05:13 pm
So are you saying that if I output a square wave, that would be the worst case?

Furthermore, are you saying that at 5v with a 4ohm speaker, if I output a square wave then I will in fact be outputting 6.25W and 1.25A as I originally calculated?
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: retrolefty on Mar 12, 2012, 05:37 pm
An amplifier's total output harmonic distortion is just a measurement of how much an amplifiers output deviates from the original input signal's waveform. That is how much distortion does the amplifier add to the input signal. No linear amplifier is perfect, reality has yet to come up with the long sought after 'wire with gain'. If you drive an amp too close to it's power rails or cause more then it's current capacity can supply the output waveform (say by trying to drive a speaker with too low an impedance value) will deviate from the input waveform, thus increasing it's output distortion value. It's all a trade-off that the designer has to deal with.

That datasheet gives two operating conditions that they user can decide to operate at, 1% or 10% distortion. Hi-Fi amplifiers were typically those that would add no more then .1% total distortion or less, often way less.

Passing a square wave through a audio linear amp is one method to test it's upper linear frequency response as a square wave is a fundamental sine wave plus all it's odd harmonics and as the amplifier does have a specific upper and lower frequency limit the output waveform will deviate from a true square wave at some input frequency. Max power output, max total harmonic distortion, and flat frequency response are interrelated 'goodness' rating for any specific amplifier.

Quote
Furthermore, are you saying that at 5v with a 4ohm speaker, if I output a square wave then I will in fact be outputting 6.25W and 1.25A as I originally calculated?

In theory only. In reality the output transistors in the amp won't allow the full +5vdc to pass through to the speaker, there is always some losses. But even though closer to '6.25' watts those wouldn't be sine-wave watts which is what audio power ratings are specified at, but rather some kind of 'peak' power watts, and then you would be comparing apples to oranges.

Lefty

Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: Grumpy_Mike on Mar 12, 2012, 05:50 pm
Quote
So are you saying that if I output a square wave, that would be the worst case?

No there are plenty of waveforms with more harmonics in them than a square wave.

A square wave only contains odd harmonics with a value of the reciprocal of the harmonic number. That is 1/3 of the 3rd harmonic plus 1/5 of the fifth harmonic plus 1/7 of the seventh harmonic and so on up to infinity. So lots of harmonics missing and the power of the higher ones are quite low.

The worst case waveform would be white noise over the full bandwidth of the amplifier, but that is not very helpful as you don't want to listen to that.

In audio there are lots of different measures of power:-
http://en.wikipedia.org/wiki/Audio_power (http://en.wikipedia.org/wiki/Audio_power)
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: scswift on Mar 12, 2012, 06:26 pm
Quote
That datasheet gives two operating conditions that they user can decide to operate at, 1% or 10% distortion. Hi-Fi amplifiers were typically those that would add no more then .1% total distortion or less, often way less.

Okay, but how does one "decide" to operate at a specific level of distrotion?  There are two levels listed for the same input voltage and the output power.  There must be another variable by which you adjust this.

Also, I do want to understand how all this works, but the main thing I'm really concerned about is whether or not supplying 5v into the amp is going to blow a speaker like this:

It says its rated for 2W, max 2.5W, but that graph with the 2.75W at THD 10% concerns me.  And I am even more concerned now that it sounds like you guys are saying the power rating is for a best case of a sine wave, and that even more power will be output if something like a square wave or, worst of all, white noise, is played.

My concerns are probably unfounded, but if the amp will actually be putting out 2.5W into a 4 ohm speaker, I'd like to know.  That could be both good and bad.  I mean more power = more volume, but not if it'll end up blowing most small speakers.

Also, I know there will be some voltage drop on that dac and the amp with my filtering.  I dunno how much yet though.  But I'm guessing it will probably drop the output from 2.75W to 2.5W or less.  Still, wondering what the worst case here is.
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: retrolefty on Mar 12, 2012, 06:38 pm
Quote
My concerns are probably unfounded, but if the amp will actually be putting out 2.5W into a 4 ohm speaker, I'd like to know.  That could be both good and bad.  I mean more power = more volume, but not if it'll end up blowing most small speakers.

I think you are making too much of it and over thinking the whole 'problem'. You know most amplifier designs deal with this by installing a volume control for the input signal such that the user can adjust the maximum power output of the amp. You haven't mentioned what kind of signals you are trying to amplify, music, sine-waves, square-waves, noise, etc? You can in your code have a means to scale the output signal range that will be supplied to the amp or wire a simple pot to the input of the amp and adjust it to 50% to start with and increase it only if needed. I suspect that the speaker you have selected will work fine with that amp.

Lefty
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: scswift on Mar 12, 2012, 06:58 pm
Yeah, I know I can allow the user to adjust the volume, but I also know the kind of folks who'll be using this, and they'll do things like max out the volume and connect 4 ohm speakers in series thinking two speakers will be louder than one.  Or worse yet connect them in parallel across their 7w amp rated for 4 ohm speakers and either blow the amp or overheat it or cause distortion, I'm not really sure which.

I just don't want them to either blow their speaker or think it sounds crappy and blame it on me. :-)  And if they do blame it on me I want to understand what's going on well enough to explain to them why it's not working the way they want it to.
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: retrolefty on Mar 12, 2012, 07:08 pm

Yeah, I know I can allow the user to adjust the volume, but I also know the kind of folks who'll be using this, and they'll do things like max out the volume and connect 4 ohm speakers in series thinking two speakers will be louder than one.  Or worse yet connect them in parallel across their 7w amp rated for 4 ohm speakers and either blow the amp or overheat it or cause distortion, I'm not really sure which.

I just don't want them to either blow their speaker or think it sounds crappy and blame it on me. :-)  And if they do blame it on me I want to understand what's going on well enough to explain to them why it's not working the way they want it to.

So what again do you require from us? There is no guaranteed protection from malicious or ignorant users and protecting your reputation is probably not something we are qualified at.  ;)
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: scswift on Mar 12, 2012, 07:26 pm
Heh. :-)

I just want to understand what's going on in the circuit.  A friend of mine has one of those 7W amps that he has two 4 ohm speakers connected in series.  When he cranks the volume up, the sound becomes all distorted.  I don't want that to happen with my circuit and I want to understand what's going wrong with his so I can help him correct it.  I've told him to try hooking up just one speaker if he wants more volume, but not to connect two in parallel out of concern for damaging his amp with a 2 ohm load.  But beyond this advice, even with all I've learned about amps while designing this circuit I'm still at a loss to explain the issue he's having with distortion.  He's certainly not exceeding the wattage rating of the speakers he's using; they're pretty nice ones.

He's using this amp btw:
http://www.canakit.com/5w-audio-amplifier-kit-ck153-uk153.html
http://www.unisonic.com.tw/datasheet/TDA2003.pdf

Witha a 12v supply.  4 ohm speakers, and this sound chip is providing the input:
http://www.elechouse.com/elechouse/images/product/MP3%20WT588D%20USB%20module/WT588D%20CHIP&MODULE%20DETAILED%20INFORMATION.pdf

If I understood why he (and almost everyone else using this setup) was having problems I'd feel a lot more confident that people won't have problems with my setup.  My best guess right now is that the sound chip has a PWM output and that's messing with the amp.  Some have tried adding a low pass filter between the sound chip and amp though and one some have met with success using this.
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: retrolefty on Mar 12, 2012, 07:38 pm
Well good luck with your project (I mean it). I've passed on about all the wisdom I can spare for now.  ;)

Lefty
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: scswift on Mar 12, 2012, 07:45 pm
And thanks again for your help; you've gotten me to where I'm 99% sure this will work.  It's just that 1% that nags at me. :-)
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: Grumpy_Mike on Mar 12, 2012, 07:53 pm
Quote
but how does one "decide" to operate at a specific level of distrotion?

You don't it is a function of what signal you put into it. You put in a signal that has a 1% total harmonic distortion then that is the power curve you get. If you put in one with 10% then you get the other curve. If you put in a signal with 20% THD then they are not saying what power you will get.

Just because a speaker is running at less than its rated power does not mean it will not distort. The same goes for amplifiers.
To find out the cause of the distortion look at the signal with an oscilloscope, if the signal is not distorted but the sound is then it is your speaker.
Remember those circuits in the data sheets are just starting points for a practical design not a finished design. Supply decoupling is important as well as filtering and correct capacitor type selection.
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: retrolefty on Mar 12, 2012, 10:12 pm

Quote
but how does one "decide" to operate at a specific level of distrotion?

You don't it is a function of what signal you put into it. You put in a signal that has a 1% total harmonic distortion then that is the power curve you get. If you put in one with 10% then you get the other curve. If you put in a signal with 20% THD then they are not saying what power you will get.

I don't think that is correct. It is stating two operating conditions that would allow the amplifier itself to ADD
up to that amount of distortion to the signal. Amplifier stages do add distortion, how much is a function of the device linearity and how they are operating on their load lines. Overdrive an amplifier and the amp itself will be the source/creator of the distortion. An amplifiers distortion specification has nothing to do with how much or little distortion is on the input signal. An amps distortion spec is based on only the distortion added by the amplifier.

Lefty

Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: Grumpy_Mike on Mar 12, 2012, 11:17 pm
Quote
An amplifiers distortion specification has nothing to do with how much or little distortion is on the input signal. An amps distortion spec is based on only the distortion added by the amplifier.
Yes I don't disagree with that.
But the point is that the more distortion is on a signal, however it got there, changes the power output of the system.
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: retrolefty on Mar 12, 2012, 11:24 pm

Quote
An amplifiers distortion specification has nothing to do with how much or little distortion is on the input signal. An amps distortion spec is based on only the distortion added by the amplifier.
Yes I don't disagree with that.
But the point is that the more distortion is on a signal, however it got there, changes the power output of the system.

No I don't see that either. Power output and distortion output are two separate measurements dealing with different attributes of a audio output signal. Distortion is simply the deviation of output signal relative to input signal (minus gain). Power output is simply the product of voltage and current of the output signal. Specifying power at a maximum allowed distortion value is just a truth in advertisement method so one can make sure they are comparing apples to apples for two different manufactures power claims.

Lefty
Title: Re: Having difficulty understanding power when dealing with speakers/amps.
Post by: scswift on Mar 13, 2012, 01:07 am
Apparently I don't need to be concerned about someone blowing the amp by using a speaker with too low of an impedance:
http://e2e.ti.com/support/amplifiers/audio_amplifiers/f/6/t/112003.aspx#396690

Of course there is still the possibility of the amp blowing a small speaker, but I have to assume most small speakers you'll find can handle at least 5v at whatever their impedance is.