Author Topic: Reading PWM signal in PIC micro  (Read 7392 times)

0 Members and 1 Guest are viewing this topic.

Offline danielks

  • Contributor
  • Posts: 19
  • Country: my
  • Newbie from Malaysia
Reading PWM signal in PIC micro
« 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 ?

Offline Psi

  • Super Contributor
  • ***
  • Posts: 8108
  • Country: nz
Re: Reading PWM signal in PIC micro
« Reply #1 on: August 01, 2011, 11:20:14 am »
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)
« Last Edit: August 01, 2011, 11:25:38 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)

Offline johnmx

  • Frequent Contributor
  • **
  • Posts: 277
  • Country: pt
Best regards,

Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo