Check out the new projects site for A-i-S

Monday, June 23, 2008

Oh the trickery.....

Ok this morning was more about setting up SAMBA and sharing printers than AVRs...

Anyway the challenge today is to conrtol a servo whilst using FreeRTOS on a AVR ATMega32. The trick here is that I usually the Procyon library to control Servos (easy to include, easy to address several servos etc etc). Unfortunately I can't include the timer.h from Procyon and the FreeRTOS headers. The issue seems to be a conflict over the timer interupt.

The Mega32 has two 8-bit timers and a single 16 bit timer. At the outset, I'm assuming tht FreeRTOS uses the 16-bit timer in the demo code I have modified.

I can see several possible ways forward...

1) Manually set up servo control without using interrupts

Probably a silly idea because then your cpu will spend most of its time counting numbers up rather than something useful

2) Alter FreeRTOS to use a different timer than referenced in timer.h

Looks to more trouble than it is worth considering the complexity of FreeRTOS. Best to avoid if possible.

3) Avoid clashing with FreeRTOS and its choice of timer. Choose a timer and interupt it does not use and use this timer instead

I think this is the first path I will attempt. Hopefully I will find an available 8-bit timer and create the code to drive the few servos that my bot requires.

4) Setup a servo control board and send UART signals to it.

If 3) above fails will take the next easiest road and build a small separate board to control the servos and control it via UART. This may have a negative impact on control and feedback though.

No comments: