Converting a pulse into an analog voltage?

Discussion in 'General Electronics Chat' started by Razor Concepts, May 17, 2009.

  1. Razor Concepts

    Thread Starter Active Member

    Oct 7, 2008
    212
    1
    The pulse is between 1ms and 2ms long every 20ms (a standard PWM pulse for servos). Is there an easy way to read that pulse and convert it to an analog voltage from 0 to 5 volts? Thanks.
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    It would be helpful to know what you are wanting to do with resulting analog voltage.

    hgmjr
     
  3. Razor Concepts

    Thread Starter Active Member

    Oct 7, 2008
    212
    1
    Read that analog voltage into a microcontrollers ADC
    (the microcontroller doesnt have enough power to use interrupts to read the pulses)
     
  4. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Which microcontroller are you planning to use?

    hgmjr
     
  5. DonQ

    Active Member

    May 6, 2009
    320
    11
    There has probably not been a micro-controller manufactured in the last 20 years that can not easily read the number of mS of an RC servo pulse. Many of them even have internal hardware that will count the number of clock pulses of the pulse and make that number available without using any processor time.

    Converting to analog, then reading with an ADC will not only require more external parts (many versus none), it will introduce errors and have a lower resolution than simply timing the pulse.

    I have a PIC, running at only 4MHz, that reads all 6 outputs of a 6-channel receiver to a 1μS resolution. I doubt that it even uses 0.1% of the processor time to do this.

    If your processor really can't count pulses, a micro-controller that can do it is available in many forms for anywhere between $0.50 and about $3.00.
     
  6. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    Pulses every 20ms are slow compared to the speed a microcontroller can read from an input. You can monitor the pulses, it is possible.

    If don't want to use an interrupt you can sample the pulses with the ADC of the uC with a sampling rate less than 1ms as to be able to detect them.
     
  7. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Most of the AVR microcontrollers have a feature called "input capture" that is ideally suited to the task of measuring pulse widths and can thus can be used to measure frequency as well.

    hgmjr
     
  8. Razor Concepts

    Thread Starter Active Member

    Oct 7, 2008
    212
    1
    Thanks. I am using an AVR microcontroller... I was not aware of the input capture interrupt. Before I was using a bad "while pin is high count time" kind of thing. I will look into input capture. Thanks for the help!
     
  9. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    That is the feature to which I was referring.

    Which AVR are you using?

    hgmjr
     
Loading...