Irobot COMMAND MODULE User Manual

iRobot® Command Module
OWNERS MANUAL
www.irobot.com
Important Safety Instructions
• Read all safety and operating instructions before operating iRobot Command Module.
• Retain the safety and operating instructions for future reference.
• Follow all operating and use instructions.
• Refer all non-routine servicing to iRobot.
COMMAND MODULE USE RESTRICTIONS
• The Command Module is for indoor use only.
• Do not sit or stand on this device.
• Keep the switch in the off position, otherwise the Create robot battery will drain when iRobot Command Module is on.
• Do not pour or spray water onto iRobot Command Module.
• Do not expose iR obot Command Module to
anything hazardous, or anything that is burning or smoking.
• iRobot Create has built-in safety sensors to keep it from falling down stairs and bumping hard into walls. iRobot is not responsible for any product issues that may arise if you disable those sensors using the Command Module.
• Never handle the Command Module with wet hands.
• Only experienced users should attempt to design and build their own circuitr y.
ePort SAFETY INSTRUCTIONS
The maximum voltage available on the ePort is 21V, so the ePor t pins will not shock you if they contact your skin. However, the ePort can supply over 20 watts of electrical power. In the event of an electrical fault, this can generate enough heat to burn you or start a fire in the event of an electrical fault. Only experienced users should attempt to design and build their own circuitry.Prebuilt ePort modules are available from a supplier listed in the Appendix A and are suitable for users who lack the experience to design their own circuitr y.
• Always use care when wiring custom circuitry to an ePort.
• Never run your iRobot Create unattended.
• Always fully test your new designs under close supervision.
• Always remove the battery from Create or remove the ePort add-on circuitry from Create before handling it.
• Never touch the circuitry with the power turned on.
• Enclose your add-on circuitry so it is not inadver tently shorted during operation.
• The Vcc and Vpwr supplies are protected by a self-resetting fuse within Create. If you exceed the current ratings, power Create off for 30 seconds to reset the fuse.
iRobot Command Module Owner’s Manual
2
Table of Contents
Introduction ...........................................................................................5
1.1 Anatomy .........................................................................................5
1.2 Overview ........................................................................................5
1.3 Example applications ......................................................................5
2. Getting Started ..................................................................................
2.1 Plugging in the Command Module ....................................................6
2.2 Running the preinstalled “drive” demo program ................................6
2.3 Installing the development tools ......................................................7
2.4 Installing the USB serial port ...........................................................8
3. Your First Project ...............................................................................
3.1 Developing for the Command Module ...............................................10
3.2 Setting up a new project ..................................................................10
3.3 Compiling your project .....................................................................11
3.4 Downloading your project over the USB link ......................................12
3.5 Testing the “input” example program ................................................13
3.6 Creating your own project ................................................................14
4. Software Reference ............................................................................
6
10
15
4.1 Declaring and using variables and registers on the ATMega168 .........15
4.2 I/O Pin Basics ................................................................................15
4.3 The Command Module’s connectors ................................................15
4.4 The Digital I/O control registers .......................................................16
4.5 DDRx: Setting the direction of a pin ..................................................16
4.6 PORTx: Setting pullups on an input pin .............................................16
4.7 PORTx: Setting the state of an output pin .........................................16
4.8 PINx: Reading the state of an input or output pin ..............................16
4.9 Using bitwise operators to selectively change bit values ....................17
iRobot Command Module Owner’s Manual
3
4.10 Command Module Internal Pins .....................................................17
4.11 Adding a button and LED to the input example program ...................18
4.12 Taking an analog measurement using the ADC ................................18
4.13 Using an analog measurement in the light example program ............19
4.14 Using a timer ................................................................................20
4.15 Debouncing a Button Input ............................................................21
4.16 Setting up and using the serial port ...............................................22
4.17 Using the USB Port for Serial Debugging ........................................23
4.18 Powering Create ...........................................................................23
4.19 Putting the Command Module to Sleep ...........................................24
5. Open Interface Reference ...................................................................25
5.1 Starting the Open Interface .............................................................25
5.2 Changing the baud rate ...................................................................25
5.3 Controlling Create’s LEDs ................................................................26
5.4 Composing and playing songs ..........................................................26
5.5 Moving Create ................................................................................27
5.6 Controlling Create’s low-side power drivers .......................................27
5.7 Sending an Infrared Character .........................................................28
5.8 Reading Create’s sensors ...............................................................28
6.Microcontroller reference .....................................................................29
7. Bootloader reference ..........................................................................30
8. Hardware reference ............................................................................31
8.1 ePort Pinouts .................................................................................31
8.2 ePort I/O connections .....................................................................31
8.3 ePort connection types and interfacing .............................................32
8.4 ePort electrical specifications ..........................................................33
8.5 ePort safety and cautions ................................................................33
8.6 Component Suppliers ......................................................................34
iRobot Command Module Owner’s Manual
4
1
Introduction
1.1 Anatomy
Top Left ePort
Soft Button
Reset
iRobot Create Connector
(under the Command Module)
LED 1
LED 2
Top Center ePort
Cargo Bay ePor t
1.2 Overview
The iRobot Command Module works with iRobot Create, giving you a way to write your own programs in C or C++ to control Create and to add custom hardware to expand Create’s capabilities without tethering the robot to a PC.
The Command Module plugs into Create’s Cargo Bay Connector, and it has four expansion ports that provide additional inputs and outputs for your custom hardware. Three of the connectors are on the top sur face, spaced to provide easy attachment points for an array of sensors, and one connector is on the back for easy access from the cargo bay.
The Command Module is powered by an Atmel AVR ATMega168 microcontroller which can be reprogrammed by downloading programs from your Windows XP computer with the included USB cable. Your programs can use the iRobot Open Interface serial protocol to control Create’s motors, lights, and speaker, and read its sensors. At the same time, the microcontroller can directly inter face with your own custom hardware through its I/O connections. Start with one of the example programs and expand and change it to add your own functionality. Updates and more information are available at www.irobot.com/create.
This manual assumes intermediate knowledge of the C or C++ programming languages, including bitwise operators. If you don’t know either of these languages, pick up a book on C from a library or bookstore. You can also find a lot of good reference materials and tutorials online by searching for “C language” in an internet search engine.
Hold Down Screws
Power LED
Power Switch
USB Indicator
USB
Top Right ePort
The manual also assumes a basic famili arity with microcontrollers, including I/O pins, regist ers, and interrupts, as well as experience with compilers and interactive development environments (IDEs).
For more information on how to use the Command Module’s software capabilities, please see the Software Reference chapter and the Open Interface reference guide found at www.irobot.com/create.
1.3 Example applications
Whether you are a hacker, educator, or robotics hobbyist, the Command Module opens many exciting possibilities. The applications are limited only by your imagination:
• Teach robotics and programming at high schools or universities. iRobot Create is a robust, affordable robotic platform that enables students to each have their own robot.
• Add new sensors and carr y out your own robotics experiments.
• Create a low-cost swarm of robots to investigate collective behavior.
• Have fun with robot “art” exhibits, song and dances or other entertaining behaviors.
• Add a camera and internet connection to create a low cost sentry robot.
iRobot Command Module Owner’s Manual
5
2
Getting Started
2.1 Plugging in the iRobot Command Module
Turn off Create.
Plug the Command Module into the Create’s Cargo Bay Connector as shown in Figure 1. Make sure it is firmly seated.
Command Module
Cargo Bay Connector
iRobot Create
Create Figure 1 Inser ting the Command Module into Create connector
Tighten the two hold-down screws on either end of the Command Module with a Phillips head screwdriver, as shown in Figure 2.
2.2 Running the preinstalled “drive” demo program
The Command Module comes pre-installed with a demo program to let you know that everything is working.
Turn on Create and wait two seconds until Create’s Power LED stops flashing, which indicates that Create is now running its main code.
Press the “reset” button on the Command Module and listen for a series of fast beeps. The LEDs on the Command Module and Create will blink slowly.
Place Create on the ground and press the black “soft” button on the Command Module. The robot will play another song and then star t driving around and flashing its LEDs in sequence, beeping and turning when it bumps into something. To stop the robot, press the “soft” button again or pick the robot up.
Troubleshooting:
• After turning on Create, always wait until Create’s Power LED stops flashing rapidly before starting a Command Module program.
• Make sure the Command Module is securely seated.
• Make sure that your iRobot Create has a full set of charged batteries (see Create documentation for more information on batteries).
• Disconnect the USB cable from the Command Module.
Command Module Hold-Down Screws
Command Module
Create Figure 2 Securing the Command Module with the hold-down screws
Philips-head Screwdriver
iRobot Create
iRobot Command Module Owner’s Manual
• Ensure that Create’s serial cable is not connected to its Mini-DIN connector.
6
2.3 Installing the development tools
The development tools provided on the included CD-ROM allow you to create your own Command Module programs. The Command Module uses the WinAVR set of open-source development tools to let you write your own programs in the C or C++ languages. The development tools include an editor, compiler, and a downloader for loading your program onto the Command Module. For more information on WinAVR, please check the project website at http://winavr.sourceforge.net
To install WinAVR on your Windows XP computer, perform the steps below. If you have a previous version of WinAVR installed on your computer, please uninstall it before proceeding.
NOTE: WinAVR places its access paths at the front of Window’s PATH environment variable. This can cause conflicts with application that use executables or dlls that are also in WinAVR (e.g. make.exe; tclsh84.dll).To fix this, after installing, move WinAVR’s paths to the end of the PATH environment variable. Open Settings>Control Panel>System, click on Advanced, click on Environment Variables, Select Path under System Variables, click on Edit, move C:\WinAVR\utils\bin and C:\WinAVR\bin to the end of the list (after a semicolon), and click OK 3 times. On one occasion, installing WinAVR wiped out the installer’s entire path. For safety, copy the value of your path variable to a spare text file in case you need to restore it later.
3. Click through the rest of the install screens, accepting
the defaults.
4. The last screen says that WinAVR has been installed
on your computer. The installation is now complete. Click Finish.
1. Insert the Command Module product CD into your computer. Start the WinAVR installation program (WinAVR-20060421-install.exe) by double-clicking on it.
2. Select your language.
iRobot Command Module Owner’s Manual
7
2.4 Installing the USB serial port
To install the drivers for the USB serial port, connect your Command Module to your PC using the provided USB cable as shown in Figure 3.
Included USB Cable
iRobot Create
Select the Install the software automatically option
USB Port on PC
USB Port on Command Module
Create Figure 3 Connecting the Command Module to your computer’s USB port
Command Module
The Command Module should be automatically detected and the New Hardware Wizard window will pop up.
Select Yes to allow Windows to connect to Windows Update
to find the driver.
It should install the driver and return without errors saying that the hardware is installed and ready to use.
If the wizard says that it is unable to find the software, quit the wizard and open the Command Module product CD. Install the drivers manually by double-clicking on CDM_Setup_32.exe (if you have 32-bit Windows XP) or CDM_Setup_64.exe (if you have 64-bit Windows XP).
iRobot Command Module Owner’s Manual
8
The New Hardware Wizard window will then pop up a second time, showing that it has found a USB Serial Port. Repeat the above procedure, again selecting the Install the software automatically option. Once the driver installation has completed, click the Finish button and proceed to the next step.
Next, find the COM port number which was assigned to the Command Module.
On your PC, go to Start->Settings->Control Panel->System.
Go to the Hardware tab and click the Device Manager button.
Scroll down and expand the Ports (COM & LPT) category by clicking on the + sign.
Select the Port Settings tab and then click on the Advanced button.
Double click on the USB Serial Port line to launch the properties window.
iRobot Command Module Owner’s Manual
Change the COM Port Number to COM9 or another unused port between COM1 and COM9 using the pull-down menu. Using a high port number will reduce the chances that the port setting will interfere with other hardware that you may install on your computer in the future. All of the example programs assume that you are using COM9. If you use a COM port other than COM9, you will need to update the example program’s makefile before you download to the Command Module. The installation is now complete.
9
3
Your First Project
The example programs are a good place to star t using the Command Module. The program that came preprogrammed on your Command Module is called drive and its source code is in the “Sample Projects” directory on the Command Module Product CD. This chapter will guide you through compiling and downloading one of the other example programs named input, and will then give you directions for creating your own project. The input example program is designed to demonstrate how to use all of the Command Module’s input and output capabilities using buttons and LEDs.
3.1 Developing for the Command Module
The Command Module is built around an Atmel AVR ATMega168 microcontroller. All of the programs that you write and load onto the Command Module are run on this 8-bit processor. For more information on the microcontroller, please see the microcontroller reference section in chapter 7 and the microcontroller spec sheet on the Product CD.
The Command Module uses the WinAVR suite of open source development tools to compile and download your C or C++ programs. The WinAVR tools include the GNU GCC compiler, avrdude downloader, and the Programmers Notepad IDE.
3.2 Setting up a new project
In this example, you will set up a new project for the input example program. The steps are similar for any new project you create.
1. Get the source files. Make a new directory on your computer and name it “input.” Copy the files input.c, oi.h, and makefile from the examples/input director y on the Command Module CD to this director y. The file input.c is the main C source code file, oi.h is the Open Interface header file, and makefile contains instructions for Programmers Notepad on how to compile and download the project.
2. Start Programmers Notepad using the desktop shortcut. If you don’t have the shortcut, find Programmers Notepad direct ly a t C: \W inAVR\pn\pn.exe (if you used the default installation directory)
The WinAVR installer installs a lot of useful documentation in the C:\WinAVR\doc director y. In the avr-libc sub-directory you’ll find the avr-libc user’s manual, which has information on many functions designed for AVR microcontrollers which you can use in your programs. Another good resource for developing with AVR microcontrollers and using WinAVR in particular is the avrfreaks website at http://www.avrfreaks. net. One of the best sources of information on the website is the forum, where you can find answers to most of your development questions. Be sure to search the forum before posting your own question because most common questions have already been answered already.
3. Create a new project. In Programmers Notepad, go to File->New and click on Project.
iRobot Command Module Owner’s Manual
10
4. Click on the … button to select the project directory where you saved the project code (in step 1). Fill in a name for your new project (such as “input”), and click the OK button.
5. Add files to your project. Your new project should now show up in the upper left-hand window of Programmers Notepad.
Right click on the name of the project under New Project Group and select the Add Files option.
In the dialog box that opens, find your “input” project directory, select the file input.c, and click the Open button to add it to your project. The file you just added will now show up beneath the project name.
Repeat these steps to also add oi.h and makefile to your project.
3.3 Compiling your project
iRobot Command Module Owner’s Manual
In Programmers Notepad, double-click on one of the source files that you added to open it.
Click on Tools->[WinAVR] Make All. Text will appear in the output window at the bottom of Programmers Notepad showing the results of your compilation.
This output window will also list any errors and the line numbers where they occur in your files. You should not get any errors with the provided example programs, but errors may occur as you develop your own code. If there are any errors, fix them and compile again.
You can edit your text files in Programmers Notepad (see the File menu), or you can use any other text editor to change your files and just use Programmers Notepad to compile and download your projects.
11
Loading...
+ 23 hidden pages