I've gone through my design files for AVRphrase and cleaned them up a bit, and now I've got them posted on SourceForge. The link is below, and it has everything you should need to replicate what I have done. In this post, I'll try to walk through the different files that are included, along with other things you might need to know if you want to build your own game.
Design Files
http://sourceforge.net/projects/avrphrase/
Once you download the zip file (AVRphrase_v1.1_20110113.zip), you will find 7 subfolders inside it:
Eagle_Files
This folder contains the schematic and board file for AVRphrase. I created these using the Freeware vsrion of CadSoft Eagle 5.6.0 (though I think the current version is 5.11.0). I updated the files to fix the things I had to do by hand, and the schematic matches what I made (if you look closely at the schematic from my previous post, a few of the component values are slightly different than what I actually used). I also included a BOM file that Eagle generates that lists the values/packages of all components. This was useful to me when double checking that I ordered all of the right parts. Most of the parts I used were in the default Eagle libraries, although some came from the Sparkfun Library, and others I made my own. I'm not sure how Eagle works with the libraries....if I need to post the library I created for you to view the schematic/board files let me know and I will.
There are a few things to keep in mind if you want to have a pcb made from this design. I made a small mistake when setting up my battery holder part in eagle, so the holes in the actual case are slightly offset from the holes in the battery holder. I used a small zip tie to keep the holder in place and there was room to fit it, but if you wanted to use screws, you would need to fix the alignment. I mentioned it in my previous post, but an improvement that would be easy to make would be to add a trace from the MCU to the reset pin of the USB-UART converter and reset it on power-on. PD4 is open for this if you want to maintain compatibility with the DIP-28 version of the MCU, or you could move the buttons from ADC5 to one of the ADC pins only available in the surface mount package and free up another GPIO that way. I didn't want silkscreen, so I turned that off. To create the gerbers, you'll need to run the CAM processor (there's plenty of tutorials online about how to do this).
BOM
I used the BOM from Eagle to make sure I had all of the parts I needed, but I've put together an Excel spreadsheet with part numbers and prices. I ordered almost everything from Mouser, and I set up a Project Manager that had all of the parts needed for a single unit, and then ordered multiples of those. If you'd like to go that route, let me know and I can send you a link to the project where you can purchase most of the components directly. I would recommend ordering extras of most of the small stuff (resistors, caps, and diodes) because they're cheap, easy to lose, and nice to have around anyways. For the ATmega48, you could get any MCU in that family (ATmega48, ATmega88, ATmega168, or ATmega328). I pretty much maxed out the code space, so if you want to add any other features you'd probably want to opt for at least the ATmega88. The 25AA512 EEPROM could also be scaled within the family, but that will require some software modifications to both the firmware and wordloader as addressing will be a little different. You can find the datasheet for each of these components on the Mouser page linked from the BOM spreadsheet.
The only parts I didn't source from Mouser are the case, LCD (and LCD pin headers), and hardware (screws, nuts, zip ties). I got the case from Polycase and my pcb is designed to mount on this case's mounting bosses. I got the screws for the case from Polycase as well. They have a Recessed or Flush option on the cases, but bear in mind that the surface they're talking about is the back of AVRphrase on my design, so it doesn't really matter. I got my LCDs from Xenon-Tech, but you could find them a lot of places. They're usually pretty cheap on ebay if you look there. Just make sure that the pins are on the top left of the screen....I got one while testing where it was at the top right, and that won't work with the pcb. The LCD footprint I'm using is from the Sparkfun library, so I'm sure theirs would work....they're just a little pricier. I'm not using the backlight, so that isn't an important feature to look for (unless you want to add it). You'll also need a row of 16 pin headers to connect the LCD to the pcb. I got mine from Digikey because they had cheaper shipping for a smaller order, but you could easily find the same thing anywhere. I used 4-40 screws to attach the LCD to the pcb before soldering, and these can be obtained at any hardware store.
Ordering enough for 10 of these, it made sense for me to look for better prices and pay extra to ship from a few different places. You may want to see if you can find everything from one source.
Firmware
I have included the firmware that is on my copy of AVRphrase. It's separated out into files that handle different functional pieces. I went through and commented most of it. I used AVR-GCC in AVR Studio with the AVR Dragon during development. The fuse settings you'll need are listed at the top of main.c. Everything is original (or based on a Datasheet/Application Note) except for the LCD code, which is using the open source LCD library found here.
AVRphrase_Wordloader
The wordloader was written using Processing 1.2.1 and relies on the Serial library to communicate with AVRphrase. This program will go through the different serial ports and send a connect character. AVRphrase will respond, and then it will select that port. If you have other ports open and in use, it will fail. I'm pretty sure there's a way to use a try--catch statement to handle that, but you could also hard code it to the port you want. This was intended to be used by people who wouldn't have any idea what port they needed to use or how to change it. The wordloader handles some basic user errors, but I still find things going wrong sometimes. It worked consistently on my computer, but I had to slow down the baud rate considerably (19200 to 4800) to yield consistent performance on the other computers. I've tested it on XP, Vista, and Windows 7, and it works fine on all three now. The Processing sketch is cross platform, but the USB drivers are what's killing Mac. Linux works fine as well, you just have to do a little more configuration (described at the MCP2200 product page Linux readme). This code is much less heavily commented than the firmware. It will take a few minutes for the upload to complete.
Cad
Polycase was kind enough to provide me with CAD files for the cases I purchased. I used AutoCAD WS to edit one and add the holes for buttons and LCD. It's a pain to use, but I didn't have access to anything better. I used Free DWG Viewer to print a 1:1 scale copy of this, and then taped it to the top of my case. I cut out the cases with a Dremel tool. You'll also need a small hole on the side for the USB connector.
User_Manual
The user manual is written from a non-technical perspective and is intended to show the end user how to play the game and how to go about loading new word lists.
Pictures
I have included some pictures of AVRphrase that you can use for reference if you want to build your own.
Configuration and Programming
Once you have assembled your AVRphrase, you will need to go through a few steps before it is ready to play. The first is to program the Fuse bits on the microcontroller, and then program the firmware onto the microcontroller. When you connect AVRphrase to your computer, you will need to install the USB Driver and use the Configuration Utility (found on the same page) to set the baud rate to 4800 and enable Tx/Rx LEDs. Once this is complete, you can use the wordloader to upload a wordlist, and then your AVRphrase is ready to play.
You can contact me by commenting here or emailing me at zjonesengineering@gmail.com if you have questions, but the level of support I can provide is minimal.
No comments:
Post a Comment