Showing posts with label pcb. Show all posts
Showing posts with label pcb. Show all posts

Saturday, July 28, 2012

MSP430 Launchpad GamingPack

TEAM MEMBERS

Max Thrun
Brittany Finch
Kathleen Foster

PROJECT DESCRIPTION

Based on the Gameduino, the GamingPack transforms your MSP430 LaunchPad into a full fledged gaming console complete with audio / video output and two Nintendo controller sockets. Just hookup your computer monitor, plug in a controller and you'll be writing games in no time.

PROJECT FEATURES

- 400x300 Pixel VGA output
- 256 16x16 Pixel simultaneous sprite images
- Up to 256 colors per sprite
- 2 Nintendo (NES) controllers
- Nostalgia


Video




http://www.youtube.com/watch?v=hDE0ZfmsVrw

Design



The schematic capture and PCB layout were done in CadSoft EAGLE. The PCBs were fabricated by Silver Circuits










The GamePack is designed around a Xilinx Spartan 3A 200K Gate FPGA. It implements the same sprite rendering core as the Gameduino and communicates to the LaunchPad via SPI. The FPGA bitstream configuration is stored on an external EEPROM which was programed using a FTDI FT2232D development board and Flashrom in Linux. The FPGA 1.2V internal core voltage is provided by a TI TLV70212 low drop out regulator.

A resistor DAC provides the various voltage levels for the VGA interface and audio is achieved by passing 2 channels of digital audio through a 4KHz low pass filter. An optional SPI EEPROM can be installed to store large game data such as images and level maps. Two status LEDs indicate power and SPI data transfer to the FPGA.

2 Nintendo (NES) controller sockets are included to provide a classic gaming experience. They are ideal for this project as the interface is simple and they can be easily purchased online or simply found in a box in your closet.









With only a month and a half to complete this project designing for test was important. The GamingPack includes a 10 pin header that can plug directly into a Saleae Logic Analyzer










Schematics, layout, and CadSoft EAGLE file can be found here.

Basic Examples


Several basic examples were developed to demonstrate and show off the various functionality of the GamingPack.



sprites_256 - Demonstates the hardwares ability to draw up to 256 sprites simultaneously



palettes - Shows each of the different color palette modes



scroll - Randomly generated scrolling terrain to show off the hardwares ability to smoothly scroll backgroud images



rotate - Example program showing the different rotation and mirror options



controllers - Small program to show how to read the NES controllers



background - Simple program showing how to display a background image



random_numbers - Shows how to use random numbers and draw text



sprite_walking - Example showing to how create a smooth walking animation



Source code for these basic examples: https://github.com/bear24rw/gamepack/tree/master/code/examples/basics

Game Examples


The GamingPack wouldn't be a gaming pack without a few games.




Breakout / Brick Breaker





Tetris





Space Invaders



Source code for the game examples: https://github.com/bear24rw/gamepack/tree/master/code/examples/games


Resources


https://github.com/bear24rw/gamepack
http://excamera.com/sphinx/gameduino

Thursday, October 1, 2009

LED Matrix

Last year in one of my classes we were required to make an 'artefact' or something that reflects the interests of the class. Most people make posters and the past two quarters that's what my class did too. Posters however are static, usually boring, and don't reflect that fact that everyone in the class is an EE major. We decided posters are for noobs and decided to go off the wall a little and make an LED matrix display. Lucky one of my friends John Wathen already had this beautiful 16x24 Green SMD LED matrix that he built back in high school.

P5271009

P5271014

What we didn't have however was a driver for it. The driver we choose to design was highly inspired from this one. The basic idea is that you use shift registers to sink the columns and a line driver of some sort to source the rows (we chose to use a Darlington array).

There where a lot of changes from the Instructables design that that we had to make however. The matrix in the Instructables was a lot smaller than ours and used 8 IO lines to drive each row. Since our matrix has 16 rows this was completely infeasible using just an ATMega168. To solve this issue we choose to use a 4:16 de-mux to control all sixteen rows with only 4 IO pins. The de-mux combined with two 8 channel Darlington arrays provided the perfect interface to control all 16 rows. To sink the columns we choose to string three 8 Output shift registers. Each shift register is rated to handle the current of the 8 LEDs that could possibly be on at one time.

