Go Down

Topic: Controlling Roomba [solved] (Read 9522 times) previous topic - next topic

bratan

May 25, 2013, 08:25 pm Last Edit: May 27, 2013, 06:52 am by bratan Reason: 1
Hi,

I have Roomba 551 which I'm trying to control from Arduino Uno. I've read "Hacking Roomba" and other examples online how it should be connected, but no matter what I try, I can't get it to respond. I know there are issues with RX/TX lines so I'm using Software Serial, here's example of the sketch:

Code: [Select]
#include <SoftwareSerial.h>
SoftwareSerial roomba(5,3);  // RX,TX
int rxPin = 5;
int txPin = 3;
int ddPin = 7;
int ledPin = 13;
void setup() {
pinMode(ddPin,  OUTPUT);   // sets the pins as output
pinMode(ledPin, OUTPUT);   // sets the pins as output
Serial.begin(57600);
roomba.begin(57600);
digitalWrite(ledPin, HIGH); // say we're alive
// 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 as defined in manual(adim)
delay(50);
roomba.write(130);  // CONTROL adim
delay(50);
digitalWrite(ledPin, LOW);  
}

void loop() {
 goForward();
 delay(50);
 halt();  
}

void goForward() {
byte j = 0x00;
roomba.write(137);
roomba.write(j);  
roomba.write(0xc8);
roomba.write(0x80);
roomba.write(j);
}

void halt(){
byte j = 0x00;
roomba.write(137);  
roomba.write(j);  
roomba.write(j);
roomba.write(j);
roomba.write(j);
}


I made cable from old PS/2 miniDin connector. Pin 1 is V+, Pin 8 i GND, 3 is RX, 5 is TX, 5 is DD. I connected Roomba's RX to Arduino TX (pin 3) and TX to pin 5. DD is on Pin 7.
Roomba powers up my Uno board no problems, but it's not moving at all :(
Also I read that CSI voltage should be around 18V, but it's actually measures as 8 Volts. Is this because I only connected one V+ pin (I have no idea if they split voltage between two) ?
Any ideas on how to get it moving? :)

EDIT: I found out that default baud is 115200. Changed code but it still doesn't work.
I have Roostick and was able to control Roomba from my computer via SCITest program.
Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, etc.

bratan

#1
May 27, 2013, 06:59 am Last Edit: May 27, 2013, 07:22 am by bratan Reason: 1
Anyway I found solution on my own.  Little by little I figured out that 500 series Roomba undergone significant change in Open Interface (OI) format. All the books, tutorials, etc. are severely outdated unfortunately :(
Major changes are:
1. Baud rate is now 115200 by default
2. No more DD pin. Instead this pin (#5) is now used to change baud rate
3. Command 130 (Control) is no longer needed (but still supported). Instead command 131 (Safe Mode) does same thing.

I modified RoombaComm BumpTurn sketch to work with SoftwareSerial and series 500 Roombas. I also simplified it to just Move forward to half a second, stop and then move backwards (sort of Hello World).
Code: [Select]


#include <SoftwareSerial.h>

int rxPin = 3;
int txPin = 4;
int ledPin = 13;

SoftwareSerial Roomba(rxPin,txPin);

#define bumpright (sensorbytes[0] & 0x01)
#define bumpleft  (sensorbytes[0] & 0x02)

void setup() {
 pinMode(ledPin, OUTPUT);   // sets the pins as output
 Serial.begin(115200);
 Roomba.begin(115200);  
 digitalWrite(ledPin, HIGH); // say we're alive
 Serial.println ("Sending start command...");
 delay (1000);
  // set up ROI to receive commands  
 Roomba.write(128);  // START
 delay(150);
 Serial.println ("Sending Safe Mode command...");
 delay (1000);
 Roomba.write(131);  // CONTROL
 delay(150);
 digitalWrite(ledPin, LOW);  // say we've finished setup
 Serial.println ("Ready to go!");
 delay (5000);
}

void loop() {
 digitalWrite(ledPin, HIGH); // say we're starting loop
 Serial.println ("Go Forward");
 goForward();
 delay (500);
 Serial.println ("Halt!");
 halt();
 Serial.println ("Go Backwards");
 delay (500);
 goBackward();
 delay (500);
 Serial.println ("Halt!");
 halt();
 while(1) { } // Stop program
}

void goForward() {
 Roomba.write(137);   // DRIVE
 Roomba.write((byte)0x00);   // 0x00c8 == 200
 Roomba.write(0xc8);
 Roomba.write(0x80);
 Roomba.write((byte)0x00);
}
void goBackward() {
 Roomba.write(137);   // DRIVE
 Roomba.write(0xff);   // 0xff38 == -200
 Roomba.write(0x38);
 Roomba.write(0x80);
 Roomba.write((byte)0x00);
}

void halt(){
byte j = 0x00;
Roomba.write(137);  
Roomba.write(j);  
Roomba.write(j);
Roomba.write(j);
Roomba.write(j);
}


Found Specs PDF here
Xronos Clock - A talking arduino based alarm clock is now available. Check out xronosclock.com for pictures, source code, schematics, etc.

aivs

Hi, I have Roomba 770, and I'm trying to control from Arduino Uno R3. I read the IO specification.
For control I used hardware uart of Arduino Uno RX=PIN0, TX=PIN1, and at the same time I have opened the serial monitor.
Roomba did not respond to my commands.
Bratan you write that need to use SoftwareSerial, Why? What the problem with Hardware Serial?




aivs

#3
Sep 05, 2015, 12:17 am Last Edit: Sep 05, 2015, 12:19 am by aivs
I found a document how connect arduino and roomba:
http://www.irobot.com/~/media/MainSite/PDFs/About/STEM/Create/Create_2_to_5V_Logic.pdf

Useful tips:
* Pin 3 is Roomba TX, which will go to the device's RX.
*Pin 4 is Roomba RX, which goes into the device's TX.
* In some cases, the drive strength of a Roomba TX line is not enough to drive the RX line of another board (for example, in some revisions of Arduino; see http://goo.gl/M4Q56u | this post] for details).
In this case, a simple PNP transistor (2N2907A, 2N3906, or 2N4403, among others) can be used to provide enough "drive" for the Arduino.

For me arduino uno r3 works well with roomba 770 through hardware serial without transistor.

aivs

#4
Sep 05, 2015, 01:08 pm Last Edit: Sep 05, 2015, 01:13 pm by aivs
Sketch: "Roomba go to Dock"
Code: [Select]

void setup() {
 Serial.begin(115200);  
 Serial.write(128);  // START
 delay(50);
 Serial.write(131);  // SAFE MODE
 delay(50);
 Serial.write(143);  // Go to Dock
}

void loop() {  
}




Go Up