EEVblog Electronics Community Forum
Electronics => Microcontrollers => Topic started by: danielks on August 01, 2011, 06:47:50 am
-
Can anyone teach me what method or how am I suppose to read PWM signal in PIC ?
-
i dunno much about what features are available in PICs (there's probably some that can read a PWM directly) .
But in general..
You could use one of the mcu's hardware timers and see how many counts you can get between pwm signal high/low, low/high changes. This would give you a measurement of the pwm pulse length and you could calculate the duty cycle from that.
Depending on the specs of the micro you might be able to use a pin change interrupt to read and reset the counter.
A good idea is to look at projects people have already done. There will be lots of projects out there where people have made a mcu pretend to be a RC servo. RC servos read a pwm signal from the RC receiver and power the motor forward or backward in order to move to the position given by the duty cycle. (there is a pot on the servo arm for position detection)
-
See:
http://ww1.microchip.com/downloads/en/devicedoc/41214a.pdf (http://ww1.microchip.com/downloads/en/devicedoc/41214a.pdf)