In which we burn an arduino boot loader onto the ATMega, and then upload our own programs.
Note: this is the final part of a series of posts describing how to create an arduino-compatible board from scratch for very little money. You can find the previous posts here:
BURNING THE BOOTLOADER
This section describes how you can easily burn a bootloader onto the stock ATMega chip in your new circuit using nothing more than your existing Arduino Uno (or older board), a few wires and one component. You do not need an external programmer device.
Wait, what IS a bootloader?? – Good question. The bootloader is a small program that is run whenever the chip starts up, and, for a few seconds, it waits and listens to see if you want to upload a new sketch. If it doesn’t get an upload, it just runs the sketch that’s already resident on the chip.
N.B. it is possible to buy ATMega chips with the arduino bootloader already burned onto them (obviously they cost more). If you have one of these, you can skip down to “Uploading a Sketch to the Board”
So, grab your “real” arduino and load up the normal arduino IDE on your computer. Load the ArduinoISP “sketch” from the File -> Examples menu option and upload it. Now connect up your new circuit to your arduino according to the image below (click to show larger in a new window).
The picture might not be as clear as it might be with all those wires floating about, so here are the connections:
|Arduino Pin||New Board|
|13||row 17, right hand side, on the stripboard (i.e. connects to pin 13)|
|12||row 16, right hand side, on the stripboard (i.e. connects to pin 12)|
|11||row 15, right hand side, on the stripboard (i.e. connects to pin 11)|
|10||hold this wire against the RESET pin when burning the bootloader (i.e. row 8, left-hand side)|
|5V||take to an external breadboard, and take another wire from the same breadboard track to the female header on the left side of the new board, row 8 (i.e. +5V)|
|GND||connect to the header on the left of the new board, row 6 (i.e. GND)|
Finally we need to add a component to defeat the “real” arduino’s auto-reset feature as this gets in the way of the bootloader-burning sketch. For an Arduino Uno (which I’m using), you’ll need to take a capacitor (electrolytic, so make sure you have the polarity right) from the +5V we’ve got on the BREADboard (not the stripboard). Connect the other end of this to the Uno’s RESET socket. If you’re using an older arduino, I understand a 120 ohm resistor will work in place of the capacitor.
Once you’re all hooked up, and you’ve got the ArduinoISP sketch loaded on your “real” arduino, change the board on the IDE to the one you’re burning TO – I’m burning an ATMega 168 so I select “Arduino Diecimila, Duemilanova or Nano w/ ATMega 168” from the Tools -> Board menu.
Then make sure you’re holding the reset wire (the white wire that’s labelled in the picture) against the RESET pin on your new board, and select Tools -> Burn Bootloader -> w/ Arduino as ISP from the menu.
If all is connected correctly, you should see the TX/RX lights on your “real” Arduino flash for a couple of minutes, then the IDE should report “Done burning bootloader“.
NOTE (30-JUN-2012) – if you hit errors like “avrdude: stk500_getsync(): not in sync: resp=0×15″ at this step, try using the Arduino 1.0.1 version IDE – this cured it for me.
Congratulations – we’ve made an Arduino! Next step will be programming the thing.
UPLOADING A SKETCH TO THE BOARD
“Real” arduinos normally have a USB socket on them to allow you to connect the board to your computer to allow you to upload “sketches” (i.e. your programs). As this is a designed to be a dedicated circuit, adding extra USB circuitry would be a waste and an unnecessary complication.
Therefore we are going to need to use something to convert USB to serial (which is what the chip “speaks” natively). Here are a couple of suggestions:
http://www.sparkfun.com/products/10008 – this is the one I’m using, I’ve soldered male header pins onto it so it plugs directly into the serial header on the circuit we’ve made.
Alternatively there are complete cables, e.g.:
Both of the cables mentioned above have female ends – when using one of these I usually use a 6 pin male to male adapter I made by soldering two six pin male headers back-to-back to convert it to a male end. You could of course use a male header on the circuit we’ve just made, but it’s easier with the female header to connect up for bootloader burning etc. Your choice!
So, with my FTDI Basic Breakout board plugged into the serial connector on our board (note which way round it goes – “BLK” on the breakout board corresponds to row 6 (i.e. GND) and a USB mini cable connecting that to my PC, I should have be able to upload sketches. Note that on the IDE I need to select “Arduino Diecimila, Duemilanova or Nano w/ ATMega 168″ as the board type (as I used an ATMega 168) and the serial port is different from the usual one that shows up for the Uno – it’s /dev/ttyUSB0 (I’m running this on Linux).
I could now load up the Blink “sketch” and upload. But here’s a little “gotcha” – we don’t have any way to automatically reset our new board when uploading – we’ve not connected up the required line on the serial connector. I haven’t bothered with this because, for some reason, I found it very temperamental, and older arduinos didn’t have an auto-reset anyway. But to upload a sketch the board needs to be reset (because, as I explained earlier, that’s the only time that the bootloader is listening).
So here’s how to upload without problems every time… hold down the reset button on your new circuit, press the upload button on the IDE (or press Ctrl-U), then, only when you see the message “Binary sketch size: xxx bytes (of a xxxxx byte maximum)” pop up in the bottom black window (indicating it’s compiled and is about to upload), immediately let go of the reset button. This ensures the board is reset at just the right time. If you timed it correctly, you should soon then see the “Done uploading” message, and you’re done!
Try testing your board with the Blink program and connecting pin 13 to an LED with suitable resistor.
I hope this little series has been useful – if you have any comments, suggestions or have spotted any errors then feel free to leave a comment. It’s been fun – cheers!
By the way, “Vero” is a trademark of Vero Technologies Ltd, UK.
The text and images in this series are Creative Commons licensed – if you wish to use them for non-commercial purposes, go ahead – please just prominently label what you use with a link back to this site!
This VeroBoardUino Tutorial is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.