right resistance and capacitor for a DAC convertor

Hi all, I just read http://www.avdweb.nl/arduino/hardware-interfacing/super-simple-dac.html and I want to implement it here.
Basically I want better sound than the tone library, possibility to mix 2 notes, play a recorded sample, etc ...

I have 2 problems though:

  • I don't have the 100nF capacitor at home.
  • I'm not sure it would be powerful enough to create sounds on my 8 ohms speaker (used to be an in car speaker).
    I used http://arduino.cc/en/Tutorial/tone successfully and it uses a 100ohm resistor, versus 10k in this DAC page.

As you can guess, I'm not a hardware guy. but I'd really like some advice on possible values of the resistor and capacitor that would play well with my 8 ohm speaker.

Thanks!

Formula is simple: F = 1/ (2PIR*C). F is known, 31.25 kHz, if you are changing C, you also have to change R to keep a balance.
Note: This simple LPF is not any good (absolutely useless) with Tone function, but may be o'k with DDS:
http://interface.khm.de/index.php/lab/experiments/arduino-dds-sinewave-generator/

Thanks magician, but I now struggle with your formula.
I checked it against my example

And it gives 159 for F instead of 31250.
1/(23.1415910 000*0,0000001)=159
What am I doing wrong?

What am I doing wrong?

Nothing wrong, this guy who build a circuits use it for DC, so filter has cut-off freq. 159 Hz, and consequently attenuation at 31250 approx. 20.0 * log10(31250/159) =~ 46 dB
In your case, there is an AC - audio tone instead of DC, so you need a filter with cut-off above upper note. As ratio becomes smaller when you drive your pitch up (31250 / X), attenuation ability for PWM freq. 31250 would deteriorate, and you will have to use more complex filters - 2-nd order, LC, etc., to keep distortion level at minimum

Thanks magician, you're the expert! I was afraid I was several orders of magnitude wrong in using your formula.
I'll go ahead with the formula then

I'll use a 1k resistor, and a 4.7nF capacitor.

Capacitor is marked "DE 472MY2X1" which I think means 4.7nF.

I'll connect the 8 ohm speaker to ground on the Arduino, and on DAC output (my previous graph).

Is it all ok, or I'm going to break something?

It's safe, to increase a loudness you may use R = 5V / 20 mA (max) = 250 OHm, and recalculate a cap of course

I'll connect the 8 ohm speaker to ground on the Arduino, and on DAC output (my previous graph).
Is it all ok, or I'm going to break something?

Well the 10K will stop you damaging anything but a 8R load will ruin the filter effect of the RC filter.

thanks all.
I'll go for 250 ohms and matching capacitor later when I find the matching capacitor.
But for now all I want it to get some sound, then play with mixing multiple sine waves in software, etc ...

Anyway, thanks everyone, and I'll post about the results next weekend

I'll go for 250 ohms and matching capacitor later when I find the matching capacitor.

But connecting it to an 8 ohm speaker will completely destroy any filtering action.

Trying to drive a 8 ohm speaker without some form of audio amplification is just a lost and wasted cause. Separate your filtering requirements from your speaker drive requirements and you might have some success. Even if you were happy just using unfiltered square waves, an arduino digital output pin is just not a good match to drive a 8 ohm speaker.

Lefty