servo pwm input

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
serstel
Posts: 22
Joined: Thu Jan 25, 2007 1:34 am
Been thanked: 1 time
Contact:

servo pwm input

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post 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.

serstel
Posts: 22
Joined: Thu Jan 25, 2007 1:34 am
Been thanked: 1 time
Contact:

Post 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.

User avatar
Steve
Matrix Staff
Posts: 3424
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post 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.

Post Reply