Page 1 of 1

Servo and Clock or PWM

Posted: Mon Jun 09, 2014 9:00 pm
by Mark
Hi,

I have successfully set up the servo component.

On another project I have successfully used the PWM component.

Trying the two together seems to stop either working properly.

I therefor though of using a clock to provide the PWM. This has the servo jumping all over the place, whichever clock I use.

Please suggest a strategy to enable me to use a servo and PWM (in some form).
It would also be useful to know what resources the servo component uses.

The chip used is a 16F887 using the internal clock.
Servo is on RD2.
The PWM was to be on RD1 but the attached code just looks at the clock effect.
I am using v6.0.7.0.

Thanks.

Re: Servo and Clock or PWM

Posted: Mon Jun 09, 2014 10:26 pm
by medelec35
Hi Mark, have you see this thread?
There are a few posts, but don't forget to checkout the flowchart on the last page.

Martin

Re: Servo and Clock or PWM

Posted: Tue Jun 10, 2014 10:22 am
by Benj
Hello,

The Servo component utilises the Timer 1 peripheral and the Capture Compare CCP peripheral, as does the PWM component.

So you can either generate the servo signals using the timer 0 interrupt as Martin showed or you can generate the PWM using software techniques and the timer 0 interrupt.

An example of software PWM can be found here, http://www.matrixtsl.com/article.php?a=52

Re: Servo and Clock or PWM

Posted: Tue Jun 10, 2014 6:38 pm
by Mark
Thank you both, I expected that some clash of resources was on hand.

Mark