Wednesday, November 30, 2011

Happy (belated) Thanksgiving!

Thanksgiving was just last weekend and it is a neat USA holiday where we get together as a family, eat way too much and reflect on what we are thankful for. I am thankful for many things: family, friends, health.... the usual stuff, but I am also thankful for my Blogs readers. I started this Blog over a year ago and since June it has just taken off.

In June I was pumped to have a couple hundred hits on my blog a month.... I mean how many people want to read about some guy in Minnesota, USA Rant about his Electronics endeavors. I was surprised that over just a few months time it has grown to over 2,000 hits a month and keeps growing. This is a huge incentive and mental push to get me off my butt and working on fun side projects in my home lab. This is also a huge testimony to the true power of the Internet connecting people all over the world. I love and appreciate all the connections and contacts I have made all over the world through this blog.

Thank you all for your support! I have many cool project ideas for the coming year and thanks to you all I have the drive to get them moving!

Happy (belated) Thanksgiving!

Saturday, November 26, 2011

ProtoStack ATmega328 Kit Review (Arduino Clone Build)

Back in October I managed to get my 7400 Logic PLL Based Switcher in the third place category of the Dangerous Prototypes Open 7400/4000 Series Logic Contest. Dangerous Prototypes had the neat idea to let the winners pick their own prizes from the many sponsor donated kits & parts; that way everyone gets something they want. I picked out one of the 3x ProtoStack ATmega328 Developments Kits they donated. I've been messing around with my Arduino Uno for a while and was looking to expand my Atmel AVR knowledge a bit and thought building up this kit and turning it into an Arduino clone would be a fun project. I figured I'd give a little review of the kit as I went along as well.

The ProtoStack ATmega328 Development Kit came in a well packaged antistatic bag that had individual heat sealed sections for the PCB and components. I also got a free USBasp programmer which I was not expecting (Thanks ProtoStack!). I did have an Atmel JTAG ICE mk-II that I was planning on using to program the ATmegga328, but the USBasp is a bit more compact and I thought I'd use that instead.
The ProtoStack User's Guide for the ATmega328 kit is very well laid out and is easy to follow. They have put a lot of effort documenting different build configurations to easily change how the board is powered or programmed. They clearly document how to power the board with a DC Jack, USB Device, Coincell CR2032 Battery, or Terminal Block. They also show how to add board stacking connectors.
It took less than 30mins to solder up the kit. I did make a few small tweaks to my build. The kit comes with a 20MHz Xtal, but I wanted my board to be Arduino sketch compatible so I installed a 16MHz Xtal instead. I also added a ST Micro ST232CN RS232 level converter (connected to D0 [Rx] and D1 [Tx] and a DB-9 female connector. This RS232 connection allows me to use a USB-to-RS232 dongle to connect this kit to my computer and download sketches from the Arduino IDE. I love that the standard Arduino's come with the USB Device interface built in, but having a native RS232 interface on this kit helps me connect to all my legacy peripherals that still use RS232. I also connected up a Parallax 16x2 Serial LCD by hooking up the RX pin of the LCD display to the D1 [Tx] pin of the micro and hooking up 5V and GND of the display to the boards power rails.
For kicks I added one of Adafruit's cool ATmega 168/328 labels on the micro, so I don't have to grab the schematic or datasheet when doing a quick measurement or mod.
Overall I was extremely happy with how quickly the ProtoStack ATmega328 kit went together; my one complaint is that ProtoStack provides very little programming tutorial help other than pointing to several third party USBasp compatible websites/software. The struggle I had was all of these websites assumed the user had a basic understanding of programming Atmel AVR's which I didn't. All I had done before is used the Arduino IDE to program parts that already had the Arduino bootloader installed.... so that was my first step, I needed to use the USBasp to program in the Arduino bootloader then I should be able to use the RS232 interface to load sketches onto this board.

The first thing I did was download Atmel's AVR Studio for Windows. I got that installed and was surprised to find that even though the USBasp programmer had a windows driver it was not compatible with AVR Studio.... fail. So I grabbed my mk-II programmer I had gotten from a friend and was surprised to find that I could not get that to work either..... double fail. It turned out that the mk-II programmers USB Device interface was broken and it worked fine if I used its RS232 connection instead. This worked, but I wanted to get the USBasp programmer working, so I downloaded a few other free Windows AVR programs.

I downloaded  WinAVR which is compatible with the USBasp, but it kept crashing and locking up on my Vista laptop. So I downloaded eXtremeBurner-AVR which ran fine, but it didn't have the ATmega328 in it's list of parts it was compatible with. At this point I gave up on finding a Windows compatible AVR program that worked with the USBasp and rebooted my laptop and started up my Ubuntu 11.04 Linux distribution.

I loaded AVRdude and started searching for tutorials on how to load the Arduino bootloader into blank parts with AVRdude. This wasn't too hard to find; Adafruit's LadyAda and Sparkfun all had well written tutorials to walk me through the process.

First thing I did was look in my Arduino IDE directory for the \arduino-0022\hardware\arduino\boards.txt file. This text file told me that for an Arduino Uno with an ATmega328 I needed to use the \arduino-0022\hardware\arduino\bootloaders\optiboot\optiboot_atmega328.hex bootloader file with the low fuses set to 0xFF, high fuses set to 0xDE, extended fuses set to 0x05, and the lock bits set to 0x0F. Cool, now I had all the info I needed to program the Arduino bootload into my board.

Next I needed to figure out how to use the USBasp with AVRdude. After plugging the USBasp into my laptops USB port I struggled a bit to get AVRdude to recognize that the USBasp was plugged in.

avrdude: error: could not find USB device "USBasp" with vid=0x16c0 pid=0x5dc 

After Google searching for clues as to why I couldn't get it to work I found many posts stating that the Linux permissions for the USBasp required AVRdude be run by the super-user (su) or root. I tried that and still wasn't having any luck. Using the lsusb command I could see that the USBasp programmer was being recognized but it looked like there was a PID & VID ID conflict error with libusb.

ID 16c0:05dc VOTI shared ID for use with libusb 

After trying to read the AVR forums for several hours to try and find a solution I remembered that some of my USB flash drives wouldn't work with Ubuntu when plugged directly into my laptop's USB ports, but worked fine when plugged into a 4-1 USB hub that was plugged into my laptop. So I tried plugging the USBasp into my 4-1 USB hub and once I got the permissions setup right it worked great!!!!! (Yeah now I was cooking!)

I loaded up the command shell and moved to the folder that had the optiboot_atmega328.hex file in it and typed in the following command into AVRdude:

avrdude -b 19200 -c usbasp -p m328p -F -v -e -U flash:w:optiboot_atmega328.hex -U efuse:w:0x05:m -U hfuse:w:0xD6:m -U lfuse:w:0xFF:m -U lock:w:0x0F:m

  • "avrdude" runs the program
  • "-b 19200" is the baud rate avrdude sends the data to the programmer
  • "-p m328p -F" sets the device to ATmega328p... the -F kills the warning i kept getting because I had a ATmega328 - no "F", but AVRdude doesn't have a non-F part in it's list of supported devices.
  • "-v -e" erase and verify the Flash of the part
  • "-U flash:w:optiboot_atmega328.hex" is the file we want to load into the device
  • "-U efuse:w:0x05:m -U hfuse:w:0xD6:m -U lfuse:w:0xFF:m -U lock:w:0x0F:m" sets all the fuse and lock bits. These bits configure the devices boot, xtal and configuration settings
Below is the output of AVRdude as the part is being programmed.

 A complete text file of the output is available here for download.

Now that I had the Arduino Uno bootloader loaded into the micro I loaded up the Arduino IDE and wrote a small sketch to display a message on the Parallax Serial LCD.
The one quirk with this Arduino clone implementation is I have to press and release the reset button at just the right time when downloading a sketch. As soon as the "Binary sketchsize......" message shows up I quickly press and release the reset button and 8 out of 10 times I can successfully download the sketch into my board. It is a timing thing, the Ardunio IDE only waits so long to receive confirmation from the bootloader running on the micro before it errors out on the IDE. If it fails to download it is no big deal I just try again and press and release the reset button. I have gotten pretty good and timing it just right.

Overall I am pretty happy with the ProtoStack ATmega328 Development Kit and would highly recommend anyone getting one. I am excited to build up a few new projects with this board; having the extra prototyping space without having to stack a proto shield is a huge plus. Thanks ProtoStack for sponsoring the 7400 contest and getting me this kit and USBasp programmer!
Also Thank You Dangerous Prototypes for putting on the contest! It was a lot of fun seeing all the cool project ideas.

Monday, November 21, 2011

An Analog Life - Remembering Jim Williams

I recently came across this video from the Computer History Museum describing Jim Williams - An Analog Life exhibit. YouTube Video Link

The video is a bit long (1hr 18mins), but worth watching. I clipped out 4 mins of the video and have that below. This is part of the actual video playing at the exhibit.

I also just got copies of two books Jim wrote. I am looking forward to reading these on my 30 hour+ plane ride to China and back in Dec.

My review of these books to come......

Friday, November 18, 2011

Altoids Fume Extractor

Lately I've been soldering quite a bit at home and thought a fan based fume extractor would be a good investment. I came across this MAKE video recently that describes how to build one that fits in an Altoids box.

I dug around in my junk box and found a 24VDC fan. This fan was a bit too deep to fit in a single Altoids box and still have room for a carbon filter, so I had the idea to solder two Altoids boxes together. One would house a 9V battery, the Switch and the Fan. The other box would house 1/2 a Pet Co. Aquarium Carbon Filter and one more 9V battery.

Below is what I came up with:

The two 9V batteries in series get me 18V which is a bit low for the 24V fan, but it still works well and uses parts I just had lying around. The two boxes soldered together solution worked out well because it stands up better and won't tip over as easily as the single Altoids box version would.

Now I can solder away all day and not get a sore throat from all the flux fumes!

Wednesday, November 2, 2011

Open 7400 Logic Contest Winners!

The winners of Dangerous Prototypes Open 7400/4000 Logic Series Design Contest were announced today. Check out the Link.

Congrats to all the winners! My project even managed a spot in the Third place group, very cool!

Thanks Dangerous Prototypes & Sponsors and thanks to all the Judges!