Better understanding of filter/values for (best) audio output?

I am making another stab at trying to understand low-pass filters/audio stuff....

instead of just following schematics, or copying other open source schematics or .brd file..etc....

I have blindly changed values while testing, but it was a true understanding...

I'd like to get a better understanding (IN LAYMEN TERMS) of if raising/lowering this resistor 'here'.. it does/effects this in the output..etc..

(not looking for long big equations or long articles on who invested what and how to calculate things... yet!) :wink:

I have a project, SMD board, that I removed some of components and soldered in wires with female, dupont connectors on the other end... so I can easily swap out components/values and test things out..

Here is a snippet of the schematic that applies to the DAC >> AMP >> SPEAKER outputn..

the components circles in RED and the components I can change for testing.. and what the current values I am testing with are..

the components in BLUE are another filter on the back-end... but I havent messed with them ever.. (but can/will if it means getting the best audio I can from this project)

R5/R6 I have a POT wired in so I can dial to whatever.. then measure it and use hard valued resistors...

right now I am getting 'decent' audio.. its not bad... but I 'feel' it could be better with a true understanding instead of randomly messing about.. :slight_smile:

GOAL:

  • best quality and volume I can achieve (fought with volume, muted/muffled sounds, no lows, no highs)
  • best filtering for external NOISE (forward thinking about still being able to use my board to PWM leds..so filtering for outside/external noise from leds or something, heard through audio/speaker)

*NOTE: using hobby speakers, un-powered, 1-2watt / 8 Ohm speakers

(clean version)

bump..

and just talking it out I guess..

so.....

R8 & C18 = LOW PASS FILTER

C21 & R6 = HIGH PASS FILTER

(R5 is added in for volume control/setting)

what part is R7 & C15 playing in this schematic then? another filter on the output..yes? confused on how much IMPACT these have on the overall results/audio output?

