Converting a pulse into an analog voltage?

Thread Starter

Razor Concepts

Joined Oct 7, 2008
212
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.
 

Thread Starter

Razor Concepts

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

DonQ

Joined May 6, 2009
321
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.
 

mik3

Joined Feb 4, 2008
4,843
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.
 

hgmjr

Joined Jan 28, 2005
9,029
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
 

Thread Starter

Razor Concepts

Joined Oct 7, 2008
212
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!
 

hgmjr

Joined Jan 28, 2005
9,029
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!
That is the feature to which I was referring.

Which AVR are you using?

hgmjr
 
Top