RC Quadrotor Helicopter by frank26080115
Contest WinnerFeatured

Step 10: Preparing the Microcontroller

arduino-logo.png

If you don't have the Arduino IDE, download it and install it. I am using version 0022.

The following steps are explained in detail in this wiki article: http://code.google.com/p/ro-4-copter/wiki/GeneralSoftwareSetup
This page is just a really short summary of what is already in the above wiki article!

The Arduino bootloader should be programmed into the microcontroller first. This step requires the use of an AVR programmer. However, after the bootloader is flashed into the microcontroller, you will only need an USB-to-serial cable (such as an FTDI cable) to upload code from the Arduino IDE.

The bootloader (I've attached it) is modified slightly since I'm using the ATmega644P instead of the usual Arduino's ATmega328P. The files are provided. The fuse-bits need to be written to the correct values as well.

AVRDUDE is the utility that we use to flash the bootloader .hex file into the microcontroller. The AVRDUDE commands you'll need is

"avrdude -c programmer_name -p atmega644p -U flash:w:bootloader_filename.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m"

Pay attention to the programmer_name and the bootloader_filename! The fuses are to get the ATmega to use the 16 MHz resonator, set the bootloader size, enable the bootloader, disable JTAG and enable SPI downloading.

Also copy the bootloader folder "Ro4Copter_Boot" (remember to rename it without the date version) as .../arduino-0022/hardware/arduino/bootloaders/Ro4Copter_Boot.

Also, download the Arduino "core" I've provided here (called Ro4Copter_Core, remember to rename it without the date version), and place it into the "core" directory within Arduino so you get .../arduino-0022/hardware/arduino/cores/Ro4Copter_Core . Also modify the boards.txt file to include an entry to use this core. This will allow the Arduino IDE to compile for the ATmega644P instead of the original Arduino's ATmega328P. Be sure to select the correct board entry inside the Arduino IDE menus. For more details on this step, check out the wiki page I linked above.

The board.txt entry:
 

Ro4Copter.name=Ro4Copter
Ro4Copter.upload.protocol=stk500
Ro4Copter.upload.maximum_size=57344
Ro4Copter.upload.speed=57600
Ro4Copter.bootloader.low_fuses=0xFF
Ro4Copter.bootloader.high_fuses=0xD8
Ro4Copter.bootloader.extended_fuses=0xFF
Ro4Copter.bootloader.path=Ro4Copter_Boot
Ro4Copter.bootloader.file=Ro4Copter_Boot_arduino.hex
Ro4Copter.bootloader.unlock_bits=0x3F
Ro4Copter.bootloader.lock_bits=0x0F
Ro4Copter.build.mcu=atmega644p
Ro4Copter.build.f_cpu=16000000L
Ro4Copter.build.core=Ro4Copter_Core


Here's a screenshot to show you where all these folders are:


The sketch you need to compile is provided in step 26. Compile it and upload it to the ATmega644P using the bootloader later.

The next few steps will help you understand what exactly the code is doing. Skip them if you don't care.
 
Remove these adsRemove these ads by Signing Up
namdari90 says: Dec 2, 2012. 7:04 AM
hi
i cant use avrdude is there any other program to use the bootloader and please if you can explain how to use avrdude and plz plz upload the docs in any site other than google code because i cant use google code if you can please email it to me
evantkaufman says: Jun 1, 2012. 3:25 PM
When I try to used AVRDUDE in the Microsoft command window, I'm getting the response that "The filename, directory name, or volume label syntax is incorrect." When I copied and pasted your command above, I chose programmer_name to be stk500 and the bootloader_filename.hex to be Ro4Copter_Boot_arduino.hex. Is this incorrect? Any help would be greatly appreciated.
frank26080115 (author) says: Jun 2, 2012. 2:36 AM
try splitting the command up into several parts, and figuring out which part of the command is causing the error
evantkaufman says: Apr 20, 2012. 10:52 PM
When you flash the bootloader for the first time, does the circuit require power or is power provided through the AVR programmer?
frank26080115 (author) says: Apr 20, 2012. 11:43 PM
Both methods would work
gaurav_sharma132 says: Mar 6, 2012. 4:30 AM
Thank for your reply.

What if I want to program my ATmega328 through Atmel AVR Studio ?

gaurav_sharma132 says: Feb 28, 2012. 12:50 PM
Why we need Bootloader. We can burn it using serial port as it has ISP. Please elaborate.

I know it is very basic question. But please answer.

Thank you very much
frank26080115 (author) says: Feb 28, 2012. 1:06 PM
I find it easier to use the bootloader, there is no real reason, go ahead and use an ISP if you want, but I prefer to use only one USB cable with my laptop.
devilmaycry says: Jul 30, 2011. 7:43 AM
(removed by author or community request)
frank26080115 (author) says: Jul 30, 2011. 5:31 PM
I don't understand your question
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!