same question for C17? seems to be a coupling cap? (I'll have to look up what PIN6 is on the LM386 amp datasheet off the top off my head I dont recall..:stuck_out_tongue: )

talking to someone else, they mentioned: corner frequency etc..

which I didnt understand though?

thanks for any advice/feddback/discussion.. :slight_smile:

Attach the schematics as .pngs or .jpgs, I can't see them as links or whatever you used.
(Reply, Additional Options, browse to your locally stored file).

sorry..

I used the IMG tags supplied by the tool bar.. (not sure why not working? maybe too big?)

anyways.. you are familiar with this schematic....

I just want to come back to it, finally, and work on understanding the filter stuff better..

as mentioned, I have fooled around with some of the values.. and have a decent sound out of it..

but with TRUE understanding, I think it can be better, already is better than stock Waveshield IMHO..

R8 & C18 = LOW PASS FILTER - [blocks high freqs, allows lows through]

C21 & R6 = HIGH PASS FILTER - [blocks low freqs, allows highs through...also has R5 as voltage divider for volume..currently pot in place for testing, removed, and metered values]

regurgitating info elsewhere..

corner frequency (f=1/(2piR*C)

not sure HOW to add int eh values fr R & C though?

was told I get 1.59khz which is kaka.. less than phone with is 3.4khz..etc.

(most of the equation and corner freq stuff went over my head...whoosh) haha..

my goal here is improve this for sound quality and better/best PWM noise blocking as I can get

(some other suggestions on the PWM noise was to run PWM at diff freq, but not sure how that is even approached... one step at a time I guess) :slight_smile:

discussion, probably totally wrong.. but.

ok.. so for LOW PASS FILTER: R8 & C18

R8: is I INCREASE value of the resistor. it cuts of the HIGHER freq the higher I go in R value...correct?
what purpose/function does the CAP play then? going lower/higher?

Is there a rule/relationship between R8 & C21 values? (ie: the higher R8 is the lower C21 should be? or vice versa?)

Not sure if R7, C15 & C17 even have a part in all this? and should be equally changed out, tweaked for best/better performance?

thanks!

amp_values1[1].jpg

amp_values[1].jpg

(not working because whatever they were is blocked for me)

R8/C18 are low pass filter to block high frequency switching noise from the DAC output.

C21 lets 0-5V signal settle at the level set by R5/R6. You could make it bigger so it lets more signal thru, like a 10uF, 47uF.
R5/R6 are a voltage divider to bring the signal level down so the gain of 20 in the LM386 does not create a clipped signal.
C15/R7 provide LM386 gain stability or something like that per its datasheet.

If you want better sound quality, you can try making a 2nd order lowpass filter vs 1st order, and increasing the DAC loading frequency. (its not PWM)

thanks Crossroads-

I'll try a higher C21 value

I still have some of the questions from the previous post.. :slight_smile:

R8: if I INCREASE value of the resistor. it cuts of the HIGHER freq, the higher I go in R value...correct?
what purpose/function does the CAP play then? going lower/higher?

I understand that R8 and C18 are the 'low pass filter', trying to grasp the purpose/function of each part in that combo..

values:
low R / low C
low R / high C
high R / high C
etc..etc..

Also what do you mean by this:

...You could make it bigger so it lets more signal thru...

do you mean as in more 'volume'?

(maybe Im getting to old for this? LOL.. I have such a hard time with audio and DAC's & amp's..etc)

as usual, your experience is appreciated..

thanks!

Yes, bigger, more signal. At that point not much current is flowing, so it may not make much dfference.
R8/C18 make the low pass filter.
http://sim.okawa-denshi.jp/en/CRlowkeisan.htm
The resister limits the amount of current that can charge up the cap when voltage is rising, the cap discharges as the voltage drops. The cutoff frequency is 1/(2PiR*C) which is the frequency where the output will be 1/2 the input.

so if it playing 22k files.. I should be using/at 11k for the filter? (half?) :fearful: :blush:

I go the link...and use the calc...

putting the values I am using now 10k/10nF

I get this as result:

Cut-off frequency
fc = 1591.54943092[Hz]

but Im not sure what my target number is that Im shooting for?

do I divide that number or something, its in Hz?

thanks...

AFAICT the whole circuit around the opamps is an active filter, possibly a Sallen-Key or some such.

Alas there are no layman's terms for how such an active filter works, at the very least you
need to speak complex impedances and poles/zeroes. Monkeying around with individual
resistor/capacitor values isn't very useful in such a circuit, you look up the component
values in a table and go with it.

[ for instance such active filters can resonate or even oscillate, something a filter made just from
R C elements cannot do ]

You can change all of the capacitors by the same ratio to move the cut-off frequency, ditto
the resistors.

whooosh!... haha..

thanks for the reply though..

I'll have to read it a few times.. to see if I can get some direction from it..

(not sure what kind of table you are referring to? that i can look up components and get values from?)

First, there's no opamp - the LM386 is a selfcontained amplifier, the values connected around are to an AC signal in, to reduce the gain of the DAC, to set the LM386 gain at 20, and to stabilize the output per the LM386 datasheet.
The only filtering is the lowpass filter out of the DAC. The Ac coupling does induce some filtering.

If the DAC is being updated at 22K, then yes, filtering should be set to <=11KHz.

thanks..

yes.. the files are 22K audio files.

so using your link: RC Low-pass Filter Design Tool

want to make sure Im doing this correct...

I entered in: (current values)

10K (R8) & 10nF (C18)

calculate...

I get this:

Cut-off frequency
fc = 1591.54943092[Hz]

to convert this to kHz..

I need to:
f(kHz) = f(Hz) / 1000

and I get this: (1591.54943092 / 1000) =

1.59154943092 kHz

is that right???

that seems a FAR (far) cry from the 11kHz I am targeting....yes?

if I go DOWN on the R8.. it makes the value higher.. (but then Im letting in more high sounds.. especially @ under the 1k value (which is what I'll have to do/use)

I have input:

R8 = 1.4K
C18 = 20nF

Cut-off frequency
fc = 11368.2102208[Hz]

which equals: 11.3682102208 kHz

correct so far?

still not fully understanding..

I dont want to be so LOW @ R8 that it lets in through high freq that make things have NOISE or junk through the speaker..

how do you know what value/threshold for R8 is TOO low to be of any value in the circuit?

(I think I had originally had 100 Ohm value in there.. didnt do any good/told hardly filtering anything out....etc)

I mean what would be the difference/better result..

R8 = 1.4K
C18 = 10nF

or

R8 = 2.8k
C18 = 5nF

both seem to give me the same Cut-off frequency:

fc = 11368.2102208[Hz] (11.3682102208 kHz)

R8 lets the current into C18..

R8 lets low freq pass..while blocking hi freq based on value.. (higher the value the more hi freq it blocks)??

is there a 'rule of thumb' here?

ie: never used less than 1K for R.. as thats lower than any human can hear...etc??

or something? lol

thanks!

CrossRoads:
First, there's no opamp - the LM386 is a selfcontained amplifier, the values connected around are to an AC signal in, to reduce the gain of the DAC, to set the LM386 gain at 20, and to stabilize the output per the LM386 datasheet.

Ah, missed that ground signal (with no ground symbol...). Not the clearest diagram in the world.

You are correct xl97 - up to you to decide if the sound quality is what you want.
Make yourself a simple excel spreadsheet to select different resistor values, find a frequency that satisfies your ear.

R8 = 1.4K
C18 = 10nF

or

R8 = 2.8k
C18 = 5nF

1/(2PiR*C) , if you double R & half C, the math cancels out. So leave C alone at 10nF, play with R.
Use a 2K or a 5K trim pot, play with it till it sounds good, measure R and put in that value.

swapped C21 out for a 10uF cap... (you were probably right.. as I didnt notice any? difference)

I left C18 alone at 10nF

adjusted R8 from:

10K
4.7K
3.3K
2.2K
1K

and played some .wav files..

I didnt notice much difference between the 3.3K and the 1K really..

however the audio is MUCH better, loud a bit more range/tone.. than when using the 10k!

I guess I'll stick to those values for now..

couple things Id like to ask/discuss.... not sure if this sort of stuff can be solved by simple value switching on some components already in place...

1.) I can 'hear' the speaker when it powers on.. a 'click' (per se`) when the board is powered..
2.) when no audio is being played.. I can 'hear' that the speaker has power.. normal? its not too loud where I can hear from far out..
3.) I have -not- tried to PWM any leds while playing any audio files.. previously.. I could HEAR the the 'stepping/fading' of the PWM through the speaker.. as noise/static/squealing/whining..etc..
(best I can describe it)

I have heard about 'using a diff freq to PWM at, as a solution (but no clue how practical that is or how to go about it anyways)
I have been told 'need to separate' the analog and digital lines...etc.. (but not exactly clear on that one either.. make sure any coupling caps on the along pins.. dont couple to gnd along with any digital pins?) that must be for when getting NEW pcb's though? not a fix for current ones..etc........right?

thanks!

Corner frequency comes from Bode Plots, you can ignore the equations and just look at
the graphs. Also, to tell what your ckt is doing, you should plot out the Bode Plot for your
amp, ie measure Gain vs Frequency.

The one formula you have is useful - ONLY because the low-pass and high-pass frequencies
are 100X apart, so you can use the formula for both cases [ie, each cap separately] with
little effect from the other cap.

corner frequency (f=1/(2piR*C)

For low-pass, R = R8 || (R5+R6) = 5K, and C = 10nF.
For high-pass, R = R8+R5+R6 = 20K, and C = 1uF,

so Flo = 8 hz, and Fhi = 3185 hz.

Your gain in the "mid-band" = R6 / (R8+R5+R6) = 0.1, so you're losing most of your
signal right there.

AFAICT, the purpose of R7 & C15 is to prevent high-frequency oscillations in the LM386
at high-gains, as the corner frequency for that network is very high = 318 Khz.

whoosh!.. hahaha..

can you 'dumb it up' a bit?

appreciate the response.. just wish I could use it better..

apply it to my project/problems..

what is the || (pipe) in your equation for? I usually default that to be an OR operand?

For low-pass, R = R8 || (R5+R6) = 5K, and C = 10nF.
For high-pass, R = R8+R5+R6 = 20K, and C = 1uF,

the NEW values (not sure if you read the thread? or using first post/image only now?)

R8 = 1.4k (using a 2k for the moment..but using the calculator link.. it says R8=1.4k & C18 = 10nF to give me around the 11kHz cut-off...

I also am not following this:

Your gain in the "mid-band" = R6 / (R8+R5+R6) = 0.1, so you're losing most of your
signal right there.

R6 / (R8+R5+R6)

2k / (2k+8k+2k) = 0.1666...

thought this 'WAS' correct now? going in the right direction?

(sorry Im just getting more confused) haha..

I used your original values. "||" = parallel combination, standard electronics terminology.

I did dumb it down, just did the calcs and no theory. You cannot understand why you
should use R = R8 || (R5+R6), etc, unless you understand a fair amount of theory. The
equivalent R values are as I indicated, you cannot use just one Rx in the corner freq eqn.
All 3 Rs factor into both corner frequencies. Ask dc42.

When you swap out values and say "as I didnt notice any? difference", you won't unless
you do a complete Bode Plot, as I indicated.

If you provide a list of all of your final value, Rx = ..., Cx = ..., etc, I'll recalculate the
corner frequencies.

(reading the Bode Plot link after the boss leaves! lol)

ahh.. "parallel" (got it!)..

my current values are as follows:

(image if location reference only)

http://forum.arduino.cc/index.php?action=dlattach;topic=171578.0;attach=46278;image

R8 = 2.2k (although my target value was 1.4k.... I also used a 1K value in place as well)
C18 = 10nF
C21 = 1uF
R5 = 8k
R6 = 2k

xl97:
R8 = 2.2k (although my target value was 1.4k.... I also used a 1K value in place as well)
C18 = 10nF
C21 = 1uF
R5 = 8k
R6 = 2k

For low-pass, R = R8 || (R5+R6) = 1.8K, and C = C18 = 10nF.
For high-pass, R = R8+R5+R6 = 12.2K, and C = C21 = 1uF,
so Fhi-pass = 13 hz, and Flow-pass = 8846 hz.

Your gain in the "mid-band" = R6 / (R8+R5+R6) = 2K/12.2K = 0.16, so you're "still" losing most
of your signal right there.

I would think you'd do better with the previous low-pass freq, since it's purpose is
filter out the hi-freq transitions on the DAC output.