Sunday, April 20, 2008

TicTacToe Bot (Part 2)

PART-2 : The TicTacToe Robot Controller

IMG_0140

Now, that we have an algorithm working, what's next? Good question. Lets take a look again at the block diagram of our electronics:

 block-diagram

Roughly based on the above I whipped together a Schematic:

Schematic

Basically a Atmel (AVR) ATMega32, with a 2x16 Character LCD,  a Keypad Matrix,  and A set of headers for interfacing with the motion driving circuitry and sensors.

Step 1: Preparing the firmware.

This was main part, apparently porting the windows 'C#' code to plain 'C' wasn't all that simple, after all. Well it would have been , except:

Error_mem

So, I did a bit of optimization, and then some more, and then a LOT more. A poem would explain better:

"Till I had reduced each int to byte,

and byte to bit,

Till each hardware register was consumed,

Till each register could be used,

or Re-Used no more,

and Lo... I present to you the 'Optimized Code-Size'" smile_shades

new_mem

This I'm particularly proud of. clap

Anyway, the code is divided into 5 Files:

  • main.c
  • game.h
  • game.c
  • UserInterface.h
  • UserInterface.c

Program Structure

Step 2: Preparing the hardware.

After getting the code "Out of the way", it was time to do what I really wanted to do this weekend. Time to get some Solder Iron Burns and some spit, wire and breadboards, together!!

Lets See what we need first. Hmmm....

IMG_0120

-Solder Iron. Check.

-Bread Board. Check.

-LCD. Check.

-Microcontroller. Check

r step -Random Headers and Stuff. Check.

-Some Discreets. Check.

-Lots-a-Buttons. Check.

All clear. Lets go....thumbs_up

One Hour Later:

IMG_0121

Everything assembled to my satisfaction, and ready for testing. fingerscrossed

IMG_0122

It Works!!! It Works!!!

Some random screens:

IMG_0128

IMG_0130

Scrolling Up and Down the Menu:

IMG_0123

IMG_0124

IMG_0125

IMG_0126 IMG_0127

IMG_0131 IMG_0133 IMG_0134

Preparing the Outer Box: (I wish I had taken my art and crafts class in High school seriously smile_thinking

IMG_0135

Ooohhh the guts and wires.....IMG_0136

The Front Panel: (Before I got creative with a felt pen smile_wink)

IMG_0137  AAaahhh Finished.... clapthumbs_upbeer

IMG_0139

 

IMG_0140

Still Works....

IMG_0142

Under the hood: Easy Access to the Microcontroller, and I/O Headers. I know, I'm a genius. smile_teeth

IMG_0138  So, Thats it for now. What about the rest of the bot? Well the main part is over, I mean, the Code works on the Mega32, is now optimized, quite a bit, and I spent an entire long weekend (Long Weekend = Friday + Saturday + Sunday) on it, so it may be atleast another 3-4 weekends that this project will be on hold, so that I can work on other interesting projects. Nothing to be sad about... Next week, I'm working on Panasonic Servo based gantry (Ball Screw), with a Xilinx Spartan XC3S400. Nice....

 

If you like this post, leave a message, it always makes my day.smile_regular

4 comments:

Mohit Mahajan said...

Nothing to do with your post... Actually was wondering why you'd have "Rita Pad" in your links. Do you own one of these printing machines?

Devesh Rai said...

I'm associated with that company.

Regards,

Debu :)

Anonymous said...

Superb!!!!
I absolutely love this idea of a tic tac toe bot...

:)

Joseph McGlone said...
This comment has been removed by a blog administrator.