Wednesday, January 18, 2012

Trying to use XBEE for the Sea Perch

Use of a 9 Volt battery (we tried 2) was problematic. The serial monitor would work well for a few minutes and then the blinking red light on the receiver board would start to dim and stop communicating. Going off USB power was reliable of course, but we need to figure out what we are going to do on the boat if 9 V batteries deplete themselves so quickly!

The other issue we face is the lack of a place to mount the X-Bee on the motor shield, which even covers up the female header pins so it is hard to put wires to the breadboard. We ordered some more female headers to solder on to the motor shield so that may do the trick, but then the boards stack pretty high and it is hard to fit them in the small otter cases recommended by MIT.

To test out the xbee modules (which we got as part of the XBee Wireless Kit from Parallax) we used the wiring diagram here: 

With the code below it worked fine:

// Requires remote XBee in loopback mode (DIN connected to DOUT)

#include <SoftwareSerial.h>

#define Rx 6 // DOUT to pin 6

#define Tx 7 // DIN to pin 7

SoftwareSerial Xbee (Rx, Tx);

void setup() {

Serial.begin(9600); // Set to No line ending;

Xbee.begin(9600); // type a char, then hit enter



void loop() {

if(Serial.available()) { // Is serial data available?

char outgoing =; // Read character, send to XBee



if(Xbee.available()) { // Is data available from XBee?

char incoming =; // Read character,

Serial.println(incoming); // send to Serial Monitor




Now, to run the motors with the XBee we will try this tutorial:

I download an XCTU installer .exe for Windows XP from
But I’m not sure I need XCTU since I’m using Arduino’s IDE?

(Note: When I tried to test the hacked Sea Perch controller using the normal 12 V battery and used the SPDT toggles they got stuck and then ruined. They won’t work anymore. Did I damage them in the hack?)

A decent XBee Tutorial is here:

Teaches how to configure with X-CTU which I downloaded. I’m not pleased that the installer uses ATI Catalyst Installer and shows lots of games as it is installing. It appears to be installing a lot of ATI drivers. And it want’s a reboot. I’m switching to Linux, especially since my efforts to convert David’s mpegs of the school still won’t allow them to be imported into Adobe Premiere 3.0 and it took overnight forever to convert half of them!

There is a configure xbee tutorial for ubuntu here:

It has good advice, consistent with what I observed when using a 9 volt battery which was inadequate to run the Xbee, saying, “Don't use USB powered USB Hubs, since these may not be able to provide enough power for the USB XBee Adapter. You'll need two available USB ports if you are planning to configure and test the XBees simultaneously.”

Problem is, this tutorial wants us to use Wine (Windows emulator) and install X-CTU. Yick. I'm trying the advice in Tom Igoe's making things talk instead (page 194) and seeing if I can use PuTTY in Ubuntu.

PuTTY seems to be available in the Ubuntu Software center. Not sure whether it is the terminal emulator I want or the client so I'm downloading both.

I start PuTTY (the client is the only one that installed because it installed first and the other was redundant) and Igoe's advice was to check “Implicit LF in every CR” in the Terminal configuration. Now I open the program. 

Using SSH I couldn't get anything to happen (tried using the local host but that didn't work). When I click on Serial a window opens but it wouldn't let me type anything in. So then I read this

Where he tells us to force local echo: “It just means that anything that goes in or out is printed on the screen.
So when you have the Putty screen up click on the "Terminal" option on the left, then under "Line discipline options" force the local echo on, so when you run it you can see if the xbee accepts what you have to say.”

I was finally able to see what I was typing, but nothing happens.

First off, you need to remove the Atmega from the board, so you can communicate directly with the XBee (if you are using the shield also set both the jumpers to USB). Next, download Putty and open it, it should look something like this after you choose the "Serial" option on the start up screen under connection type (image1). Next, make sure the correct communication speed and com are correct then click the terminal button on the left side and under "Line description options" force on the local echo (Image2). Next, click the open option on the bottom and a black screen should pop up.  Now type in "+++" with the one second delay, and the screen should display "OK" (Image3). Now, lets check the current ID by typing "ATID"  and the default ID should pop up. Now I will change it to 420 (or whatever) by typing "ATID420" and, again, looking for the OK. Next, check to see if it has been changed (typing ATID again). Finally, save the changes by typing "ATWR" and close out with "ATCN". There are other AT commands found here

To find out what Serial port I'm using I use the advice from the Arduino cookbook page 470:

No matter where I plug the xbee in I get the same result:

Only when I remove it does it say “no such file or directory”.

So we are reasonably certain that ttyUSB0 is the right port.

This procedure does not work when I have the Arduino's plugged in. Running ls /dev/ttyUSB* yields “no such file or directory” except when the Xbee itself is plugged in. This corresponds to what another tutorial said about having to remove the ATMega chip from the arduino when using the shield to configure the Xbee.

By booting up the Arduino IDE I can see in the Tools/Serial Port what I have plugged in. I remove the Xbee and ttyUSB0 dissapears. Now I have only ttyACM0 and ttyS0. From the terminal I can run “ls /dev/ttyACM*” and it returns “ttyACM0” and I can run “ls /dev/ttyS*” and get back a whole list of “ttyS numbers ” from ttyS0 to ttyS31. Hmm.

When I unplug the Arduino Uno and leave the clone plugged in (using the FTDI Chip TTL-232R-3V3 USB to TTL Serial Cable), I see that the ttyS0 is the only thing listed in the Arduino IDE Tools/Serial Port. So the real Uno must have been the ACM0.

I verify this by unplugging and plugging in the UNO via USB. The ACM* command can't find a file or directory when I use ls /dev/ttyACM* without it plugged in. But the other board, the clone, shows all the ttyS* options regardless of being plugged in or not. And it stays present in the Arduino serial port under tools. It seems that /dev/ttyS0 is always there by default in Ubuntu using the Arduino IDE.

Weirdly, when I remove the real UNO and keep only the clone plugged in, I need to select USB0 to do my uploading of code.

And now when I type in “ls /dev/ttyUSB*” it returns /dev/ttyUSB0. Hmmm.

Now I try to run the XbeeLoopbackTest sketch and I get the “error: 'class SoftwareSerial' has no member named 'available'” Funny because it worked on XP yesterday. I try to download NewSoftSerial and install it according to this tutorial:

No, that doesn't help; it is for windows.

Instead I use $ which arduino and find that my arduino folder is /usr/bin/arduino.

No, that doesn't help.

libraries go into your sketchbook directory.
On my machine the sketchbook folder is in /home/wayoda/sketchbook

Create a new directory on ypour machine
/home/<your user name>/sketchbook/libraries
and install the libs into this directory

You should at least read this page here

Okay, I did what was asked and I changed the sketch for XbeeLoopbackTest to read
the following:

// Requires remote XBee in loopback mode (DIN connected to DOUT)

//#include <SoftwareSerial.h>
#include <NewSoftSerial.h>

#define Rx 6 // DOUT to pin 6
#define Tx 7 // DIN to pin 7
//SoftwareSerial Xbee (Rx, Tx);
NewSoftSerial Xbee (Rx, Tx);

void setup() {
Serial.begin(9600); // Set to No line ending;
Xbee.begin(9600); // type a char, then hit enter

void loop() {
if(Serial.available()) { // Is serial data available?
char outgoing =; // Read character, send to XBee

if(Xbee.available()) { // Is data available from XBee?
char incoming =; // Read character,
Serial.println(incoming); // send to Serial Monitor


It compiles, but there is no response from the Serial monitor! Ah, but that is because my loop between pins 6 and 7 on the receiving Xbee were wired wrong.
Now it is working!

Now I will work with this tutorial that says, “You should be able to get two Arduino boards with Xbee shields talking to each other without any configuration, using just the standard Arduino serial commands (described in the reference).”

Perhaps the baud rate is what is wrong?

What if I change the 38400,38400 to 9600,9600?

No difference.

Meanwhile, I soldered female headers to the Motor Shield so I can experiment with the Xbee. I soldered 2 eight pin and 2 six pin corresponding to the usual arduino pins and then two more 6 pin female headers for the extra 5V and ground pins on the motorshield board. I must thus bring 2 eight pin and 4 six pin female headers to Washington Prep today.

Tuesday, January 10, 2012

12 Step Plan for the Sea Perch to PORPOISE aquatic robotics pipeline

 (NOTE: This is a rough draft, subject to modification, which we share to enable citizen scientists and community stakeholders in the cloud to help us develop a curriculum that will ultimately work for everybody, particularly folks who felt that traditional engineering curricula under-served their needs.)

Dear Teachers and Students, and Robotics Enthusiasts all,

Welcome to PORPOISE: Precision Oceanographic Robotics Program In and On the Sea Environment, sponsored by Motion Picture Marine and the Office of Naval Research!

A very happy new year to you all!

We hope your holidays were "plus que parfait" and  "double fun bar none"!

With this blog we will lay out plans for working together to co-create what we hope will be the most effective aquatic robotics platform possible!

We know you are going to be super busy at your schools this semester and are aware of your time constraints so we are working hard to make sure that  participation in the Sea Perch to PORPOISE pipeline development project will enhance and add to your curricular activities and educational goals rather than burden them further.

Ultimately, with the benefit of your insights and ideas and ingenuity, we hope to get STEM learning through hands-on microcontroller based aquatic robotics to be an embedded part of science/technology/engineering/math curricula in schools around the world. In this way we hope to more effectively cultivate a new crop of "engineers without borders"...  but definitely with a purpose! We hope to invite everybody down the yellow brick road to an Oz where you are all wizards, using physicalized computing and embedded microcontrollers, sensors and actuators to help solve the greatest challenges facing humanity in the 21st century!

Err ... but we are  getting ahead of ourselves!

Let's start at the beginning, seeing how we can build upon the experience many of you had with Sea Perch ROV building (perhaps when you were in Middle School?) and turn it into a pathway to successful understanding of Aquatic and Marine Robotics and maybe a ticket to participation in the world famous Roboboat and Robosub competitions, or even a ticket into the engineering program at the college of your choice!
 We are helping to set up mentor/protege partnerships between University STEM outreach programs and local high schools to make Aquatic Robotics one easy and effective way to bring more under-served youth into the exciting and lucrative field of water-based civilian and Naval engineering and environmental sensing technology.
We are  working closely  with an old friend and colleague from the Motion Picture Marine/Jefferson High School D.E.M.M.O Productions (Digital Engineering for Multi-Media Occupations) Perkins Vocational-Academic-Industry partnership  initiative,  Dr. Todd Ullah. Dr. Ullah was  former director of Science for the Los Angeles Unified School District and is now  Principal of  Washington Preparatory High  School (in Inner City Los Angeles, not Washington DC).   We will be doing a basic Sea Perch build  with 4 students from his E-Tech Small Learning Community program (with mentorship from  UCLA Engineering) this Thursday morning. Our goal is to build one ROV  by the end of Thursday with them to get things rolling so that throughout the semester we can explore ways of making PORPOISE a pipeline to a new way of teaching science and math so it is relevant to a wider audience.

We are also working with Venice High School's After School Robotics Club  Team and with the Technology Club students of Washington Math Science Technology Public Charter School in DC and the Evanston Township School in  Chicago along with students from a few others (principally students in Colorado and Rhode Island).  But this is just a start.  
We hope that all of you who are interested in extending the Open Source  "PORPOISE Robotics with a Purpose" mission to young people all over the world will join us in making aquatic/marine oriented robotics fun, inexpensive and accessible.
Here is a draft of a brief outline and rough schedule of how we intend to move forward this semester (subject to change as experience dictates!).
THE PORPOISE 12 STEP PLAN TO AQUATIC ROBOTIC COMPETENCY: From Sea Perch to Semi-Autonomous Hybrid RoboBoat.

Build out your  Sea Perch kits according to the instructions provided with the kit. This way we have a common platform to work with.
You will need at least one Sea Perch kit!
TIME NEEDED: 3 to 4 hours?

(You can build a virtual ROV at Nautilus Live here!)


A: "Hack" the manual controller board for the Sea Perch by soldering wires onto the back of the circuit board, according to instructions provided by Motion Picture Marine PORPOISE, and connect the wires to breadboards.
TIME NEEDED: 1 hour?
B: Assemble/Prepare  Microcontrollers that will control the Sea Perch manual controller.   In the first  case the microcontroller is 'ready to use', in the second
the students get a chance to solder the components on the PCB board (using the same skills learned in soldering the Sea Perch controller)  to learn and understand more about this open source microcontroller. Both will have the same functionality.
You will need 2 microcontrollers  for this initial phase:  an Arduino Uno Microcontroller and a  Sparkfun Arduino Microcontroller PTH kit.
TIME NEEDED: 1 hour?

Build the Motor-Shield that will mount on the microcontroller and control the Sea Perch motors. These accept the 12 V battery input from the supplied Sea Perch battery.  
You will need 2 motor-shield kits (Adafruit Motor Shield Kit v.1.1) that require some soldering.
TIME NEEDED: 1 hour? 

Connect the Arduino to a Computer and run the Sea Perch in real time  using the Arduino IDE Serial Monitor to allow the motors to be driven by a student using letters from the Computer Keyboard. 
We will provide you with the code and instructions
TIME NEEDED: 30 minutes?

Run the Sea Perch motors "blind"  using a compiled  Arduino Sketch running independently on the microcontroller to demonstrate the initial stages of CNC robotics (i.e. "autonomy").
TIME NEEDED: 30 minutes?

 "Hack" a cheap Remote Controlled Toy Car transmitter (we bought the BigTime Muscle Camaro from Target for less than $15)  to accept input from the Arduino so that the toy car can be remotely controlled using the serial monitor and using the same code as in steps 5 and 6 to demonstrate the beginnings of wireless control of a robotics platform.
 You will need a single cheap  RC Car  with instructions for hacking which we will provide.
TIME NEEDED: 1 hour?

 Assemble the MIT Sea Perch Sensor Suite ("a microcontroller-based platform that can be fabricated with minimal tools in a few hours, for under $200, which monitors Water Temperature, Depth, Conductivity and Light) and attach to the Sea Perch. The data the sensors monitor can be collected on a provided SD card and can then be uploaded to the Google Digital Ocean project.  The Suite is in Beta Testing at MIT right now and you will be participating in the testing.
You will need 1 MIT Sea Perch Sensor Suite
TIME NEEDED: 3 to 4 hours?
Hack a $70 Spy Video Car, remove the night vision camera and place it in a housing on the Sea Perch, with a video cable following the normal Sea Perch control cable,
giving it "eyes" to see underwater.
You will need 1 Spy Gear Video Car VH6 for this.
TIME NEEDED: 2 hours

9.  FREE WILLY... AND THE SEA PERCH!Create a floating platform for the Microcontroller/Motor Shield/Video Transmitter that the Sea Perch can tow around the water, giving the Sea Perch a much wider range. The floating platform can be a boat or a simple raft made of foam. The microcontrollers will be housed in Otter cases.  An XBee Wireless shield will be added to the Arduino to allow communication with the land-based computer.  In this phase students will learn how to use wireless transmission to run the Sea Perch and consider the problems of waterproofing the controllers.
Students need to be creative in coming up with the materials for the floating platform as we move toward creative use of local materials and thinking outside the box.
You will need the XBee TX/RX (Transmitter Receiver) shield for the microcontrollers and the Otter Cases and hardware
TIME NEEDED: 2 hours?

In this phase students are invited to join MPM PORPOISE in building a robotic surface craft (called  "Sea Sparrow"?, "Manta Ray"? Depending on Design...)  that can bring the Sea Perch ROV to specific locations for exploration of the underwater environment, much as National Geographic Explorer Bob Ballard takes his ROVs around the world on "The Nautilus" (see

The boat platform will take more thought and experimentation than the simple floating platform in step 10 as it will need to have its own motor thrusters, be hydrodynamic  and streamlined and  house not only the initial Sea Perch Microcontroller, but an additional Microcontroller/Motor Shield/XBee set for controlling the Sea Sparrow Surface Craft.
You will need plastic sheets, foam, two "Sea Perch" style 12 V motors (Sea Perch used the Jameco 232021 series which are no longer available; try substituting the 232040 series but watch current consumption)  and propellers (used now as boat thrusters) and water proofing cases and materials for assembling a sea-worthy and motor-ready surface craft, along with a template we will provide for a simple hull design to help  students get started.
TIME NEEDED: 2 hours?


In this step students add a micro-controller and Motor-shield and Xbee  to the boat, identical to what was controlling the Sea Perch when it was tethered to the floating platform, only this additional Arduino/MotorShield/transceiver will control the boat thrusters, while the former will control the Sea Perch thrusters. Both the Sea Perch microcontroller and the Sea Sparrow  Microcontroller will be mounted on the deck of the Boat and both can be controlled remotely via the XBee radios from the shore based computer. With this step completed the Sea Sparrow can now actively  take the Sea Perch to a site of deployment rather than being towed by the Sea Perch. The Students will also learn to connect a servo to the Arduino and connect it to
a pair  of robot claws that will hold the Sea Perch in place at the surface as it is towed by the boat to location and then released so it can be instructed to descend and start analysing what's  going on under the boat. 
You will need an additional Arduino board, MotorShield Kit and Xbee transceiver, servo, robotic claws and actuators and Otter Case and peripherals for this stage of the build. To build a robotic claw mechanism that can hold the Sea Perch from the boat you need to get two $10 claws and two $11  medium pan servos and two $6 pan bracket (Sparkfun also has a $30 tilt kit to add functionality that has the brackets and a tilt servo to go with the pan servo.
TIME NEEDED: 3 hours?


In this last module of the build students, having previously equipped the Sea Perch with the MIT Sea Perch Sensor Suite and the Video Camera to let it sense the underwater environment, add the PORPOISE Sensor Suite to the Surface Craft to enable it to sense what is going on topside. There are many sensors available for Arduino based robotics projects today.   Some of the sensors the students will put on the Sea Sparrow will be somewhat  familiar to anybody who has used the LEGO Mindstorms Kit.  We will work with six sensors initially.
  1. The first sensor is the familiar ultrasonic range finder (we use the Parallax PING))) Ultrasonic Distance Sensor for $30) , enabling the boat to sense objects and avoid collisions and take evasive action.
  2. The second sensor is the IR Range Finder which is "probably the most powerful sensor available to the everyday robot hobbyist. It is extremely effective, easy to use, very affordable ($10-$20), very small, good range (inches to meters), and has low power consumption.
  3. The third sensor is a PIR (Passive Infra-Red) Motion Sensor for about $10-- a pyroelectric device that detects motion by measuring changes in the infrared (heat) levels emitted by surrounding objects, enabling the craft to detect the presence of living creatures, fires, hot engines or moving objects reflecting solar radiation. 
  4. The fourth sensor is a LSM303DLH digital Navigational Compass/Accelerometer, for about $30, enabling the craft to do Dead Reckoning on a bearing. 
  5. The fifth sensor is a $60 gyroscope enabling even more precise orientation measurement and navigation as well as stabilization potential (A good comparison of accelerometers and gyroscopes can be found in this  sparkfun tutorial: "Gyroscopes measure angular velocity, how fast something is spinning about an axis. If you're trying to monitor the orientation of an object in motion, an accelerometer may not give you enough information to know exactly how it's oriented. Unlike accelerometers gyros are not affected by gravity, so they make a great complement to each other".
  6. The sixth  sensor is a $60  EM-406A GPS module enabling the craft to navigate to a general location and report its location.
Students will learn about the different ways marine robots are able to navigate and be controlled using these sensors. The accelerometer on the LSM303DLH digital compass, for example, can also be used tor determining attitude, measuring the surge, sway and heave of the boat on the water, which could come in handy later for stabilization (see Chapter 8 project 21 of Tom Igoe's book 'Making Things Talk - Using Sensors, Networks, and Arduino to See, Hear and Feel Your World').  With these sensors connected to the Sea Sparrow Arduino microcontroller the craft will now be able to navigate semi-autonomously.  
(While the six sensors listed above come to about $200, students can opt to use only a few of them and still get navigational functionality; we recommend using a Navigational Compass/Accelerometer ($30) and an IR range finder ($10) for starters, then going for the ultrasonic distance sensor ($30). From there you can work your way up to ever more refined sensing and navigation.)
Whereas in step 11 the craft could be controlled by the land-based computer on the fly, step 12 enables the boat to run autonomously via an Arduino sketch uploaded to
the microcontroller that, by sensing its environment, can avoid collisions, turn around,  and navigate by itself to specific beacons. Depending on the sensors you add you can even program your robotic boat to react in very complex ways to environmental stimuli!
You will need the sensors and PCB board/shields and code and waterproof housing materials for this final phase of the project.
TIME NEEDED: 4 hours?

WHAT'S NEXT? MOVING FURTHER DOWNSTREAM:Once you  have completed the PORPOISE 12 step plan, you will have a very capable Sea Perch/Sea Sparrow hybrid Robosub/Roboboat Platform. 
The Platform can be  programmed in the Arduino/Processing (C language) environment and controlled manually but  remotely, via the computer keyboard on the fly via the serial monitor, or through updated programs compiled onto the microcontroller. The boat will be able to be programmed for  many navigational challenges and will carry the Sea Perch, much as Bob Ballard's Nautilus carries his ROVs to locations around the world, and then allow the Sea Perch to be deployed. 
The Sea Perch can then be driven remotely via signals relayed by the receiver on the boat down the cable to the Sea Perch, and the boat will transmit live video feed from the Sea Perch to a monitor on shore. The Sea Sparrow will also be able to bring the Sea Perch back to shore once it has gathered underwater data with the MIT Sensor Suite so that the data can be uploaded to digital ocean.
 These capabilities will enable a large variety of competition and research challenges to be undertaken, making the Sea Perch and Sea Sparrow valuable tools for future missions.  Students can continue to further refine the designs of both Sea Perch and Sea Sparrow, adding additional sensors and capabilities. They will serve as flexible platforms for experimenting with an endless variety of computer programming tasks and real world environmental data sensing and collection.

In addition to being able to  continue evolving the Sea Perch/Sea Sparrow, the students  will know how to  "hack" off the shelf RC controlled toys so as to cheaply expand capabilities and make use of things they find in their own playrooms, garages and even junkyards. This will help encourage more creative thinking about how to continue in robotics without breaking  the bank or reinventing the wheel.

The goal beyond the 12 Step Plan, which we hope you will undertake with us, is to have the students dream up missions for the Sea Perch/Sea Sparrow so that we can invite some of  them to a proposed 1 week summer camp, to be held in conjunction with the Office of Naval Research and the AUVSI  (Autonomous Unmanned Vehicle Systems International) Roboboat/RoboSub competitions where they will come together with other students from around the world and work in cooperative/competitive virtual teams, pooling ideas and stimulating each other  to try implementing real-world tasks for the new hybrid platform.

The step beyond this is to have the students continue to grow with the program in the following school year, maintaining their contact with the students they met at the camp throught social media and prepare for an official PORPOISE competition the following year that provides a pathway to the collegiate level of Roboboat/Robosub competitions where the sky is the limit.

Please note that this will be a collaborative process that we hope to support as much as possible but that will really evolve thanks to your contributions to make it relevant, interesting and fun for everybody.  All materials produced will be OPEN SOURCE and freely shared via a website that we will be creating and that you will have lots of input in as pioneer partners.
All participants will receive appropriate credit and citation and permission to use the materials developed for non-commercial purposes and involve others is freely given. We are working to build a robotics platform that is empowering to all and lets us all use science, technology, engineering and math to better serve our families, communities and regions as well us helping us better serve our country and make our world a better safer, healthier place.

We look forward to continuing this journey with you!


Dr. T.H. Culhane
PORPOISE STEM Curriculum Development Coordinator