Servo and Clock or PWM

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

Moderator: Benj

Post Reply
Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Servo and Clock or PWM

Post 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.
Attachments
ServoandClock1.fcfx
Servo and Clock
(14.78 KiB) Downloaded 225 times
Go with the Flow.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Servo and Clock or PWM

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

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:

Re: Servo and Clock or PWM

Post 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

Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Re: Servo and Clock or PWM

Post by Mark »

Thank you both, I expected that some clash of resources was on hand.

Mark
Go with the Flow.

Post Reply