Page 1 of 1

servo pwm input

Posted: Fri Jun 15, 2007 9:13 pm
by serstel
Hi

Can the pic receive pwm from a source that normally drives a servo, like an RC Gyro? Is there a way that, something like this, can be done?
Thanks

Posted: Mon Jun 18, 2007 9:39 am
by Benj
Hello

Yes the PIC can receive the PWM signal as long as its frequency is not too high. The easiest way to monitor it would be to start the tmr0 running

Code: Select all

tmr0 = 0;
Then wait until the pulse goes high.

Code: Select all

while (porta & 0x01 == 1);
Once it goes high you would collect the value in the tmr0 register

Code: Select all

FCV_MYVAR = tmr0;
Then restart the timer

Code: Select all

tmr0 = 0;
and monitor how long the pulse was low using the same method.

Posted: Tue Jun 19, 2007 1:09 am
by serstel
Hello

Thanks for the tip, however if I were to use the pic to drive servos as well, then I would need the tmr0 register to provide the interupts neccesary to produce a PWM output for the servos.

Posted: Tue Jun 19, 2007 8:50 am
by Steve
On a lot of chips (e.f. 16F87x and 16F88x series), the PWM is generated by the Timer2 source, which means that Timer0 would be free.