Low pass filter connected to PWM not outputting correct value

Hello,

I have attached a low pass filter consisting 1MOhm resistor and 100nF capacitor to pin D13 on my Arduino Mega. Using Matlab I told Arduino to output 2.5V to pin D13( writePWMVoltage(a,'D13',2.5) ). So I thought measuring the voltage across the capacitor will give me smooth 2.5V however both my DMM and Analog read of Arduino are reading me ~2.1V. Why is that?

This might be a dumb question but I could not search answer for my situation
so I gave a go :slight_smile:

Thanks in advance.

I told Arduino to output 2.5V to pin D13( writePWMVoltage(a,'D13',2.5) )

And will that work? What actual value are you sending to D13?

Also 1M is a bit high, approaching the value of the input impedance of your meter. Plus check the 5V rail of your computer, what is it?

The filter is off. Your cutoff is about 1.6 Hz. You need higher cutoff freq for PWM. Try again but set cutoff about 1 kHz.

I think I understand what youโ€™re trying to do. Filter the PWM to output a steady DC. Interesting. Play with the filter.

wolframore:
The filter is off. Your cutoff is about 1.6 Hz. You need higher cutoff freq for PWM. Try again but set cutoff about 1 kHz.

This is totally incorrect. It is a low pass filter the break frequency only affects the speed that the voltage can be changed, not the DC value.

Corner frequency must be low to remove ripple.
But as Mike said, a (10Megohm?) DMM or other circuit connected to a filter loads it, and you end up with a lower voltage.
Especially if you have choosen a very high resistor for your filter.

Try 10k/47uF, and/or buffer the output with an opamp.
Leo..

Grumpy_Mike:
This is totally incorrect. It is a low pass filter the break frequency only affects the speed that the voltage can be changed, not the DC value.

Hey Mike you're right... I didn't get what he was trying to do until after I posted... He's doing 50% PWM to try to output 2.5v after filter. Looks like the filter is dropping voltage.

I checked my 50% duty cycle output (2.5V) and 100% duty cycle output with my (5V) oscilloscope and it is giving me value of 2.48V and 4.96V so Arduino looks fine,

I also tried 100k resistor instead of 1M, and now I am getting ~2.28V at 50% duty cycle

Seems like impedance of the filter was the problem, Now I'm getting 2.48V with 10KOhm 100nF filter. Thanks everyone!

Not sure what you're trying to do, but 10k/100nF is not enough to remove the PWM component.
Try a 10-100uF capacitor.
Leo..

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html.

What will you be using the analog level for?

You may need to add a unity gain buffer to prevent the filter from being loaded down.

Tom... :slight_smile: