[CCC DEV] Servo code question

Dennis Meade meade.dennis at gmail.com
Fri Jun 25 01:42:03 BST 2010



Matt, our messages seem to have crossed in the ether. I wrote a response 
which covers most of this. As  far as I'm concerned, multiple approaches 
are great..  I wfll be interested in seeing the other code. I started 
doing a write up to explain how all this works, but am not quite finished

On 6/24/2010 7:33 PM, Matt Jadud wrote:
> 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
The timer mechanism can be used to only interrupt the code at the end of 
a pulse. It uses the OCR1A register to contain a value corresponding to 
the pulse interval. The interrupt is generated at the end of the pulse.

> 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
The 328p has 1 16-bit timer and 2 8-bit timers. The architecture guide 
goes on for almost 40 pages on  using just the 16-bit timer.  If it 
weren't for the material to crib from, I wouldn't even have attempted 
writing a driver.

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

I'm curious how this code deals with with microseconds in occam. (oh, I 
think I see. You can access the registers directly )
> Thoughts? Does this help you?
>
> Cheers,
> Matt
>


-- 
Dennis

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.concurrency.cc/pipermail/developers/attachments/20100624/015df349/attachment.htm>


More information about the developers mailing list