Roomba 530 OI serial data

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!

Roomba 530 OI serial data

Postby LazyRoomba » July 26th, 2016, 9:23 am

I'm working on a project, hooking my Arduino up to my roomba. I have a problem that I don't know how to resolve,

http://prntscr.com/bxpr7x

I simply don't know how to get those values (Image above). I'm very new to c++ so my knowledge isn't strong.

The code I have in the Arduino


const int txPin = 0;
const int rxPin = 0;
const int ddPin = 8;

byte start[] = {128};
//And take control of the robot
byte hyjack[] = {131};

byte getSensor[] = {142, 7};

char sensorbytes[10];

//byte getSensor[] = {142, 7};
#define bumperRight (sensorbytes[0] & 0x01) //1
#define bumperLeft (sensorbytes[0] & 0x02) //2
#define wheelDropRight (sensorbytes[0] & 0x04) //4
#define wheelDropLeft (sensorbytes[0] & 0x08)//8

//byte getSensor[] = {142, 9};
#define cliffLeft (sensorbytes[0] & 0x01)//1

//byte getSensor[] = {142, 10};
#define cliffFrontLeft (sensorbytes[0] & 0x01)//1

//byte getSensor[] = {142, 11};
#define cliffFrontRight (sensorbytes[0] & 0x01)//1

//byte getSensor[] = {142, 12};
#define cliffRight (sensorbytes[0] & 0x01)//1

//byte getSensor[] = {142, 18};
#define cleanButton (sensorbytes[0] & 0x01)//1

//byte getSensor[] = {142, 18};
#define spotButton (sensorbytes[0] & 0x02)//2

//byte getSensor[] = {142, 18};
#define dockButton (sensorbytes[0] & 0x04)//4

//byte getSensor[] = {142, 21}; - UNKNOWN
#define chargingState (sensorbytes[0] & 0x01)

//byte getSensor[] = {142, 24}; - UNKNOWN
#define batteryTemperature (sensorbytes[0] & 127)

//byte getSensor[] = {142, 45};
#define lightBumperLeftSig (sensorbytes[0] & 0x01)//1

//byte getSensor[] = {142, 45};
#define lightBumperFrontLeftSig (sensorbytes[0] & 0x02)//2

//byte getSensor[] = {142, 45};
#define lightBumperCenterLeftSig (sensorbytes[0] & 0x03)//1

//byte getSensor[] = {142, 45};
#define lightBumperCenterRightSig (sensorbytes[0] & 0x04)//4

//byte getSensor[] = {142, 45};
#define lightBumperFrontRightSig (sensorbytes[0] & 0x08)//8

//byte getSensor[] = {142, 45};
#define lightBumperRightSig (sensorbytes[0] & 0x11)//16




//Not working

//byte getSensor[] = {142, 15};
//#define dirtDetect (sensorbytes[0] & 0x01)//1

//byte getSensor[] = {142, 17};
//#define infraredCharOmni (sensorbytes[0] & 0x01)//1

//byte getSensor[] = {142, 52};
//#define infraredCharLeft (sensorbytes[0] & 0x01)//1

//byte getSensor[] = {142, 53};
//#define infraredCharLeft (sensorbytes[0] & 0x01)//1


//byte getSensor[] = {142, 23}; - UNKNOWN
//#define batteryCurrent (sensorbytes[0])//4

//byte getSensor[] = {142, 22}; - UNKNOWN
//#define batteryVoltage (sensorbytes[0] & 65535)//4

void setup(){

Serial.begin(115200);
Serial3.begin(115200);

//Bring the roobt out of passive mode
digitalWrite(ddPin, HIGH);
delay(200);
digitalWrite(ddPin, LOW);

//Take control of the robot
Serial3.write(start, sizeof(start));
delay(200);
Serial3.write(hyjack, sizeof(hyjack));
delay(200);
}

void loop(){

delay(1000);
updateSensors();

Serial.println(sensorbytes[0] >> 8);
Serial.println(sensorbytes[0] & 32767);

}

void updateSensors(){

Serial3.write(getSensor, sizeof(getSensor));

int i = 0;

while(Serial3.available()){

long c = Serial3.read();

sensorbytes[i++] = c;

}

}




I got the example code from http://roombahacking.com/software/ardui ... mpTurn.pde and modefied it.

Any help would I would appreciate.

The Roomba: https://scontent-lhr3-1.xx.fbcdn.net/t3 ... 4426_o.jpg

