![]() |
||
![]()
MISC
SKILLS
HARDWARE
SCIENCE |
This quick tutorial will teach you why and how to upgrade your microcontroller for The $50 Robot to work faster and store larger programs.
Specific Differences Between ATmega8 and ATmega168
The first difference is that the ATmega8 can run at a maximum 16Mhz while the ATmega168 can run up to 20Mhz maximum. To run at this maximum value will require an external crystal oscillator.
Otherwise,
The $50 Robot by default uses the slow internal oscillator. This is plenty fast already for most applications. If you ever require complex math capabilities (floating point math, for example), or you are doing serious computation as with mapping or computer vision, then you might need the faster processor. The next major difference (the most important one) is flash memory size. The ATmega8 comes with 8k while the ATmega168 comes with 16k. As you start to create more advanced robots you will quickly realize that 8k is barely enough memory to do what you want. The last major difference is price. Mouser.com lists ATmega168 part # 556-ATMEGA168V10PU for $4.11 while list ATmega8 part # 556-ATMEGA8L-8PU for $3.66. Ok so not that big of a difference, but now you know part numbers and where to buy them at . . . Update: The ATmega328P is the latest and greatest. It sports twice the memory as the 168, but is a bit more expensive. Its a drop in replacement, meaning its pin-for-pin.
How Do I Know That My Robot Needs More Memory?
c:\program files\winavr\bin\..\lib\gcc\avr\4.1.1\..\..\..\..\avr\bin\ld.exe: region text is full
How do I Upgrade?
If you were using the PonyProg method of programming, you will need to download the newest version of PonyProg2000: v2.07c BETA. I have not tested this version on the ATmega8, but it should still work. Previous PonyProg versions will not work with the ATmega168. If you always used AVR Studio to upload your code, just ignore this step. The last step is to make a few quick changes in your source code. In your file called 'makefile' (check your source code folder), look for a line that says this:
# MCU name
and change it to:
# MCU name
Next, also in the makefile, look for a line called timer.c and change it to timerx8.c. If you are not using this file, don't worry about it. Then in the file SoR_utils.h, look for a line that says #include "timer.h" and change it to #include "timerx8.h". If you do not have these new timer files, the $50 Robot source code has been updated with them. The global.h file should also be modified since it contains a F_CPU define, depending on if you use the makefile to overwrite that value or not. The compiler will know what to do and handle the rest automatically for you.
What if I Want to Use a different ATmega?
I will not go into detail explain this, but look at the section called CONFIGURE PORTS in the SoR_Utils.h file. With a little thought, it shouldn't be too hard to reverse engineer it. In that same file you will see lines such as PORT_OFF(PORTD, 4); that should also be changed to do what you want. |
|
Has this site helped you with your robot? Give us credit -
link back, and help others in the forums! Society of Robots copyright 2005-2014 |