View Full Version : PWM to Anlog voltage

03-25-2009, 06:41 PM
Hi guys,
I have PWM pulse of 50 Hz, which i want to monitor using micro controller. For this i want to convert it to analog voltage and give it to DAC.

I have gone through RC filters and used 2Mega ohm resistor and 1micro fard capacitor.

But i am not able to get any signal in scope. :( .
Please help.

03-25-2009, 06:43 PM
Sorry its not DAC its ADC.
Direct interface PWM output to ADC is not working.

03-26-2009, 09:50 AM
you dont need an ADC!!!

PWM is digital !!!

03-27-2009, 04:14 PM
I want to monitor the PWM generated by a micro controller ( in a RF receiver) using another micro controller.

My idea is to convert to analog signal and give it to ADC of second micro controller for monitoring it.

03-27-2009, 05:56 PM
as the wave is of 50 Hz only, you can get fair accuracy by just using a timer to count for how much time the input signal is high. reset the timer whenever signal goes low.

a analog solution can be to use a capacitor. the idea is to let the capacitor (better integrator) charge when the input is high. as soon as input goes low, use adc and then short the capacitor to remove the charge accumulated.

03-30-2009, 05:13 AM
HI Ashish,
Do you have a circuit diagram using the capacitor ?
As far as i could find on the net tpwm=1/f
and should choose time constant of RC filter t=R*C
such that t>=100*tpwm.

But it does not give ant reading.
:( What should i do?

03-30-2009, 12:52 PM
you dont have to convert it to analog to give it to an ADC. !!!!
(as long as the voltage levels are within the ADC limits)

but why, why on earth do you want to use an ADC?? :roll: :roll: :roll: :evil:

03-30-2009, 06:44 PM
Hi, i have a RF receiver circuit which controls servomotor using PWM. I want to monitor the pwm signal using micro controller and execute different instructions for the varying PWM signal.

03-30-2009, 08:56 PM
just search for opamp integrator.
as in your case Vin is constant, say 5V so Vout=(5/RC)*t
max time=20ms and max Vout=5V so RC=.02
therefore if R=1K , C=20uF.

now you need 2 more circuits before giving it to ADC. first is inverter (as integrator output is inverted). second circuit to ensure that the capacitor is reset before a new pulse comes.

03-31-2009, 04:23 AM
Hi Ashish,
I got the RC filter and the Opamp part, but coukd you please tell me more about inverter and the ciruit to ensure that thecapacitor is reset?
Thank you.

03-31-2009, 07:44 AM
listen, anil, to monitor a PWM signal all you need is to check when the input is high or low. you dont need an ADC, your dont need a stupid filter or whatever.

Now if you still want to go forward with ADC - well, some people wont just listen.

03-31-2009, 02:32 PM
Hi allbits,
could you please tell how will you check or monitor the pulse width?
The PWM signal varies from 1msec to 2msec

04-03-2009, 02:38 PM

This is what u need :
To execute different instructions for different PWM duty cycles. Right ?

What to do :
It depends on how many times PWM signal changes its pulse width in one second.

## IF PWM signal changes its pulse width, say once in a second :

u need RC filter with cutoff freq of 5Hz (one decade less than the base PWM, so that 50Hz signal will be sufficiently suppressed).
Let C = 220n, then R = 1 / (2*pi*C*f) = 144K (~150K) :

IN>---^v^v^-------------> Out - TO ADC of uC
.......................=== 220nf
----------------------------- GND

No need to add integrator, etc.

# IF PWM signal changes its pulse width, many times in one second :
- Use external interrupt and configure it for rising as well as falling edge triggering.
- When rising edge occurs, start some timer with appropriate prescalar
- When falling edge occurs, stop the timer and read the count value. This will give u the pulse width in terms of number of counts.