Here's a few quick notes that will help you program your own Arduino-compatible boards for first-time use. This is just for people building their own boards. If you bought ArduPilot or BlimpDuino pre-made, all this has already been done for you, so ignore this.
Here are the necessary steps to load firmware onto the Atmega chip:
1) You'll need an ICSP AVR programmer and a FTDI cable. We recommend AVRSIP2 [shown] or USBTinyISP for the former and the Adafruit cable for the latter. Connect the cable to the ICSP port on your board [on ArduPilot it's the one marked "AT168"]. The red stripe on the cable should be on the same side of the connector as the square solder pad on the back of the board. (On our boards that means that the red strip is on the side closest to the processor)
2) Now you'll need to change (turn off) one of the default "fuse" settings in the Atmega, which divides the internal clock by 8 so it only runs at 1 Mhz. (Explanation of all that and more about fuses are in the excellent Sparkfun tutorial here). For that you'll need to download some special software. If you have the AVRSIP2 programmer, it came with AVR Studio, which is excellent. If you got the USBTinyISP, I recommend AVRdude, and instructions on how to get and install it are here.
3) To change the fuse with AVR Studio, connect the programmer and go to Tools/Program AVR/Connect. Choose AVRISP mkII. You may get an error (choose cancel). On the "Main" tab of the dialog, click the "Settings" button and pick 125khz, then click "Write". Then make sure "Device" is ATMega168 and "Read signature". At the bottom it should say that all's okay. If so, switch to "Fuses" tab and uncheck CKDIV8. Press "Program", then "Verify" to make sure it's working. Now you can go back to the "Main" tab and change the Settings to 2Mhz. You processor is working fine and ready to program.
To change that fuse with AVRDude call up the Windows command line CMD and enter the following command (this assumes you're using the USBTinyISP programmer; if you're using the AVRISP2, substitute "avrispv2" for "usbtiny"): avrdude -p m168 -c usbtiny -U lfuse:w:0xE2:m
4) Now you'll need to burn the bootloader. It's easiest to do this within AVR Studio. Still in the AVR Studio dialog box you used above, go to the Program tab. Where it says "Flash", input the correct bootloader file. For ArduPilot, that's the "ATmegaBOOT_168_diecimila.hex" file in your Arduino hardware\bootloaders\atmega168 folder. For BlimpDuino it's the "ATmegaBOOT_168_pro_8MHz.hex" in the same folder. Click "Program". All should go well and you'll see the OKs below.
If you don't have AVR Studio, you can do this within the Arduino IDE. We've found that it doesn't currently support the AVRISP2 programmer, but it does support the Adafruit one linked above. If you're using a crystal or resonator on your board (to run the processor at 16MhZ), select the Decimila board in the Arduino IDE [Note: this is the mode you should use for ArduPilot]. If you're not using any external frequency generator and are thus running on the Atmega's internal 8 Mhz clock, select "Arduino Pro or Arduino Mini (8mhz)" [Note: this is the mode you should use for BlimpDuino]. Connect the AVR programmer to the ICSP pins on the board and select "Burn Bootloader" with whichever AVR programmer you have. The IDE should freeze for about 15 seconds and then report that it's done that successfully. If it doesn't work despite a few attempts, you may have a wiring problem on the board. Each one of those ICSP pins connects straight to an ATmega pin as shown in the schematics, so it should be pretty easy to diagnose.
5) Now you should be able to upload Arduino sketches (ie, your program) from the IDE. Just remember to make sure you've selected the right board--Decimila if you're using an external frequency generator [ArduPilot] and Arduino Pro if you're not [BlimpDuino]. Both boards now support autoreset when programming, so all you should need to do is to press the "upload to I/O board" button in the Arduino IDE and wait a minute. [If for any reason autoreset isn't working you can manually push the reset button on the board every time you uploading code so the bootloader can "look" for the IDE.].
If this all seems a bit complicated, rest assured it's a lot easier to read and follow these instructions than it is to figure it out yourself over months, like Jordi and I did ;-) And remember, you only have to go through this once. After the Atmega is configured for Arduino, you can let the IDE take over all the hard work.
I know this is a very late post, but maybe you can help.
The USB is no longer seen when I plug in the cable.
I just managed to kill the U82 code on my Arduino Mega R2, probably when I plugged in the STK 500 to it's 6-pin header instead of the 2560's header (I'm guessing). Anyway, I've read that Flip 3.4.5 can re-program it, but attempting to load MEGA-dfu_and_usbserial_combined.hex results in an "address out of range" error. Is there a better file or method to use?
Thanks,
Alan
Can I load it with a newer version of AVR studio? the 8U2 was not listed on vers. 4 of the 'Studio.
I,m not sure if this is the right place and this is an old post I'm looking at. I also looked for a search box and used search social network .Is this the one I should be using?
Second question ,the chip that comes with Blimpduino is Mini or minipro with atmega168 . From the shop then what is the program that runs and lights all the LED's and flashes them when you first power it up .Very impressive satisfying stuff
Chris I have used the Parallax Propeller proto clip to program the Arduino Pro board. (I run Tx,Rx,Gnd out on separate wires with pins) and it works good. Can I program the ArduPilot the same way ? I just got the ArduPilot board today. I want to change some stuff with the Arduino.exe programmer that I loaded the Pro board with. What I want to experiment with is interfacing the Atomic 6DOF board.I think I need to hook to the ICP on the ArduPilot tho. I already tried pins 30 & 31 or is the ICP a special interface?
Earl
Hmm, I've read some techniques for SMD soldering before, but never that one. It doesnt sound too painful like that. I do intend to give it a shot eventually, I just haven't had a chance to practice at it yet.
The secret to SMD soldering is wick. Use a hot iron, use your sponge to clean the tip, and then run solder along all the leads. Don't worry if they're all glooped together. Then lay the wick along the row of leads, and hold the iron along the length of the wick. All the gloopy solder will magically disappear, leaving clean (and soldered leads).
Yes, you can use that programmer. We're actually using the ATtiny45 on the current board, but either processor will do. The avrdude command line to turn off the CKDIV8 fuse is:
avrdude -p t45 -c usbtiny -U lfuse:w:0xE2:m
[WARNING: The online fuse calculator that many people use has a bug and will give you the wrong value for this. If you use their value you will KILL your chip. Don't do it!]
That is the correct link to the firmware.
The command to load the firmware (make sure the hex file is in root directory) is:
A quick question...
Can I use the USBTinyISP to program the ATTINY85 on the Ardupilot board ?
Do you have the avrdude command line required to do that.
I think the source code for the ATTiny was posted but the link no longer works.
I am assuming that the servo switch hex file is the one to use.
( hope this link works) ServoSwitch.hex
Comments
just watched by a few -I can't answer your question
is this forum active?
Chris,
I know this is a very late post, but maybe you can help.
The USB is no longer seen when I plug in the cable.
I just managed to kill the U82 code on my Arduino Mega R2, probably when I plugged in the STK 500 to it's 6-pin header instead of the 2560's header (I'm guessing). Anyway, I've read that Flip 3.4.5 can re-program it, but attempting to load MEGA-dfu_and_usbserial_combined.hex results in an "address out of range" error. Is there a better file or method to use?
Thanks,
Alan
Can I load it with a newer version of AVR studio? the 8U2 was not listed on vers. 4 of the 'Studio.
Second question ,the chip that comes with Blimpduino is Mini or minipro with atmega168 . From the shop then what is the program that runs and lights all the LED's and flashes them when you first power it up .Very impressive satisfying stuff
Earl
Thanks Chris
The secret to SMD soldering is wick. Use a hot iron, use your sponge to clean the tip, and then run solder along all the leads. Don't worry if they're all glooped together. Then lay the wick along the row of leads, and hold the iron along the length of the wick. All the gloopy solder will magically disappear, leaving clean (and soldered leads).
Here's a video that shows how it's done.
Yes, you can use that programmer. We're actually using the ATtiny45 on the current board, but either processor will do. The avrdude command line to turn off the CKDIV8 fuse is:
avrdude -p t45 -c usbtiny -U lfuse:w:0xE2:m
[WARNING: The online fuse calculator that many people use has a bug and will give you the wrong value for this. If you use their value you will KILL your chip. Don't do it!]
That is the correct link to the firmware.
The command to load the firmware (make sure the hex file is in root directory) is:
avrdude -c usbtiny -p t45 -U flash:w:ServoSwitch.hex
Can I use the USBTinyISP to program the ATTINY85 on the Ardupilot board ?
Do you have the avrdude command line required to do that.
I think the source code for the ATTiny was posted but the link no longer works.
I am assuming that the servo switch hex file is the one to use.
( hope this link works)
ServoSwitch.hex
Regards
Phil