# pwm and low pass filter to generate voltage

Hi.

I have a device with 3 states : offline, online and standby. The goal is to get a UNO control this device.

The 3 states are activated/controlled by a small amount of voltage: ≥3.5 V - 1.2 V to 2.9 V - ≤0.8 V.
I make some tests with a CR2032 lithium battery, connected to the device input-control pin, and it works fine for 2 states.
So far I could understand that I can generate theses values from any pwm arduino pin using a Low pass filter.

Question is: what are the corrects value for the resistor and the cap needed. Easy way to get/calculate the right values ?

Hi,

If you need 3 levels and you can spare 2 output pins you could do something like the attached circuit.

Pin 8 and 9 LOW will give you < 0.8V
Pin 8 HIGH and 9 LOW will give you a voltage 1.2 V to 2.9 V set by VR2.
Pin 8 LOW and 9 HIGH will give you a voltage of 5V which is >3.5V.

Just an idea, Tom…

The time-constant of an RC filter is R*C. The cut-off frequency is 1/(2*pi*R*C).

Since the normal PWM setup is 500 or 1000Hz, and you want a cut off frequency at least an order of magnitude lower, lets go to 50Hz cutoff (starts to attentuate from about 50Hz upwards).

Thus f = 1/(6.3*R*C) = 50.

Thus R*C = 3.2e-3, so choose C = 100nF means R = 33k would work.

However this is only part of the story - the device you decline to identify (so I can't progress further) will have an input impedance that will load the output of the RC filter.

Without knowing this impedance there is no way to know is the values above will work, since the device might be 1k, just forming a 34:1 potential divider at DC with the above components, limiting the output to millivolts, or it might be 10^9 ohms, essentially not loading the filter at all...

So provide all the information please...

The Uno's I/O pin internal pull-up resistor can be anything from 20KΩ to 50KΩ. Try connecting a 20KΩ pull-down resistor on one pin, then configure the pin to get:

``````[b]pinMode        Value    Output Voltage[/b]
Output         HIGH       5
INPUT_PULLUP   20K-50K    2.5-1.43
Output         LOW        0
``````

TomGeorge:
Hi,

If you need 3 levels and you can spare 2 output pins you could do something like the attached circuit.

Pin 8 and 9 LOW will give you < 0.8V
Pin 8 HIGH and 9 LOW will give you a voltage 1.2 V to 2.9 V set by VR2.
Pin 8 LOW and 9 HIGH will give you a voltage of 5V which is >3.5V.

Just an idea, Tom…

Hi.

Nice suggestion to bypass hard ( for me ) calcs. Soon a got the pot I will test it.

Thanks a lot to share the schematics.

MarkT: However this is only part of the story - the device you decline to identify (so I can't progress further) will have an input impedance that will load the output of the RC filter.

So provide all the information please...

Hi.

Thanks. The device: it's a small add-on extension card for a customized network device. It's receive just voltage and react switching the network device to off/on/standby. I could read impedance on input pin, 4.5Mohm( so much ??). I can't tell more about the card.. no label, no brand. A metal case and lot of dark epoxy are covering all most of the card, I can see a few smd resistors and caps too, but can't see inside the metal case ( maybe some IC's inside ).

dlloyd: The Uno's I/O pin internal pull-up resistor can be anything from 20KΩ to 50KΩ. Try connecting a 20KΩ pull-down resistor on one pin, then configure the pin to get:

``````[b]pinMode        Value    Output Voltage[/b]
Output         HIGH       5
INPUT_PULLUP   20K-50K    2.5-1.43
Output         LOW        0
``````

Thanks.

Another way to get it. Will test it too.

I couldn’t agree more.

I’m planning on using an Arduino for a UAV auto pilot in combination with a Raspberry Pi and GSM modem for real time data processing and reporting.

They’re both perfect, small, low power devices that will marry well in the future! Thanks, The Cheesy Animation - 3D Interior Rendering

The words Raspberry Pi and real time do not sit very well together. The Linux in the Pi will stop you having a real time anything.