Building the Board

For this week's assignment we were given a chip design and told to add a button and an LED (i.e. a light). Then we had to actually fabricate the chip and program it to do something with that light and that button. Since this was my first time programming a non-arduino-based microcontroller (and my first time programming an arduino was also just two weeks ago) I decided to stick with using only the one input and the one output rather than trying to incorporate the serial cable.

By the end of the design session I learned to edit an Eagle document. I also learned a bit of basic circuit design. Here's my ending schematic:

Once I finished designing I went on to mill the board. I managed to squish the extra components onto the existing design rather than expanding the size of the chip.

You can see in the picture that all of the legs of the microprocessor's copper plates are connected. This is WRONG! I only discovered my error after I finished stuffing everything. This ended up being a wonderful mistake, however, because I learned the best way to remove a chip from a board! To remove a large component from a board, just add more solder! It sounds counterintuitive but by adding more solder you create a thermal mass which gives you time to heat all of the legs at once. This means you can just melt all the solder and pull the chip off the board in one fell swoop.

Once the board was all stuffed I started playing with the programming aspect of it. I quickly learned that my joints still didn't work, and so I learned my second valuable lesson -- Flux makes everything work. By adding flux to each joint and just running the iron by all of the joints I was able to debug the board without having to test any connections.

Simple Simon

I decided to create a pattern matching game for my assignment (aka "simon"). When you push the button, the chip generates a random 8-step pattern (i.e. a random number from 0 to 255) and plays the pattern to you by flashing the LED. Then it's your turn to repeat the pattern exactly. If you get the pattern right it blinks a success pattern ("..- ..-") and if you miss a beat or press the button too early it blinks a failure pattern (- - - - - - - - -) and you lose the round.

The hardest part of the program was figuring out the timing and ensuring responsiveness. At first I had it so you needed to be pressing the button at instantaneous moments (i.e. it would check button state every 200 ms). But this proved to be a very difficult to play because it meant that the button didn't feel linked to the light (it waited every 200 ms to check, meaning if you pushed or released the button in the middle it wouldn't affect the state of the light). I ended up checking the state of the button once every 1 ms and saying that if the button was pressed for more than half the time in a given period, that counted as a button press. This allowed me to light up the button as the user pressed it (i.e. making the game responsive) while also keeping track via a timed counter.