Does anyone on here know if the capacitor-resistor combo attached to a pwm output pin of an Arduino gives a decent analog output?
@MLE_online depends on the purpose... If you want is to be smooth it cant change fast.
@RueNahcMohr how fast or slow?

@MLE_online

Start with the R C time being 10X the frequency. You can't really get all the bumps out without turning it into DC.

How good does it need to be? What's the application?

R C time is microfarads times megohms. for time in seconds. Rule of thumb.

@RueNahcMohr

@MLE_online @RueNahcMohr what arduino do you have? They have different PWM speeds. And what is your acceptable ripple in your output?

Slowest pwm is 490hz. If you filter that with a 1k resistor and a 10uf capacitor, that’s a cutoff of about 16hz. So you could have a control signal of about that. It would have a ripple of about [edit: 0.25] volts on the output

Edit: I accidentally ran the calculation at the wrong PWM speed. The slower speed gives you .25 volts ripple, the faster gives you 0.12v

@MLE_online @RueNahcMohr additional info: you can software bit bang a faster pwm, there are arduino libraries

Also, you can use this calculator for PWM. It has been around for decades and I use it all of the time. Just plug in the pwm frequency, and the resistor and capacitor values and it will come back with cutoff frequency, and output ripple, and even graph it over time

http://sim.okawa-denshi.jp/en/PWMtool.php

(Sample)RC Low-pass Filter Design for PWM - Result -

@MLE_online thats set by the RC combination you use. Are you gonna tell what you want to use it for?

@RueNahcMohr @MLE_online

If the pwm is at 100kHz and you are trying to generate a sub 100hz tone, it might be fine. If you want full bandwidth audio to 20kHz, nope.
https://www.allaboutcircuits.com/technical-articles/low-pass-filter-a-pwm-signal-into-an-analog-voltage/

@poleguy @MLE_online

additionally, if you need steady more than resolution, an R-2R DAC is easy to make.