Wednesday, November 7, 2012

Arduino - burning chips, saving money...and an important tip!

No, not potato chips...'computer' chips you silly goose!

I'm always looking for ways to save money, and I recently used up one of my last ATMega328 (with the Arduino bootloader pre-programmed on it) chips in a project. I've always been under the impression that to burn the bootloader, it takes extra hardware (pre-built from a retailer) and complicated software configuration/setup.

It turns out it's pretty easy to burn the bootloader yourself. There's a great tutorial that shows you how to do it right on Arduino's website. All you need is an Arduino, a 16MHz crystal, a 10K resistor, and 2 18-22 picofarad (ceramic) capacitors.

Here's a screenshot of the part of the page that shows how to hook everything up:

Here's what it looked like on my breadboard(s):
(You don't need to use 2 breadboards...I was just running out of empty breadboards, so I used the mini-red one and one side of a pre-occupied one)

Where does the money savin' part come in? Well the point of all of this is that you can buy an ATMega328 pre-loaded with the Arduino bootloader on it @ Sparkfun for $5.50. (Note that this is for the Arduino Uno). Orrr, you can buy the chip with no bootloader @ Digikey for $2.88. So would you rather pay $5.50 for a chip with the bootloader already on it, or spend a couple of minutes and pay half that price? I personally would rather pay half the price...I have 2 minutes to spare usually. ;)

I do have 1 tip if you go the route of burning your own bootloader though. There are 2 ways you can set up your new chip on a breadboard. 1 way uses no external parts - just the ATMega328 itself (described at the bottom of their page). The other way (described at the top of their page) uses a few external parts which I mentioned at the top of this article. Go this route! It's a few extra parts to hook up, but it's worth it.

The reason I say go the route with a few extra parts is that the timing will match up with the Arduino board. I first tried the method without any extra parts, and when I put the chip back on my Arduino and uploaded a simple 'blink' sketch...it ran at what appeared to be 1/2 the speed. :( I'm assuming that because of the internal 8MHz clock of the chip 'conflicts' with the 16MHz crystal on the Arduino. But when you burn the bootloader the way I recommend, you use a 16Mhz crystal for timing, and I had no problems when doing it this way.

If anyone has any questions or comments about this, feel free to leave them. I am also curious if my theory about the timing difference is correct or not. (Regardless, the results are what matters in the end and now I know how I am going to burn the bootloader in the future)


No comments:

Post a Comment