PWM to Analog voltage

Hello everyone,

I have a question regarding PWM to Analog voltage conversion.
Usually one would use a simple RC Filter to convert PWM to 0-5 voltage, but that introduces some voltage ripple.
The situation is that an Arduino is going to be a sensor voltage dataloger in car, ie getting sensor voltages on one side and outputting them on the other side and logging them to the memory.
With reading the sensor voltage everything is ok, they're 0-5v input and i just analogRead() them.
But when i want to output the voltage to the ECU i cant just simply do analogWrite() since it will output in PWM, where as i need 0-5 analog voltage. I'm looking for some transistor that would accept PWM signal and output 0-5 analog voltage without any ripple, just like a car sensor.
So what would be the best transistor to use?

Thank you,
Max.

A transistor will not get rid of the ripple.

How much ripple can your ECU stand?
How quickly must your analogue output respond to changes?

If you know the answers you should be able to design a suitable filter.

Russell.

How about a digital potentiometer?
http://www.mouser.com/ds/2/268/22147a-54123.pdf

russellz:
A transistor will not get rid of the ripple.

How much ripple can your ECU stand?
How quickly must your analogue output respond to changes?

If you know the answers you should be able to design a suitable filter.

Russell.

I dont think the ECU can stand any ripple..
Output should be as fast as on the input side, ie almost no respond time.
Im good at programming but not so good at designing circuits..

Paulcet:
How about a digital potentiometer?
http://www.mouser.com/ds/2/268/22147a-54123.pdf

Digital potentiometer.. That would be an option, maybe..

Basicly i just need the arduino to be able to output 0-5v analog voltage without any ripple, just like a normal car sensor would. Any solutions are welcome :slight_smile:

KeNNy_aKa_MaX:
I dont think the ECU can stand any ripple..

Nonsense. If it can stand noise it can stand ripple of a similar level. Every thing in electronics produces noise. You need to quantify it.

Output should be as fast as on the input side, ie almost no respond time.

How fast is that? Seconds, milliseconds, femtoseconds. Again it needs to be quantified.

Im good at programming but not so good at designing circuits..

I'm good at designing circuits but I've done very little programming since the 1970s.

Digital potentiometer.. That would be an option, maybe..

Maybe, but they only have 7 bit resolution while the PWM output is 10 bit and can be extended. It will give accuracy similar to about 40 mV ripple.

Russell.

russellz:
Nonsense. If it can stand noise it can stand ripple of a similar level. Every thing in electronics produces noise. You need to quantify it.

Ok, so for example lets take the AFM (Air Flow Meter), here is a graph of a perfectly working one:

russellz:
How fast is that? Seconds, milliseconds, femtoseconds. Again it needs to be quantified.

I'd say milliseconds would be enough.

You could go either way. The digipot I posted the datasheet for is less than a $1. There are 10-bit digipots as well. A filter can probably get you the response you need as well.

  • A "slower" filter (a filter with a lower cutoff frequency)

  • A higher [u]PWM frequency[/u]

  • A filter with a sharper cutoff (usually an active filter built with one or more op-amps)

  • Don't use PWM (use a DAC or a digital pot)

The Teensy 3.1, under $20, has a 12 bit DAC that even has its own voltage reference, so the output won't change just because of ripple on the power supply.

It is a 3.3V part, though.

https://www.pjrc.com/teensy/teensy31.html

Even cheaper, a $5 12 bit DAC from Adafruit that is I2C:

Seems like the simplest solution.

  1. Set the PWM frequency to maximum - with 8 bit PWM and 16MHz clock
    you can go to 62.5kHz (using fast mode) - this means finding a suitable library
    or tinkering with the timer registers directly.

  2. Use an R-C-R-C 2-pole filter to get better low pass filtering. With a cutoff of
    1kHz or lower you'd get perfectly good output.

KeNNy_aKa_MaX:
The situation is that an Arduino is going to be a sensor voltage dataloger in car, ie getting sensor voltages on one side and outputting them on the other side and logging them to the memory.

If your ultimate goal is to log the digital sensor data to memory why would you want to use PWM as an intermediate step?

Do you really need to have the signal going into the arduino and then to the ecu ?

You should be able to have both the arduino and the ecu using the original signal, attaching the original signal to the analog input should not interfere with the ecu's ability to read it.

Even cheaper, a $5 12 bit DAC from Adafruit that is I2C:

I just noticed you already mentioned this in Reply#9 so I'll remove my post which is redundant.