Servo and Clock or PWM

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

Moderator: Benj

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

Postby Mark » Mon Jun 09, 2014 9:00 pm

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 65 times
Go with the Flow.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8821
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2560 times
Been thanked: 3716 times
Contact:

Re: Servo and Clock or PWM

Postby medelec35 » Mon Jun 09, 2014 10:26 pm

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
These users thanked the author medelec35 for the post:
Benj (Tue Jun 10, 2014 10:19 am)
Rating: 5%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Re: Servo and Clock or PWM

Postby Benj » Tue Jun 10, 2014 10:22 am

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

Postby Mark » Tue Jun 10, 2014 6:38 pm

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

Mark
Go with the Flow.