Conversion from PWM to 0-5V DC voltage

Discussion in 'General Electronics Chat' started by edward2011, Jul 6, 2011.

  1. edward2011

    Thread Starter New Member

    Jul 6, 2011
    2
    0
    Hi Guys!

    I'm studying Engineering at the University of Adelaide working on a very exciting project called EDWARD: http://sites.mecheng.adelaide.edu.a...ects.php?wpage_id=44&title=60&browsebytitle=1

    As part of our goals this year we plan to make the vehicle remote controlled.

    We've got a package similar to this: http://www.ebay.com.au/itm/SANWA-DA...Radio_Controlled_Vehicles&hash=item255e3311bd

    My question is, knowing what the base frequency and PWM duty cycle is coming out of the receiver module, is there a circuit that could effectively turn the duty cycle (say 1-2ms) into an analogue voltage easily readable by our microcontroller (in this case 0-5V) ?

    I came accross this thread: http://forum.allaboutcircuits.com/showthread.php?t=22222

    Is this what I'm after? A simple RC circuit?

    Or would an ESC (http://en.wikipedia.org/wiki/Electronic_speed_control) for a brushed DC motor possibly work?

    I know... I'm an engineering student... I should get this... *sigh*

    Any help would be great!

    Thanks guys!

    Sam.
     
  2. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,536
    Conversion is very simple, you came across two simple techniques already. I'd use a multistage RC filter myself (in other words, a 2nd or 3rd order low pass filter) to minimize ripple. The output should be a variable DC voltage that reflects with fair accuracy the duty cycle of the PWM. Since you are feeding this into a µC you don't need the 0-5V exactly, the CPU can compensate nicely for that.
     
  3. edward2011

    Thread Starter New Member

    Jul 6, 2011
    2
    0
    Aha!! I read that about 12 times before posting here and could not see who it would work in practice.

    But that makes perfect sense.

    How would one select what value C and F to use depending on the maximum and minimum "on time" for the duty cycle? Or it'd be more dependent on the fixed frequency of the PWM signal wouldn't it...
     
  4. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,536
    Yep, you need to keep the knee of the filter below the lowest PWM frequency (not all PWM encoding schemes are frequency stable). I've come up with several, but one I've pretty fond of does have a stable PWM base frequency. It isn't too critical, but I would keep the knee around one octave away.

    BTW, Welcome to AAC!
     
  5. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    I know this is not what you asked, but you could just sample the 0v-5v digital PWM directly with the microcontroller.

    One method I have used is to capture the 0v-5v as a LO or HI bit, captured at a fixed frequency in a timer interrupt. Any fixed frequency different from the PWM frequency is ok, as it will beat with the PWM frequency and you just average the HI LO bits over time to get an average PWM.

    This can give you a much finer measurement resolution than the ADC and measures PWM itself, not a analog converted version of the PWM that may have issues.
     
  6. strantor

    AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    have you come across this yet? http://dev.emcelettronica.com/how-t...g-or-analogue-voltage-digital-circuits-part-2

    I was looking into doing this a few months back and (without re-doing all my research and providing links) what I came up with from what other people had tried and said in other forums was that the best you will get from an RC filter is a semi-ok sawtooth, but I never tried it so can't say. they also said that for a true stable analog signal you need a DAC. I bought one but never got around to using it, so can't testiy to those results either.
     
    shortbus likes this.
  7. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Wow I just checked th elink and saw you are making a monowheel (diwheel) project! Very cool.

    Just watch out for the hard braking scenario... ;)
     
Loading...