[CCC DEV] Servo implementation question
Dennis Meade
meade.dennis at gmail.com
Fri Jun 25 00:46:33 BST 2010
Code for the servo has been written as .c code. I checked it into
avr-servo/tvm/arduino as servos.c. Code which invokes it is in occam. I
still can't get past the Status "E" error at which point I can finish
the code. It's mostly error checking and the remaining FFI.
It's interrupt based.
Briefly, it uses the TCNT1 16-bit counter and OCR1A, a compare register.
The TCNT1 is set to a starting value and OCR1A to a value corresponding
the the interval of the desired pulse.. When the TCNT1 reaches the
value in OCR1A, an interupt is generated.
The interrupt is turned on by turning on a bit in the TIMSK1 (
Timer/Counter1 Interrupt Mask Register ). The bit is the OCIE1A (
Timer/Counter1, Output Compare A Match Interrupt Enable
).
That's the simplified version. It supposedly can handle 12 servos. The
time out of the VM as I understand it, is very short as most of the
processing is done in hardware. The remainder is done in the ISR and
amounts to very short code segments.
I mentioned that I had checked the code in awhile ago, I think.
I'll describe my problem in my next email.
Dennis
On 6/24/2010 10:40 AM, Matt Jadud wrote:
> Hi all,the
>
> We can implement servo control one of two ways:
>
> 1. Use hardware PWM.
>
> 2. Fire a timer every 20ms, and drive an arbitrary digital pin high
> for somewhere between 600us and 2400us. This would allow us to
> (possibly) control more servos than we have PWM pins. However, while
> driving servos, we are out of the VM.
>
> Opinions either way?
>
> Cheers,
> M
>
>
More information about the developers
mailing list