Go Down

Topic: Filtering (Read 2792 times) previous topic - next topic

scswift

As mentioned in another thread, I'm using this amp:
http://www.ti.com/lit/ds/symlink/tpa6211a1.pdf

Coupled with this dac:
http://www.ti.com/lit/ds/symlink/tpa6211a1.pdf

I have a 5v power source.

My goal is to maximize my power output, but I am working under the assumption this speaker will be used:
http://www.pololu.com/catalog/product/1258
http://www.pololu.com/file/download/18mm-speaker.pdf?file_id=0J377

And that's rated for 2W, max of 2.5W, so I don't want to exeed that.

I've been looking at the Audio Shield to see how they filtered the output, as they're using the same dac:
http://www.ladyada.net/make/waveshield/design.html
http://www.ladyada.net/images/wavshield/v11/wave11schem.png

And what I'm looking at right now is the voltage reference for the DAC, on pin 8.

We can see in the schematic above that LadyADA has used a 100K resistor paired with a .1uf capacitor to make a low pass filter with a 15.9hz corner frequency, to filter out noise from the microcontroller.

But as GrumpyMike told me a while back when I first looked at using this DAC, because of the 165K input impedance on the DAC, the resistor here will create a voltage divider, and instead of a 5v reference, I will get more like a 3.1v reference.

The result of which would be that the voltage output to my amp would swing from -3.1v to + 3.1v and that would in turn be output to my speaker because it has a gain of 1, and the result of that would be less wattage to my speaker and lower volume.  And that's not good because I want to maximize my volume.  But I also want to get rid of noise.

So, I looked for a way to change the voltage divider so I wouldn't lose almost 2v to my low pass filter and as GrumpyMike suggested originally, lowering my resistor value would do the trick... but at the cost of more noise. 

Well I think I understand now that the reason for more noise is that if I lowered the 100K to a 10K, my corner frequency on my RC circuit would go up to 159hz.  But I wondered what the effect of changing the capacitor would be.

So, I experimented with these RC filter and voltage divider calculators:
http://www.muzique.com/schem/filter.htm
http://www.raltron.com/cust/tools/voltage_divider.asp

And I found that it was quite easy to see how different values of caps and resistors worked together for my filter, and what different values of resistor would do with my voltage divider.

The end result was I found that, if i wanted a 15.9hz cutoff I could use the following:
.1uf + 100K = 3.1v drop
1uf + 10K = 4.7v drop
10uf + 1K = 4.97v drop

Now, I still haven't done the math for it, but it looks like the filter caps I put on my amp are also going to give me a voltage drop.  So it would probably be best to go with the lowest voltage drop I can on the DAC.

With that in mind, what I'm really wondering is... can I really choose any of those three combinations of capacitors and resistors and get the same result in regards to noise reduction, with varying levels of voltage drop?  Is there any disadvantage to using a 10uf cap and a 1K resistor, aside from a 10uf cap being a little expensive compared to a .1uf cap?

Grumpy_Mike

Quote
can I really choose any of those three combinations of capacitors and resistors and get the same result in regards to noise reduction, with varying levels of voltage drop?

Yes.
Quote
Is there any disadvantage to using a 10uf cap and a 1K resistor, aside from a 10uf cap being a little expensive compared to a .1uf cap?

The only thing is that a 10uF cap has a higher natural corner frequency, that is the frequency at which the capacitive reactance  Xc from the capacitor matches the inductive reactance Xl from the inductance of the capacitor.
But in practical terms you will struggle to notice this.

scswift

Okay, sounds like I'm all set with those then.  Thanks. 

Just gotta figure out what frequencies I want to filter my amp output at now.  I need to set up a band pass filter.  I've been doing some tests in Sound Forge with various sound effects and music and reading up on human hearing.  I don't want to filter out useful frequencies. 

From my research I learned the following:

* We can only hear 20hz-22khz, and adults usually only up to 16khz.
* A 6db drop is equal to a 50% reduction in volume.
* A low or high pass filter's frequency is its corner frequency, which is the frequency where the sound begins to be attenuated
* The attenuation is 6db per octave
* An octave is a doubling or halving of frequency
* So if you have a corner frequency of 22khz, 44khz will be at 50% volume
* At 16khz, it would be 32khz at 50% volume, and  22khz would be around 25% quieter

