Just for the fun of it I decided to try out one of the Society of Robots AxonII controller boards (societyofrobots.com/axon2/). It is based on the Atmega640 microcontroller by Atmel, which has some nice features like 4 UARTS (1 is used by the USB), 16 AtoD pins, 15 PWM channels…). After getting a few things to work, I decided to try it out on one of my Brats, as you can see in the picture below:
I cut out my own electronics holder for it as the board is a slight bit wider and shorter than the BB2. The software is written using Appstudio from Atmel and the free GNU C compiler. Note: the C compiler that downloads with Basic Micro Studio for the Basic Atom Pro is also the GNU compiler. I started off using a software Library called WebBotLib which is Open Source. More information up at: sourceforge.net/projects/webbotavrclib/
The picture shows the Axon2 board. The top row of pins are the Analog input pins. I am currently only using 1 for the SHarp sensor. The right hand side shows the USB adapter, which I am using to output debug messages. The Gray ribbon wire connects to an ISP board that I use to download programs to the board. You can use the bootloader on the board, but it is a little more complicated and slower. The servo wires are connected on the bottom and left hand side and the XBee is connected to one of the UARTS toward the top left of the board. Note: I had problems with the Sparkfun regulated adapters and I am currently using one of the ones from Selmaware (I can go more into this if anyone is interested…)
In my Code, I currently have all 7 servos connected up to hardware PWM channels and I am using the webbotlib servo class, which more or less defines the range of a servo in a byte (-127 to 127). When you define the servo you define the center point (1500) and the range (500) for the servos and it does the translations. I then wrote my own version of Servo Group move that I specify a new location for a set of servos and how much time in mS to get there and it does the work to adjust each servo. Currently I have a call out in my main loop to do this every 50ms, but may move this to an actual timer. I also then then converted the BAP basic code that for example to do a turn left that looked like:
elseif(command = 11) ; Turn left
gosub movement 200, 0, 0,-140, 0, 0,500]
gosub movement 200,-350,-350,-140, 350, 350,500]
gosub movement 0,-350,-350, 0, 350, 350,500]
gosub movement 0, 350, 350, 0,-350,-350,500]
gosub movement 200, 350, 350,-140,-350,-350,500]
gosub movement 200, 0, 0,-140,-350,-350,500]
gosub movement -140, 0, 0, 200,-350,-350,500]
gosub movement -140, 0, 0, 200, 0, 0,500]
gosub movement 0, 0, 0, 0, 0, 0,500]
To be Data Driven in C. So I created a set of classes and then defined data that looked very similar:
static CMLSD1 s_cmlsd1_TurnLeft = {9, {
{ 200, 0, 0,-140, 0, 0,500},
{ 200,-350,-350,-140, 350, 350,500},
{ 0,-350,-350, 0, 350, 350,500},
{ 0, 350, 350, 0,-350,-350,500},
{ 200, 350, 350,-140,-350,-350,500},
{ 200, 0, 0,-140,-350,-350,500},
{-140, 0, 0, 200,-350,-350,500},
{-140, 0, 0, 200, 0, 0,500},
{ 0, 0, 0, 0, 0, 0,500}}};
...
SetCurrentCommandList(&s_cmlsd1_TurnLeft); //command = 11
This allowed my main input loop to simply call off to process the current moves and then call of to get input and decide if a command list is still running, decide which events I wish to process. For example I can be walking and then easily call off to have the turret servo rotate. Or if I had them on this Brat shoot the guns…
I have made some reasonable progress. It is talking to the DIY XBee remote, it is walking (although I want to probably fine tune this some), The head servo rotates and I can do a ping with the Sharp sensor and send the distance back to the DIY remote which displays the results.
If anyone is interested, I can upload the sources… Right now it is a work in progress.
P.S - Before anyone asks. No I have not abandoned working on the Basic Atom Pros. They are also great boards and I have a lot invested in them. May at some point try to port the C code back to the BAP and may try changing the Basic version Movement functions to be more data driven as well… Besides I am still waiting for the next version of the BAP manual to review and Arc32 board to play with…