Now that you’ve learned how to program your Create (see Lesson 1) and wirelessly communicate with your Create (see Lesson 2), it’s time to explore the iRobot Command Module expansion ports—and expand your create. Armed with four ports, dubbed ePorts, the Command Module provides unprecedented access to the I/O pins of its onboard Atmel ATmega 168 AVR microcontroller.
The only trouble is how can you tap into these I/O pins?
While the jury is still out on the iRobot Command Module Breakout Board (#4818; suggested retail should be $5.99), Element Products sells the eProto board which can plug into any of the four Command Module ePorts. Priced at $4.95, eProto is supplied as a two-part kit: DB-9 male plug and a sweet 1 3/16 x 1 1/4-inch PCB. What’s so sweet about a PCB without any components? Plenty, you can add your own.
Assembly is easy enough—just solder the supplied DB-9 plug to the underside of the PCB. Done. Hey, time yourself; you just assembled an electronic kit is less than 5 minutes.
Ahh, but now the real fun begins, populating the 96 holes of the eProto PCB with your own components. Making this task even easier are the 18 solder pads that extend the 9 pins from the DB-9:
|Pin||# of Pads*|
*Remaining 6 pins, one solder pad each.
This arrangement enables you to use the other 78 solder pads for holding your components, while deriving power and reading the AVR’s I/O pins with the DB-9’s extension pads.
Show Me the Number
If soldering isn’t your cup of tea, but you’d like to monitor input/output activity on the AVR’s I/O pins, the Element Products eDisplay might be the answer. This $19.95 compact, 4-digit liquid crystal display (LCD) is an “intelligent" screen with its own on-board microcontroller that can be plugged into any of three Command Module’s ePorts (e.g., top left, top right, and top center; you shouldn’t use the cargo bay ePort).
NOTE: You can attach the eDisplay to the cargo bay ePort, but all characters printed on the screen will be upside down.
Supplied with a C code function library, the eDisplay can print 9 different combinations of alphanumeric characters with 9 built-in, high-level functions:
- Print 8-bit unsigned decimal numbers; example “128"
- Print 16-bit unsigned decimal numbers; example “1234"
- Print 8-bit unsigned hexadecimal numbers; example “FF"
- Print 16-bit unsigned hexadecimal numbers; example “FFFF"
- Print a blank display
- Print the word “PASS"
- Print the word “FAIL"
- Print the word “On"
- Print the word “OFF"
An example demonstration program, lcd4_exp.c, can be downloaded and compiled in WinAVR for evaluating each of the 9 built-in functions. Inside this demo program, there is a port “auto-detect" routine which locates the eDisplay’s ePort location. This routine consists of a simple series of five if/else if statements that examine each ePort for the presence of the eDisplay. Make sure that you paste this routine into your own eDisplay programs. Very handy.
NOTE: The eDisplay might not work with “some" hardware attached to other ePorts. This fault is a “feature" of the demo program’s auto-detect subroutine. You can circumvent this limitation by hard-coding the eDisplay’s ePort into your program.
Demonstration Program Correction: This include line in the eDisplay lcd4_exp program should be commented out:
// #include “oi.h"
This include file is used by Create and can sometimes cause complier errors. If you notice an error message referencing the absence of this include file, then just comment it out.
Also, make sure that you use COM9 for your USB Command Module port. Higher value port assignments can sometimes cause problems with WinAVR during the AVR programming step.
Each digit of the eDisplay is comprised of seven segments plus one decimal point. Furthermore, there is a colon between the second and third digits. This colon is useful for creating a clock display with eDisplay.
If you would like to individually control each digit’s segment and decimal point, a low-level lcd4SendDigits() function can be used for addressing 4 control bytes for enabling and disabling the screen’s 32 controllable bits. Yes, the colon is treated as a single bit (e.g., S32).
Roll Your Own
If you’ve got a hankering to add some hardware projects to one or more of the Command Module’s ePorts, but eProto and eDisplay don’t answer the mail, then build your own adapter plug. Depending upon your application, the cost can be reasonable, the labor relatively easy, and the final appearance very customizable. Here is a sample DIY ePort Plug:
- Connector D-sub plug 9-position; solder cup #609-1524-ND; $1.53
- Back shell DB-9 45-degree grey plastic #993-109P45E-ND; $1.29
- Connector header 9-position #WM6409-ND; $.58
- Red LED 3mm #160-1140-ND; $.19
- assorted wire jumpers
*all parts are from Digi-Key
- Break each of the header pins apart.
- Solder a single header pin to each solder cup pin of the DB-9 plug.
- Solder the LED between pins 3 and 4 of the DB-9 plug. The longer leg of the LED must be soldered to pin 4. The other leg is soldered to pin 3. Pin 3 in all of the ePorts corresponds to a digital I/O pin of the AVR (e.g., PB0 through PB3). You can use this LED to monitor the operation of your program by triggering the appropriate AVR pin.
- Slip wire jumpers over the header pins and route the collected wires through the outlet of the back shell. Test the continuity of the header pins and DB-9 pins before you complete the assembly of your DIY ePort Plug.
- Assemble the DB-9 back shell, turn off the power to your Create and Command Module, attach your DIY ePort Plug, and turn on the power to Create and the Command Module.
You can use the wire jumpers to quickly interface sensors, motors, and switches to your Create. These jumpers also simplify the debugging of your hardware project. It’s your very own plug-n-play DIY ePort Plug. Now go create something.