So if I don't want to attenuate anything below 16khz and don't mind a 25% drop in volume at higher frequencies many people can't hear, then I should choose a 16khz corner frequency for the low pass portion of my  bandpass filter.

And my tests showed that it is actually really easy to hear stuff as low as 20hz so I should set my high pass filter there.

Grumpy_Mike

It is correct if a bit simplistic.

Quote
So if I don't want to attenuate anything below 16khz

While you may be able to hear things at 16KHz these will not be perceived as loud as things at lower frequencies.

Quote
* The attenuation is 6db per octave

Moot point, this is the voltage drop of not the power drop off that is only 3dBs / octave for a first order filter. Each order of filter adds 3dBs per octave to the slope. Active filters are second order filters and using two or more will allow you to make a higher order filter that drops off more rapidly.

In fact there are lots of different filter design that trade ripple in the pass band and stop band for steepness of drop off. Exactly what are you trying to achieve by having a filter?

There is no need to bother with a filter at the low end, it does nothing for you and only adds components and possible extra distortion.

scswift

#4
Mar 12, 2012, 10:30 pm Last Edit: Mar 12, 2012, 10:32 pm by scswift Reason: 1
Quote
Exactly what are you trying to achieve by having a filter?


I'm trying to prevent noise that may be present in my circuit from being audible in my output.  I don't know if there will be any noise that needs to be filtered though, so I'm just going for a general approach and trying to filter anything which is outside that which I know should be in the signal (audible frequencies).


Quote
There is no need to bother with a filter at the low end, it does nothing for you and only adds components and possible extra distortion.


http://www.ti.com/lit/ds/symlink/tpa6211a1.pdf

Page 15, "input capacitor":
Quote
In the single-ended input application, an input capacitor, CI, is required to allow the amplifier to bias the input signal to the proper dc level. In this case, CI and RI form a high-pass filter with the corner frequency defined in Equation 2.  The value of CI is an important consideration. It directly affects the bass (low frequency) performance of the circuit.


I am using a single ended input here.  And according to this, I need Cl, which forms a high pass filter.

I figured for this I would use the same 1K resistor and 10uf capacitor which I plan to use on the DAC's Vref.  This would then filter stuff below 16hz... the opposite of the low pass filter on Vref.


Where the band pass filter comes in is when I would add LPFs in two places. 

The first I thought I should add to filter high frequency noise from the circuit on the speaker output.  If you look at the schematic on page 15 of the above datasheet they show this, and they discuss it on page 16 as step 1 of "band pass filter".

The second is also discussed there.  And at first I wasn't going to include it as it seemed superfluous, but then  I noticed on the audio shield, LadyADA put a low pass filter on the DAC's output:
http://www.ladyada.net/images/wavshield/v11/wave11schem.png

And if you look at that, and then look at the schematic on page 15 of the amp's datasheet again, you'll see that what she's put there is not unlike RaCa, which on page 16 step 3 is listed as a second LPF. 


Now, I don't know if two LPFs are even necessary.  But I also don't know that they're not needed.  And if only one is needed I don't know which one would be better to include.

But that's basically why I was trying to figure out the parameters for a bandpass filter.

Grumpy_Mike

Yes you are defiantly over thinking this.
You are not going to acheave anything by filtering out noise that is outside the audio band.
That filter is known as a reconstruction filter, it's job is to remove the noise introduced by the sampling process. If this is in the audio range this is needed to stop a whine. If it is outside the audio range it is not needed.
That amplifier works by sending pulses to the speaker and uses the inductance of the speaker to work as the reconstruction filter. It is not a conventional amplifier.

scswift

Quote
That amplifier works by sending pulses to the speaker and uses the inductance of the speaker to work as the reconstruction filter. It is not a conventional amplifier.


So wait, are you saying that this amplifier:
http://www.ti.com/lit/ds/symlink/tpa6211a1.pdf

Is not a conventional amplifier?

It sounds like you're saying the amplifier outputs a PWM signal and counts on the speaker to average it out.  But I don't see anything about that in the datasheet, and it says it's a class AB amplifier, which I thought output an analog voltage.

My concern here is what will happen if someone attaches another amplifier to my circuit to amplify it further.  I wanted an analog output because I thought that would have a better chance of working properly than a PWM signal.

scswift

I double checked TI's page:
http://www.ti.com/product/tpa6211a1

While it doesn't specify in the datasheet, it does say right at the top there that it is a class AB amplifier.

