Best RC values for converting Arduino Uno PWM output to Analog

Helloo people!!

I hope you are doing great! I just firstwanted to express my thanks for such a wonderful forum this is!! :slight_smile:

I have a very simple question ... I am generating analog voltage (0-5V) from the PWM output (frequency 1Khz - pin 9)..

Therefore I am looking for a method to calculate the best R & C values for my first order low pass filter (RC) to smooth the PWM output..

Can anybody please share their ideas to make me understand better and solve this issue?

I sincerely appreciate your support!

Warmest Regards

Pramit

It really depends on what you are doing with the analogue output and how fast you want to be able to change it. How much ripple can you stand on the output? What are you driving?

The default PWM frequency is about 500 Hz or 1000 Hz depending on which analog pin you use.

The cut-off frequency of a simple RC low pass filter is given by:

f = 1/2PiR*C

A signal at that frequency will be attenuated by 3 dB and the attenuation increases by 6 dB for every doubling of frequency above that ( O.K. it's a bit more complicated than that but that's good enough for now).

There's a simple calculator that can do the sums for you here

Russell.

To be more clear, that is f = 1/(2PiR*C) and for a start, that frequency should be 1/10th the PWM frequency or lower.