[CCC DEV] Servo code question

Matt Jadud jadudm at gmail.com
Fri Jun 25 00:33:34 BST 2010


Hi all,

This one is for Dennis, in part...

Looking around your branch, it looks like you were attempting to add
the ability to control servos from arbitrary pins. This would involve:

1. Setting up a 16-bit timer to fire once every 20ms
2. Turning that pin on for somewhere between 600us and 2400us (numbers
vary based on servo manufacturer)
3. Rinse, lather, repeat.

This approach does allow you to control more servos... but, that said,
it means your code is continuously being interrupted by the timer ISR.

Shortly, we'll have PWM-driven servo code available for you. This will
allow you to drive... er, either 4 or 6 servos off an Arduino, and
more off the Mega. (I forget... does the 328 have 1 16-bit timer, or
2?) Regardless, this approach does not interrupt your code... you just
modify the value of the timer compare register, and it handles driving
the pin in the background, allowing your code to do its work without
interruption.

Ultimately, I'd like to have code for both approaches in the codebase,
as there may be times that being able to set up and drive 6 or 8
servos is necessary/desired. So, the work you're doing isn't a waste,
by any stretch. But, if you only need a few (2 to 4), then the (pure
occam-pi, no FFI) code that we're about to commit will do the job.

Thoughts? Does this help you?

Cheers,
Matt

-- 
Sent from my TRS-80




More information about the developers mailing list