Arduino serial issues

Inside the Roomba and Scooba and more, Cool mods, Repair and Upgrades - including the all new iRobot Create Kit. Let's void that warranty baby!

Arduino serial issues

Postby cmcclellan1993 » January 10th, 2013, 2:54 pm

Hi everyone, I've been attempting to control my Roomba 2.1 with a arduino uno using a mini-din serial connection between my arduino and the roomba. However, I'm having trouble with consistency. I'm using a test sketch (which I will paste at the end) right now to start off with, which should simply put the roomba into spot mode in an infinite loop. Every now and then it works, and the roomba responds by sending itself into spot mode, but most of the time it doesn't. Instead, when I upload the sketch to the arduino, the roomba goes from being on to off and then about two seconds later back on. Right now, all I have connected is the tx to rx connection and the grounded wires of the roomba.

void setup(){
Serial.begin(57600);
delay(500);
Serial.write(128);
delay(100);
Serial.write(130);
delay(100);
}
void loop(){
Serial.write(134);

delay(1000);


}
cmcclellan1993
 
Posts: 1
Joined: January 10th, 2013, 2:45 pm

Re: Arduino serial issues

Postby mfortuna » January 11th, 2013, 7:58 am

A couple things. What do you mean by roomba 2.1? If you are referring to a 400 series then 57600 is the correct BAUD rate, else use 115200.

Also, I am not sure what happens when you send a spot command every second. Try sending it just once or try blinking the LEDs in a loop.
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5144
Joined: February 5th, 2006, 10:35 am
Location: NH

Discovery LEDs won't cooperate!!

Postby New2roomba » May 19th, 2013, 1:24 pm

This sketch won't do ANYTHING on a Discovery (4210 0504 07) when connected to an Uno R3 thru an appropriate cable. The Discovery works as expected on its own and with the Roomba Remote.
I'm working with the LEDs for now. I'll work with the drive motors once I get the lights figgered out.
What is the purpose of toggling DD when setting up the Roomba?

Thanks, in advance, for any assistance
/*
* Turn lights on & off
* --------------
* The following code came from "Bump-&-Turn" so it should(?) work
* Arduino pin 3 is connected to Roomba RXD
* Arduino pin 4 is connected to Roomba TXD
* Arduino pin 5 is connected to Roomba DD
*
*/
#include <SoftwareSerial.h>
SoftwareSerial Roomba(3,4);
int ddPin = 5;
int ledPin = 13;

void setup() {
pinMode(ddPin, OUTPUT); // sets the pins as output
pinMode(ledPin, OUTPUT); // sets the pins as output

digitalWrite(ledPin, HIGH); // Start Setup
// wake up the robot
digitalWrite(ddPin, HIGH);
delay(100);
digitalWrite(ddPin, LOW);
delay(500);
digitalWrite(ddPin, HIGH);
delay(2000);

// set up ROI to receive commands
Roomba.write(128); // START Roomba in PASSIVE mode
delay(50);
// Set baud rate
Roomba.write(129); // Baud command
Roomba.write(10); // 10 = 57600
Roomba.write(130); // CONTROL Roomba in SAFE mode
delay(50);
digitalWrite(ledPin, LOW); // finished setup
delay(2000);
}
void loop()
{
// This code came directly from "Hacking Roomba" page 32
digitalWrite(ledPin, HIGH);
Roomba.write(139); // LEDS command
Roomba.write(40); // Status & Spot green
Roomba.write(128); // Power medium amber
Roomba.write(128); // 50% bright
delay(4000);

Roomba.write(139); // LEDS command
Roomba.write(15); //Dirt Detect, MAX, Clean, Spot ON
Roomba.write(128); // Green Power
Roomba.write(255); // 100% on
delay(4000);
Roomba.write(139); // LEDS command
Roomba.write(16); // Red Status
Roomba.print(0); // Power color
Roomba.write(100); // Dim
delay(4000);
Roomba.print(139); // LEDS command
Roomba.print(48); // Amber Status
Roomba.print(0); // Power Green
Roomba.print(128); // 50%
delay(4500);
Roomba.print(139); // All off
Roomba.print(0);
Roomba.print(0);
Roomba.print(0);
digitalWrite(ledPin, LOW); // we've finished 1 loop
delay(3000);
}
New2roomba
 
Posts: 3
Joined: March 4th, 2013, 1:31 pm

Re: Arduino serial issues

Postby mfortuna » May 19th, 2013, 7:58 pm

I think dd toggle is supposed to wake up the roomba.
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5144
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Arduino serial issues

Postby mfortuna » May 19th, 2013, 8:07 pm

It has been a while since I messed with this but check out:
viewtopic.php?f=4&t=15779&hilit=Ultrasonic+create
Mike
Reds x 3, Dirt Dog, Disco (now a parts bot), Create, Scooba 350, and Security Dawg
Evolution Mint
Neato XV-11
User avatar
mfortuna
Robot Master
 
Posts: 5144
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Arduino serial issues

Postby bhylak » June 4th, 2013, 2:03 pm

I'd recommend grabbing a Roomba library for Arduino. There's a few but my personal favorite is http://www.airspayce.com/mikem/arduino/Roomba/

It'll simply everything a little bit.
Ben

Homemade Telepresence Robot:
http://mayarover.blogspot.com/
http://www.instructables.com/id/MAYA-Te ... nce-Rover/

There are only 10 types of people in the world. Those who understand binary and those who don't
User avatar
bhylak
Robot Addict
 
Posts: 1637
Joined: October 17th, 2009, 7:30 pm


Return to Robotic Hacking

Who is online

Users browsing this forum: Fraggboy, meccup, vic7767 and 196 guests