And while Wikipedia doesn't seem to specify if class AB uses pulses or not:
http://en.wikipedia.org/wiki/Class_AB_amplifier#Class_B_and_AB

It does specify that class D uses pulses, which leads me to believe that class AB does not.

scswift

#8
Mar 13, 2012, 01:17 am Last Edit: Mar 13, 2012, 03:13 am by scswift Reason: 1
Grumpy,

You say I'm overthinking this.  Perhaps you're right. 

But it is true that I need Cl and Rl on my single ended input, is it not?  Cause according to the datasheet, at the very minimum, I need that high pass filter on the input.

And if a low pass filter on my dac's output is unnecessary, why does the audio shield have one?   

[edit]

I found the explanation for the LPF on the output of the audio shield's DAC:
http://www.ladyada.net/make/waveshield/design.html

Quote
There is another low-pass filter connected to the output of the DAC (R7 and C8). This is for filtering out the 'square wave' component you see in the recreated-audio wave. Even though the noise is only 1/4096'ths of the signal (about 1.2mV) its still noise and these two components filter out anything above 11KHz. The reason the filter cut-off frequency is 11KHz and not 22KHz is that if you sample at 22KHz you will only be able to reproduce frequencies at half that rate, 11KHz. This is the Nyquist theory. It is sneaky but true. If you try to sample 16KHz waveform at 22KHz it will actually sound much -lower-, it will play at 6KHz (it is 'mirrored' around 11KHz)


As I will be using a newer version of the audio shield's library which can play back wavs at 44khz, if that LPF filter really is necessary, it would seem logical to change the cutoff frequency to 16khz or 22khz.

Grumpy_Mike

Quote
So wait, are you saying that this amplifier:
http://www.ti.com/lit/ds/symlink/tpa6211a1.pdf

Is not a conventional amplifier?

Sorry no it is my error. I had been looking at the LM4667 and the data sheets look very similar so I was confusing the two.

This thing about "cut off frequency" is a bit misnomer, it implies that nothing gets through above the cut off. In fact it would be better to call it the roll off frequency. It doesn't even start to drop at that frequency but it is the point where the output has dropped by 3dBs, that is the output is half the input.

scswift

Grumpy,

I understand what you're saying about using the term cut off.  I'll try to use the terms roll off or corner frequency from now on. :-)

The -6db figure I used was the first I found when trying to determine how rapidly it dropped, but you're right, it's -3db.   

I found this page today with some nice tutorials on various filters:
http://www.electronics-tutorials.ws/filter/filter_2.html
 

Quote

That filter is known as a reconstruction filter, it's job is to remove the noise introduced by the sampling process. If this is in the audio range this is needed to stop a whine. If it is outside the audio range it is not needed.
That amplifier works by sending pulses to the speaker and uses the inductance of the speaker to work as the reconstruction filter. It is not a conventional amplifier.


Now that you know this is a class AB amplifier, would you amend this statement?

Also, what are your thoughts on the necessity of the LPF on the output of the DAC on the audio shield?

I don't know if I will be playing back 22khz or 44khz audio files, but I would like to design the circuit on the assumption of the lower sampling rate just to be on the safe side.  How do I know if the stair stepping from the samples might produce an audible whine?

Here's what I've got so far for the layout of the audio portion of my circuit:
http://www.shawnswift.com/arduino/dacamp.png

scswift

Well, I almost screwed up big time.  I was focused on selecting the right frequency for my low pass filter, but I almost failed to notice that the resistor on the low pass input also functions as a voltage divider to set the gain of the amp, and as I want that gain to be 1/1 and the internal resistor is 40K, the external resistor in the low pass filter must be 40K as well!

scswift

Okay, got 40.2K 1/10w 1% resistors and .22uf 10v capacitors on there now.

Grumpy_Mike

Quote
Now that you know this is a class AB amplifier, would you amend this statement?

The first sentence stands the second doesn't.

Quote
How do I know if the stair stepping from the samples might produce an audible whine?

By the sampling frequency, if it is in the audible range then it will need filtering. However if the step from one sample to the next is small the noise energy it contributes to the signal is small. This will depend on the sample rate and the signal you are trying to recreate. Things are worse the closer to the Nyquist your signal is. This is because with only two samples per cycle then the change from one sample to the next is much larger than when you have more cycles in the sample. 

Go Up