Programming

Tools and Code

Here is what you'll need to program Prodos:

    • Arduino Development Environment : this allows you to write code and upload it to the microcontroller (Arduino Duemilanove) that runs the robot.

    • uOLED Arduino Library : this allows the Arduino to interact with the OLED

    • 4D Graphics Composer : this allows you to upload images to the MicroSD card that goes into the OLED

    • Prodos Control Code : this contains the code that controls Prodos (walking and menus)

Installation Instructions

Follow the instructions below to set up your computer to be able to program Prodos:

    1. Install the Arduino development environment.

    2. Move the Menu folder from the Prodos Control Code into the libraries folder for your Arduino installation:

      1. example : "C:\Projects\Biped\Controllers\arduino-0022\libraries\Menu"

    3. I couldn't figure out how to get the relative linking to work properly for the Menu libary,

      1. so the following changes will need to be made in the code files:

      2. in Menu.h:

      3. change the path in line 19:

      4. #include "C:\Projects\Biped\Controllers\arduino-0022\libraries\Servo\Servo.h"

      5. to whever your Arduino installation is

      6. #include "<your Arduino installation directory>\libraries\Servo\Servo.h"

      7. in Menu.cpp:

      8. change the path in line 18:

      9. #include "C:\Projects\Biped\Controllers\arduino-0022\libraries\uOLED\uOLED.h"

      10. to whever your Arduino installation is

      11. #include "<your Arduino installation directory>\libraries\uOLED\uOLED.h"

      12. change the path in line 19:

      13. #include "C:\Projects\Biped\Controllers\arduino-0022\libraries\Servo\Servo.h"

      14. to whever your Arduino installation is

      15. #include "<your Arduino installation directory>\libraries\Servo\Servo.h"

    1. Remove the jumper connector on the OLED board (the jumper puts the display in slide show mode)

      1. Make sure to copy the uOLED folder to the libraries folder in your Arduino installation

      2. example : "C:\Projects\Biped\Controllers\arduino-0022\libraries\uOLED"

      3. install the images file (data.gcs) for the OLED.

      4. Open up the graphics composer

      5. example : "C:\Projects\Biped\Controllers\arduino-0022\hardware\oled160\GraphicsComposer\GraphicsComposer.exe"

      6. from the main menu :

      7. File->Open

      8. Navigate to data.gcs (it is in the same folder as this text file)

      9. insert the microSD card into your computer (use the converter card if necessary)

      10. upload the images to the card

      11. *note that for adding new images to the card : use 96x64 pixel png files. When adding new files you'll need to type in "*.png" in the browser dialog to see the png files because it only looks for jpg files by default (and jpg files get horribly compressed when it loads them).

Discussion

The code for Prodos is composed of the following files:

Menu.cpp : This is the code file for the Menu library (for Arduino). It contains most of the code that runs the robot. It has several classes that provide structure for the menu system and animation.

Menu.h : This is the header file for the Menu library (for Arduino). It defines all of the classes used in the library.

keywords.txt : This text file defines key words used in the Menu library. It is used by the Arduino Development Environment to be able to highlight key words and prevent duplicate names.

prodos_control.pde : This is the Arduino code file that sets up the graphical user interface (GUI), and controls the walking animation. It uses the Menu library.

data.gcs : This is an images file (in the Graphics Composer format) that contains all of the images needed to display the animations and menus for Prodos.

Writing code for the Arduino is done using the C++ language and there are lots of good tutorials online. There are also several tutorials that come with the Arduino Development Environment (File->Examples). You won't need to do any coding to get Prodos working, as all of the necessary programs have already been written. However if you'd like to modify or extend the functionality of Prodos feel free.

Basic tasks such as sensor reading, servo position setting, and OLED output can be accomplished by adding a few commands to the loop method in an Arduino program (such as prodos_control.pde). Advanced functionality (such as nice menus) comes from writing classes and leveraging the object oriented features of C++. A good place to put classes is in custom Arduino libraries ... which is where most of the code for Prodos lives (in the Menu library).

The Arduino has a limited amount of memory, so be careful about how much memory you use in code. I had to remove several features of Prodos because the memory was full. When the memory is full unpredictable behavior can result and is difficult to debug. To get around this issue in future prototypes the control code will be shifted to a more capable processing platform (such as Android or PC) and the Arduino code will simply route commands to the servos and pass back sensor information.