# PWM to Analog Voltage

#### Miramax

Joined Nov 12, 2006
22
I am looking to convert a PWM signal to to analog voltage to drive a LED 10 segment bar graph.
I found this handy number here http://www.ontrak.net/pwm.htm and it looks pretty easy, its a low-pass RC filter made with a resistor and cap.
I want to drive a LM3914 and 10 led bar graph with the analog voltage to indicate what the duty cycle is. 0 leds lit = 0% duty ~ 10 leds lit = 100% duty.
If the PWM is at 1KHz, what size resistor and cap is needed?
Sorry for the noobishness, I've been learning tons from you guys so far
Thanks again

#### bertus

Joined Apr 5, 2008
21,653
Hello,

You could make a lowpass filter that has a 10 - 20 times lower frequency as the PWM signal.
So a filter between 50 Hz and 100 Hz will work for the 1KHz PWM.

Greetings,
Bertus

#### Miramax

Joined Nov 12, 2006
22
How would one go about doing this? Same circuit just different values for the cap and resistor right?
I need to do some more studding

#### thatoneguy

Joined Feb 19, 2009
6,359
The standard Value of 22uF, replacing the 1uF, and a 47 Ohm resistor in place of the 4.7k would give around a 150Hz Lowpass Cutoff in the circuit posted above. 100 Ohm would move it down to around 100Hz.

#### SgtWookie

Joined Jul 17, 2007
22,221
The standard Value of 22uF, replacing the 1uF, and a 47 Ohm resistor in place of the 4.7k would give around a 150Hz Lowpass Cutoff in the circuit posted above. 100 Ohm would move it down to around 100Hz.
Not so good; that'll result in high current in the resistor to charge/discharge the capacitor, and high current in the output of the device.

Go fish.

Change the cap back to 1uF (or smaller) and increase the resistance.
[eta]
The existing circuit has a low-pass of around 30Hz. If you just decreased the 4.7k resistor to somewhere between 1.5k and 2k, you'll be in the ballpark of where you want to be.

Last edited:

#### thatoneguy

Joined Feb 19, 2009
6,359
My apologies, I forgot the application. I was thinking "output"/low impedance.

Sarge is up about 3 on me now.

#### SgtWookie

Joined Jul 17, 2007
22,221
My apologies, I forgot the application. I was thinking "output"/low impedance.

Sarge is up about 3 on me now.
I've pulled more than my share of doozies on here.

Yes, if our OP was looking to drive a speaker or something, then they'd need a low impedance output. But when driven by a microcontroller, keeping the uC's I/O limits in mind has to be a pretty high priority.

a 1.5k resistor will give a max source/sink current of around 3.33mA; easy for it to handle even with many other I/O loads.

#### Miramax

Joined Nov 12, 2006
22

#### italo

Joined Nov 20, 2005
205
if you bother to go to MAXIM.com they have all kinds of chips to drive LED. I just got two free samples to try it.