530 with 880 CHM and Dirtbin (It's a beast)
LazyRoomba
Robot Addict
 
Posts: 179
Joined: May 9th, 2013, 6:22 am

Re: Roomba 530 OI serial data

Postby LazyRoomba » July 26th, 2016, 10:10 am

Playing around with the voltage, and with some research Iv'e come up with a number.

The returning data is sent as two bytes, so I access those two pieces as sensorbytes[0] and sensorbytes[1].

int data_1 = (sensorbytes[0] & 0xFF); (62)
int data_2 = (sensorbytes[1] & 0xFF); (187)

if I do

data_1 * 255 + data_2 I get 15,997 as my battery voltage, which seems in spec with the manual

Would this be correct?

Edit: Tried same method on the current, returned -543 mAh.. Hyjacking my roomba discharges the battery at a higher rate :(

Edit2:

http://prntscr.com/bxrfh2
LazyRoomba
Robot Addict
 
Posts: 179
Joined: May 9th, 2013, 6:22 am

Re: Roomba 530 OI serial data

Postby mfortuna » July 26th, 2016, 11:52 am

Yes, the high order byte is returned first. The formula should be data_1 * 256 + data_2.

Current is a signed value. It seems like your reading is kinda high for just sitting around. For example if you read 255 and 0 for the two bytes, that represents -255.
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: 5771
Joined: February 5th, 2006, 10:35 am
Location: NH

Re: Roomba 530 OI serial data

Postby LazyRoomba » July 26th, 2016, 5:07 pm

Not sure what it was, reset the Roomba now it's at around 47 mAh on current been used.

Thanks
LazyRoomba
Robot Addict
 
Posts: 179
Joined: May 9th, 2013, 6:22 am

Re: Roomba 530 OI serial data

Postby a1robotrepair » July 28th, 2016, 5:51 pm

530 with 880 CHM and Dirtbin (It's a beast)

Pictures please!
How did you handle current limit for the BLDC bin motor?
Roses are red Violets are blue Poems are hard Flowers and Chocolate
http://www.daycounter.com/Calculators/
a1robotrepair
Robot Master
 
Posts: 824
Joined: October 14th, 2013, 8:40 am

Re: Roomba 530 OI serial data

Postby LazyRoomba » July 29th, 2016, 2:04 pm

The CHM had no modifications made to the electronics, but does require milling, or cutting a big piece of the chassis off. The dirt bin is the same. The roomba will not power the dirtbin as it draws too much current, so..

I used a cheap $0.01 pnp transistor and a mosfet. Buck convert on ebay for around $2. Then the big task, and risk, was cutting up the chassis and redesigning the backend, which I 3D printed and glued in place.

The dirtbin circuit.

http://prntscr.com/bz5sz0

Added pics of the roomba itself.

Curerntly working on a project that will use the nano sat in the roomba to control the robot with new modes, such as cleaning ect.. (Smarter, room mapping ect..) hence the missing serial port (Removed for a discrete look)

Been using the roomba with the 880 mods for nearly a year, been running perfectly fine
Attachments
IMG_20160729_183415.jpg
Backend top
IMG_20160729_183356.jpg
Arduino for dirtbin sensors
IMG_20160729_183328.jpg
New chassis backend
IMG_20160729_183245.jpg
Roomba 530
LazyRoomba
Robot Addict
 
Posts: 179
Joined: May 9th, 2013, 6:22 am

Re: Roomba 530 OI serial data

Postby vic7767 » July 29th, 2016, 2:37 pm

That's a mod / Hack to really be proud of, great work. Have you thought about using a700 or 800 base plate so you can have better battery access to your 530 ?
Roomba and Neato Mods, come visit: http://www.vic7767.com/

http://www.Robot-Doc.com/
User avatar
vic7767
Robot Master
 
Posts: 14385
Joined: January 14th, 2006, 8:31 pm
Location: Haughton Louisiana - USA

Re: Roomba 530 OI serial data

Postby LazyRoomba » July 29th, 2016, 2:56 pm

The chassis on the 500 is very similar to the 800, +/- features, but the body shell has had big changes. Without the new body panels their's a chance the face plate won't fit, especially when the 700 / 800 series has a different PCB design. You can see the dirtbin on the pics above (The 3D printed backend) sticks out, the 800 series is wider than the 500 but I could be wrong, I think Irobot repositioned the CHM further forward, hence the 10mm gap on my roomba and the dirt bin sticking out the back by around 10mm.

Thanks
LazyRoomba
Robot Addict
 
Posts: 179
Joined: May 9th, 2013, 6:22 am

Re: Roomba 530 OI serial data

Postby a1robotrepair » July 29th, 2016, 4:58 pm

That's 3 I know of.
My 780 using third-deg chassis mod. and shorting R113, adding heat sink to Q79 and a small separate board for a low pass filter. http://www.robotreviews.com/chat/download/file.php?id=8573
Zs 760 using a stand alone V to V converter and Q79 as control.http://www.robotreviews.com/chat/download/file.php?id=8596&mode=view
And yours, the most extreme mod to date.
If you get your hands on an OSMO and get familiar enough with your Adriano coms, you will be able to read more than the makers want. Warning, don't post findings as Gregg found out, posted in his scratchpad.
Roses are red Violets are blue Poems are hard Flowers and Chocolate
http://www.daycounter.com/Calculators/
a1robotrepair
Robot Master
 
Posts: 824
Joined: October 14th, 2013, 8:40 am

Re: Roomba 530 OI serial data

Postby LazyRoomba » July 30th, 2016, 9:52 pm

When I call the angle data, I get between -1 -> 2, even when the roomba is rotating, it's the same as the distance. Am I missing something? I'm getting other data (such as lightbumper raw signal data ect..) I can't wrap my head around why.. I really don't want to have to work it out from scrap.

I send optcode 20 (angle) and after converting the two bytes I get between -1 to 2. Data been requested every 0.025 seconds.

Edit: Angle has a known bug
https://robotics.stackexchange.com/ques ... cket-id-20
LazyRoomba
Robot Addict
 
Posts: 179
Joined: May 9th, 2013, 6:22 am

Re: Roomba 530 OI serial data

Postby vic7767 » July 30th, 2016, 10:01 pm

I don't recall now for sure but there is a Create group on Google that encountered that same issue and came up with some answers. I suspect the answers will apply to the R3 530.
Roomba and Neato Mods, come visit: http://www.vic7767.com/

http://www.Robot-Doc.com/
User avatar
vic7767
Robot Master
 
Posts: 14385
Joined: January 14th, 2006, 8:31 pm
Location: Haughton Louisiana - USA

Re: Roomba 530 OI serial data

Postby a1robotrepair » July 30th, 2016, 10:07 pm

Angle Packet ID: 20 Data Bytes: 2, signed
The angle in degrees that Roomba has turned since the angle was last requested is sent as a signed 16- bit value, high byte first. Counter-clockwise angles are positive and clockwise angles are negative. If the value is not polled frequently enough, it is capped at its minimum or maximum.
Range: -32768 – 32767
Try increasing your request time to greater than 1 sec. then 5, then 10...
Roses are red Violets are blue Poems are hard Flowers and Chocolate
http://www.daycounter.com/Calculators/
a1robotrepair
Robot Master
 
Posts: 824
Joined: October 14th, 2013, 8:40 am

Re: Roomba 530 OI serial data

Postby LazyRoomba » July 30th, 2016, 10:26 pm

I used the info from the stack exchange and I got an angle! -2202.71 and it does increase / decrease, although a tad high, I can reference from it. Need it so I can calculate the x and y of roomba when driving in angles (Room mapping)

Many thanks
LazyRoomba
Robot Addict
 
Posts: 179
Joined: May 9th, 2013, 6:22 am

Re: Roomba 530 OI serial data

Postby a1robotrepair » July 30th, 2016, 11:01 pm

I will have to look at pac 20 again but I believe it was close on flash version 10, 2015-05-26-1001-L.
I did not know there was a bug in previous versions, and maybe this one also.
Roses are red Violets are blue Poems are hard Flowers and Chocolate
http://www.daycounter.com/Calculators/
a1robotrepair
Robot Master
 
Posts: 824
Joined: October 14th, 2013, 8:40 am

Re: Roomba 530 OI serial data

Postby a1robotrepair » July 31st, 2016, 7:40 pm

Pack 20 is flawed! Unintelligible.
I went back in my notes and while messing around came up with the same solution as stack exchange but I think it's a little better: degrees360 = {(pulses right - pulses left)*180}/512. Substitute Pi for 180 for radian.
Measured 70 mm wheel diameter and 232 mm for distance wheel center to center.
508.8 encoder pulses/rev
1 wheel revolution 220 mm.
1.055 revolutions 180deg, 3.14rad
Your wheels diameter and distance measurements will differ slightly.
http://www.irobotweb.com/~/media/MainSite/PDFs/About/STEM/Create/Create_2_Wheel_Hack.pdf?la=en
Roses are red Violets are blue Poems are hard Flowers and Chocolate
http://www.daycounter.com/Calculators/
a1robotrepair
Robot Master
 
Posts: 824
Joined: October 14th, 2013, 8:40 am

Re: Roomba 530 OI serial data

Postby LazyRoomba » August 1st, 2016, 10:40 am

I'm having issues with the stackechange forumla. It's not accurate for some reason. My right wheel encoder is around (lets say 5000) and my left wheel is around (lets say 29000).

If I do (Left - Right) / 235 wheel base, I get 102.12 radians

Converted to degrees, 5854.012 = (102.12 * 180) / PI

But! If the roomba turns 90 degrees, the code says roomba rotated 150 (Or even higher).

Whats more, I've yet to discover why, but my encoder readings are jumpy. Meaning they can be fine then microsecods later they can change with an incorrect reading like a negative or even thousands higher than the actual reading.. Still looking at the issue (Could be my code).


degrees360 = {(pulses right - pulses left)*180}/512


so..

*Reversed wheels to keep the number positive for better reading
degrees360 = {(left encoder - right encoder)*180}/512 ?

for me,
degrees360 = 8437.5

Hmm.. I did create a method that converts the huge degrees to 1 -> 360, but the encoder is very jumpy.

The issue I got right now, my angle measurement is not accurate. and I'm struggling to figure it out

Edit:
Fresh project, still jumpy
http://prntscr.com/c08vdd
http://prntscr.com/c08wvt

Right encoder: 289
Left encoder: 1318
Right encoder: 289
Left encoder: 1318
Right encoder: 289
Left encoder: 1318
Right encoder: 289
Left encoder: 550 <-----
Right encoder: 289
Left encoder: 1318
Right encoder: 289
Left encoder: 1318
LazyRoomba
Robot Addict
 
Posts: 179
Joined: May 9th, 2013, 6:22 am

Re: Roomba 530 OI serial data

Postby a1robotrepair » August 1st, 2016, 11:45 am

(289 - 1318 = -1029.) (-1029 / 512 = 2.001.) (-2.001 X 180 = -361.8deg.) (-2.001 X 3.14 = -6.285rad.) Turning right forward, left reverse 360deg. Change 512 to 514.5 for exact 360. Do I have left and right correct? I forget.
That's very close.
You may need to clean your encoders. There is no accounting for wheel slip or stall. Even using tethered coms, the update from the MCU creates errors. Getting it close, downloading your program and observation of the robots activity will enable fine tuning of your equations.
Roses are red Violets are blue Poems are hard Flowers and Chocolate
http://www.daycounter.com/Calculators/
a1robotrepair
Robot Master
 
Posts: 824
Joined: October 14th, 2013, 8:40 am

Re: Roomba 530 OI serial data

Postby LazyRoomba » August 1st, 2016, 11:57 am

I've added parameters that checks the encoder data and rejects and huge data changes, seems to be getting a stable stream now.

Using your new example;
Left = 5707
Right = 1745

(Left - Right = -3962) (-3962 / 512 = -7.73828125) (-7.73828125 X 180 = -1392.890625) (-7.73828125 * 3.14 = -24.298203125)

The left and right can have a huge gap, due to the limit been 65535.

I can get the angle by incrementing / decrementing the difference on each cycle within my code - how I can convert to 1 -> 360.

Looking at the raw encoder data tho, the right encoder does seem more jumpy. Probably clean it later today. Realized tho, alot of debris ends up trapped in the right wheel from the sidebrush..
LazyRoomba
Robot Addict
 
Posts: 179
Joined: May 9th, 2013, 6:22 am

Re: Roomba 530 OI serial data

Postby LazyRoomba » August 1st, 2016, 1:57 pm

After doing some extensive testing, I found on my Roomba the two encoders are too jumpy to be accurate. I've slowed down my script, even changed the wheels.

Left wheel:
19445
19471
19497
19266
19292
19316
19343
19369
19651
19676
19702
19729
19755
19523
19548
19574
19600
19627
19909
19934
19960
19984
20011
19780
19806
19833
19859


Right wheel:
-26148
-26142
-26117
-26091
-26065
-26295
-26269
-26245
-26219
-26192
-25911
-25885
-25858
-25832
-25807
-26039
-26013
-25987
-25961
-25935
-25653
-25627
-25601


These encoder readings were taken with my script that evens out the data spikes. I would suggest not to use the encoders for precise, fast-paced actions. Each line of data had a 0.1 second delay. Wheels were traveling at 50mm/s forwards using the drive command (137)
LazyRoomba
Robot Addict
 
Posts: 179
Joined: May 9th, 2013, 6:22 am

Re: Roomba 530 OI serial data

Postby a1robotrepair » August 1st, 2016, 4:11 pm

Encoder counts should accumulate unsigned forward or reverse. Your code has to determine which. Reset your bot, I think that clears the counts, check it after resetting. Hope you have 6 months at 70 hours a week to program.
Maybe third-deg will read this post and help shed some light on the situation
Roses are red Violets are blue Poems are hard Flowers and Chocolate
http://www.daycounter.com/Calculators/
a1robotrepair
Robot Master
 
Posts: 824
Joined: October 14th, 2013, 8:40 am

Next

Return to Robotic Hacking

Who is online

Users browsing this forum: a1robotrepair, justinall and 299 guests