Some other features that we included on the driver board were 3 green LEDs, 3 push buttons, ISP header, TTL header. When all was said and done we ended up the the schematic shown below.

rev_4


I know, you are probably looking at that and thinking, "Why are all the shift register outputs criss-crossed??". The reason for doing this is because the output pins on the chip are not exactly in a row so to assist in board layout the pins had to be crossed and mixed up so that the board layout would be nice. It's much easier to change the order of the columns in the program then it is on the board layout (in my opinion). We didn't want to etch a double sided board so a lot of effort went into laying as much of the circuit out on a single side. There were a few paths that could not be routed and were just jumped with wire (you'll see in picture below).

board


Notice how there are a bunch of air-wires (yellow lines) that I couldn't figure out how to route, they are manually jumped when the board is put together.

To etch the board we printed out the board layout 1:1 scale on glossy photo paper, it was than ironed onto a piece of copper clad. The idea is that the toner will stick to the copper clad and when the board is dipped in acid the acid will eat away at everything but the traces, since they are coved by the toner. I'm definitely not an expert in this area so ask John Wathen more about the process, he is basically a pro.

DSC_9192
Etching the board in acid

DSC_9193
Checking to see if its ready to be scrubbed

DSC_9199
Dirty traces

DSC_9205
Scrubbing off the rest of the toner

DSC_9217
The beautiful result, nice and shiny

Now, let me just tell you that we did this in a public bathroom at school. So there were three guys in a bathroom with latex gloves, a camera, and tub of some green liquid. Trust me we got some weird looks.

The next step was to drill all the holes. I don't remember exactly how many there were (John might) but there were a lot.

IMAG0015


After all the holes were drilled John soldered it all up.

P5271010

P5271011


And the result!

P5271017

P5271015

P5271013

P5271008

P5271007

P5271004

P5271005

P5271006

P5271019

P5271014


Now that the board was finished it was the moment of truth.

Adam Steele lent me his programmer. Plugged it into my Xbuntu box, apt-get installed the avr tool-kit and the programmer was immediately recognized (NICE!). Flashed a simple program to flash the status LEDs and low and behold, IT WORKED! Next up, everything else. I started by modifying the program that the Intructables provided but quickly got frustrated by the way it worked. It treated each column as a bit in a byte and the rows as a byte, this made it extremely hard to visualize outputs to the display. Also I was using a de-mux and had 24 columns which the code did not easy support. So what do you do in this situation? REWRITE.

An outline of how the new code works:

The value for each pixel is stored in a 2D array 16x24, want to set the top left pixel? buffer[0][0] = 1; simple as that, much easier than dealing with it as an array of bytes. Okay, so it takes up more memory but IMO it is completely worth every bit (pun intended).

The code starts by initializing the ports (pull-ups, in/out, etc) then it initializes timer1. To be completely honest the fill value for the timer was chosen by adjusting value, flashing, seeing if the refresh rate was noticeable. We ended up with OCR1A = 0x012C; as a good value.

The code then falls into an While(1) where it sequentially calls functions to draw stuff on the screen, for example:


All the high level functions (tunnel, spiral, shift, etc..) write to 'buffer'. When the timer interrupt goes off it calls the function shift_int() which reorders the columns into 'buffer_2' and then shifts them out to the shift registers. It then calls shift_mux() which jumps to the next row. So essentially we have a double buffered display.

Once all the low level code was done it was all fun and games. It was really nice being at the point were all you had to work with is a 2D array. We ended up with the high level functions:



It is so incredibly easy to make new functions when you are just manipulating a 2D array.

A warning before you watch the videos, they were taken with a crappy point n shoot camera so they look incredibly choppy. In real life the display is incredibly fluid and smooth. The videos do it zero justice.




Eagle Files & Source Code [Mirror]
If you re-use the design or source (which I encourage you to do) please give credit where credit is due. Also note that the entire code was literally written in a one night programming marathon since we were extremely pressed (read: it was due the next day), so there are still many bugs. Also I take no responsibility for any damage if you use my design and code (had to put a disclaimer ;))

Any questions regarding the design or the source code should be directed at me bear24rw . gmail.com
Any questions regarding the construction of the board should be directed at John Wathen jmwathen . gmail.com