Society of Robots
Search and Index
MISC
 Parts List
 Robot Forum
 Chat
 Member Pages
 Axon MCU
 Robot Books
 Shop
 Contact

SKILLS
 How To Build
  A Robot
  Tutorial

 Calculators
 Mechanics
 Programming
 Miscellaneous

 Robots
 Space

HARDWARE
 Actuators
 Batteries
 Electronics
 Materials
 Microcontrollers
 Sensors

SCIENCE
 Robot Journals
 Robot Theory
 Conferences


    Axon II Microcontroller

    GETTING STARTED
    Installing Software


    Part #1: Installing Software
    Part #2: Setting up Hardware
    Part #3: Using the Bootloader

    NOTE: THIS IS THE OLD SETUP INSTRUCTIONS
    TO SEE NEW INSTRUCTIONS CLICK HERE.

    Although the Axon II can be setup just like the original Axon, the new method offers many advantages.


    STEP 1: Install WinAVR

    While waiting for your Axon II to arrive in your mail, here are several programs you need to download and install to make full use of your Axon II microcontroller. Follow the self-explanatory installers.

    WinAVR will install the GNU Compiler and a ton of useful utilities. On the download page, select the latest release (bottom of list).

    WinAVR (22mb)

    Version 20090313 has been verified to work with the Axon.

    WinAVR


    STEP 2: Install AVR Studio

    AVR Studio is an IDE, assembler, and programming software all in one. When you want to write and compile code, this is the software you will be using.

    AVR Studio, version 4.17 (112mb)

    Further AVR Studio upgrades (untested by SoR) can be found on the AVR Studio Download page. Or for direct links to download tested upgrades go here. Because AVR Studio is not compatible with Mac or Linux, you might find this post and this post helpful. If you use Vista 64 bit, read this and this. And here are instructions for programming the Axon using Ubuntu.

    AVR Studio


    STEP 3: Download WebbotLib

    WebbotLib is a new powerful library for AVR-based microcontrollers such as the Axon and Axon II. It offers many advantages over the original Axon library.

    WebbotLib:
    - open sourced
    - supports many robot sensors/hardware
    - compatible with other microcontrollers
    - SoR supported
    - easy to use
    - large supporting community

    Everything you need to know about WebbotLib is in the WebbotLib manual (included in download as pdf).

    1) To install, first download the latest version here:

    download WebbotLib (4mb)

    2) create a folder called WebbotLib. Make sure there are NO spaces in the file/directory name. For example, do not do
    'C:\Documents and Settings\User\Desktop\Robot . . .'

    Also, the project file name must be the same name as the initial file. These are 'features' (bugs) in AVR Studio that will cause you problems otherwise!

    The recommended directory is:
    C:\My_Robots\WebbotLib

    3) Extract all files from the zip file into your folder.

      NOTE: The code for the original Axon is still supported by the Axon II. If you prefer to use the original code, refer to the original Axon manual for code installation instructions. There are two changes you need to be aware of. First, replace the SoR_Utils.h file with this one. Second, since pinout has changed, verify that your I/O commands are still valid. To use the LED display, call commands such as below:
      a_on(); //turn on LED a
      b_off();
      LED_all_off();
      LED_one(); //turn on #1
      LED_three();
      LED_on(); //turn on status LED
      

    WebbotLib is updated regularly - always try the latest version before reporting a bug. To keep updated, subscribe to this forum thread, but DO NOT POST SUPPORT QUESTIONS IN IT.


    STEP 4: Start a new Project

    Now we need to start a new project.

    Find the new AVR Studio 4 icon in your start menu, click, and you should immediately see this window come up:

    Select New Project

    Select 'New Project'

    The next window that comes up will look like this:

    Select These Options in AVR Studio

    Copy the options that I have chosen, but whatever file name you like. Remember to choose a file name and directory without spaces!

    Optionally, if you want a simulator (not required), click Next>> and choose these options:

    Select These Options in AVR Studio

    Click Finish. AVR Studio should now look something like this:

    AVR Studio


    STEP 5: Setup WebbotLib

    Now we need to tell AVR Studio to use WebbLib. Go to Project -> Configuration Options.

    Go to Configuration Options

    Set the microcontroller to ATmega640, frequency to 16000000 (16MHz), and optimization to -0O. No makefile. It should look like this:

    Configuration

    Now click the Include Directories icon, and browse for your WebbotLib folder. This tells AVR Studio where to look for your common files.

    Declare Includes Folder

    Lastly, we need to declare three more important library files. Click on the Libraries icon and add the WebbotLib folder as before. Next, use Add Library-> to add libWebbot-ATmega640.a. This file MUST COME FIRST. Then add libc.a and libm.a. Your window should look like this:

    Declare Library Files

    Push OK. WebbotLib is now set up to use.


    STEP 6: Add Source

    Now lets add some code to begin programming.

    Download the Axon2 example programs. Use the photovore sample code for this step.

    Copy/paste all code in Photovore.c into the .c file with the same name as your project (found in Source Files on the left). For example, if your project is called 'Axon2_WebblotLib', paste the code into Axon2_WebbotLib.c. Push the 'Save' icon at the top left in AVR Studio. This is the main() file.

    Now, right click 'Header Files' and left click 'Add Existing Source File(s)...'.

    Add Header Files

    Add hardware.h from the photovore example folder. You could also just drag and drop. If you ever create new files, only label them as .h. The compiler can get confused with multiple .c files and result in strange compiling errors.


    STEP 7: Compile Code

    The final programming step is to compile the code. This converts your code written in C to machine code in a .hex that only your specific microcontroller can read. You should do a Rebuild All the first time you compile the downloaded source code, or manually replace any program files. But after that, you only need to do the faster Build command.

    Build All

    If all went well, you should see this message after compiling. It shows you how much memory you have used:

    Compiled Output

    If you get errors, and you are new to programming, it may be a little difficult to debug at first. Go back and check to make sure you followed all the steps, especially properly naming the files (a common error).

    Note that a new .hex file can be found in your project folder. This is the compiled program that will be uploaded to your microcontroller. Whenever you modify your program, just click 'Build' and it will recompile a new .hex for you. Don't forget to Save before recompiling.

    Note: A common error you may get is

    "gcc plug-in: Error: Object file not found on expected location C:\Documents and Settings\User\My Documents\My_Robots\[your project name]\[your project name].elf

    Make sure your makefile specifies the output .elf file as [your project name].elf"

    If you get that error, it means you made a mistake naming your files. Start at the beginning, and read instructions more carefully.


    STEP 8: Save Everything

    Lastly, save your project configuration.

    Save AVR Studio Project Configuration


    Now that you are done setting up software, continue for
    Part #2: Setting up Hardware >>>



Get Your Ad Here

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
forum SMF post simple machines