PCB making/ Microcontroller programming

The goal in this integrated microcontroller programming/ PCB design segment of the class is to create a simple interactive game to familiarize oneself with assembly and/or C, and to successfully program a board which is similar to the Hello World boards we previously made using the ATTINY45.  I started out coding my game in C, a simplistic implementation of checkers, in which a text gui of the board is printed to terminal, a user makes moves by returning the start and end square, and the computer responds with its own (simple, though not entirely stupid) move.  I hope to code something in assembly too if I have time, but the way I wrote checkers, it would have been impossible for me in assembly, unless I knew way more than I do.  As it is, this took me quite a while.  What I found is that I could almost do it on the ATTINY45.  I got it to compile such that every byte of EEPROM and every byte of FLASH was used (256 and 4096, respectively).  However, it left out some key features which encouraged me to go to the ATMEGA88 for its increased memory, even though it had way more pins and functions than I needed. 

Basically I built the same board as the Hello World before, I just mapped the MOSI, MISO, SCK, -RESET, and GND pins that were used before to program the board from a parallel cable to the corresponding pins on the 88.  When importing from Neil's EAGLE library into an EAGLE schematic, each of the pin functions are clearly mapped.  This was my first time using EAGLE, and I didn't do a great job of it.  First off, EAGLE hates it when you do anything to mess with the corresponding nature of the .sch and .brd files.  It also doesn't like undos in this respect.  There is supposedly a way of recorrelating .brd and .sch files if you get them out of sync by going into a file (.elf?) and editing something, but my board was simple enough I just started over.  Basically you lay out the connections and elements in your schematic, and these are mapped to your board, which you then use to set the physical layout and map the trace paths.  I had to use some jumpers because I couldn't get all the traces on the same plane without crossing, and you can do this one of two ways.  You can map a 0ohm resistor as jumper pads, or you can say to hell with correlation, I'll delete the connections in the schematic and map them manually on the board.  You can use the autorouter if you have a simpler situation, but you can only alter the paths somewhat afterwards i.e. you can't insert a new bend in a trace, at least I couldn't.  Once you have your board laid out how you like, you need to go to view, and select only the top layer.  This removes the elements, and you're just left with your copper traces.  Then you need to select monochrome to get it into the black and white that cad.py likes.  Export it as an image, and save it as [fname].png.  Below is what I ended up with (Update: my board had some errors (I didn't connect all the VCCs), but Courtney's was correct, so I list here correct .png below mine, use that instead, and unfortunately it's not yet in the correct format to go to cad.py, as mine is, but you can recreate it easily enough).

EAGLE

Atmega88

Open this up in cad.py on the machine driving the modela.  You're going to have to select invert image so that the black is what wants to be cut.  Once I rendered, I found that due to the quantized nature of EAGLE, as well as the rendering portion of cad.py, some of the pads for the ATMEGA88 didn't get separated.  They were admittedly very small and close together, but some did, and some didn't.  This can be seen in the milled pre-stuffed board below.

88

I ended up having to use an exacto knife to separate the pads.  Some of them were lost, but I only lost ones that weren't connected to anything.  The only purpose they were serving was helping to attach the 88 to the board.  The picture below shows what I came up with.

traces

I then stuffed the board.  My jumpers were quite ugly, and things got more spread out than they should have been.  I'm not even going to show the result.


Now to the programming.  I wrote my code in WinAVR in the Programmer's Notepad, which offers most of the typical features like reserved words, bracket matching, etc. of a nice IDE like MPLAB or Eclipse.  It was here that I compiled the code and sent it to a hex file.  There is integration between WinAVR, AVR Studio, and the AVR Dragon, but I first tried to program the microprocessors in Ubuntu, so I could have the terminal and the instruction set we used before using Avrdude.  I started with just the Hello World hex I had done successfully before, so that I could see if my setup worked.  What I have to program is USB->AVR dragon->ISP connector wire->5 pin header.  What I have to read is USB to serial converter->serial connector wire->4 pin header.  I made the ISP connector wire and serial connector wire.  I'm doing it this way so I can do everything off my laptop, which has neither a serial nor a parallel port.

Update a few days later:

Missed a jumper in that picture above, need to switch a PB2 to PB5 in Neil's makefile, need a new jumper cable to connect the tx pin of the 4 pin header, in series with a resistor.  I'm writing this rather late (3AM Monday morning), and can't make the needed corrections right now.  Therefore I am having to run my code off the tiny45, which is limiting my Flash memory to less than I need for a full implementation

I got the dragon to work.  The proper headers can be seen in the picture below.  The syntax for avrdude for the tiny45 is:

sudo avrdude -p t45 -c dragon_isp -P usb -e -U flash:w:Checkers.hex

For the 88 sub m88 for t45. 

Headers

I was using 2 computers because I'm doing the hex making on winavr, emailing the result to my ubuntu where I know how to program with term.py and avrdude.  (Update: you can do the hex making on ubuntu of course, I just didn't know the correct command lines, it's just like make [file] [makefile])