Shop OBEX P1 Docs P2 Docs Learn Events
Death by serial problems. Help!! — Parallax Forums

Death by serial problems. Help!!

NoBo780NoBo780 Posts: 94
edited 2009-07-11 20:14 in Robotics
I swear, nothing has confused or urked me ask much as thus problem I am having right now, trying to get a microcontroller to communicate with an iRobot Roomba. So basically, I have noticed that my BS2 CAN receive sensor data from the Roomba, but neither my PC nor my other microcontroller I'm familiar with, the Arduino as it is called, are able to receive the sensor data packet. I have tried to shed light on this on and off for over a year, and I've picked it up again, hopefully to solve it once and for all.

Tod E. Kurt published a book called "Hacking Roomba' a while back. I was pretty intrigued about the whole Roomba as a developer's toold idea, and so I decided to get one to start working on. I made the 'roomba serial tether' from the book, so I can hook up the roomba to my PC, and I also made the cable that can be used to hook into any microcontroller capable of controlling the Roomba. The problem has been receiving sensor data from the Roomba; I just can't pull it off. I even tried using the BS2 and Arduinos in a master-slave configuration (because I knew that for some reason, at least the BS2 was able to get the sensor data, so I figured "why not use the BS2 to get sensor data, and use the Arduino for the dirty work..."), but that didn't work for some odd reason. I saw this post HERE on that, but I can't seem to get the gist of it (the timing is tricky even at 2400bps; I know I have to use the WAIT, SERIN, SEROUT commands etc.).

I may have even posted here about this before, but if I did, it has never been resolved. This post has additional information on things I've already tried; if you can, please read that; it'll make more sense out of this!

Thanks for all your support.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Giggly Googley!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-29 01:33
    Condolences. Take a break, go out and do something fun, maybe you'll figure something out.

    If you would like more specific support, you really have to give more details about what you know, what you've tried, what has worked, and what has not. I know you've touched on that, but it's really very sketchy. There's an art to telling a story to capture someone else's imagination. You have to flesh out the story, hang some meat on those bones.
  • iDaveiDave Posts: 252
    edited 2008-11-29 01:44
    I feel your frustration! I have a similar issue trying to get a bs2 with a transmitter to talk to a picaxe with a receiver. Had no luck yet so I'll be paying attention to this thread. Just want my bs2 to play nice with others!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "THE ONLY TRUE WISDOM IS IN KNOWING YOU KNOW NOTHING." - SOCRATES
  • SRLMSRLM Posts: 5,045
    edited 2008-11-29 03:51
    Ohhh, Story Time! Tell me! Show me pictures!
  • NoBo780NoBo780 Posts: 94
    edited 2008-11-29 04:26
    Ok. Sorry about that.

    So, as far as what I have TRIED, here goes:
    I have hooked up my BS2 to the roomba, uploaded the 'bumpturn' code (from the book or http://hackingroomba.com/), and ran it; it worked. Then I have tried interfacing my arduino (ATmega168 on the 'Arduino' carrier board) to the roomba, and running the 'bumpturn' code written for the arduino, which does NOT work. The arduino IS able to send the roomba commands, but ISN'T able to receive sensor data from the roomba. Ergo, the 'bumpturn' code is more like 'bump&die' if you know what I mean. So, I tried to fiddle with the code to see what might fix the problem. I don't want to have to re-type the details on the code I fiddled with & the discoveries I made by doing so, so here's the directly copied post I posted in another forum about it:
    Me: said...

    AHA! I noticed something here. In the 'bumpturn' code for the arduino, it seems that if I tweak the wait time after the 'get sensor data' ROI command is issued, some weird things happen. Here's the snippet I'm talking about. At line 4 of this code snippet is the part where it waits for the roomba to read all its sensors. Originally, the code off of the hackingroomba website has this delay set for 100ms. But apparently, that is too long, because you get no reaction from a bumper activation with that long of a wait. So I reduced it, but at a really low value makes it constantly spin right for some reason. And so, after tweaking the delay, I found that something very weird happens. The whole thing DOES respond to the RIGHT bumper. But after a bumper is hit, the arduino freaks out; it resets, and the RX and TX lights blink like crazy. Does this have to do with the pull-down resistors/TX/RX interference problem you talked about? I took a look at the schematics for the model of arduino I'm using, and it looks like it does have resistors in series with the RX and TX pins, just FYI.

    What is wrong??
    void updateSensors() {
      Serial.print(142, BYTE);
      Serial.print(1, BYTE);  // sensor packet 1, 10 bytes
      delay(64); // wait for sensors
      char i = 0;
      while(Serial.available()) {
        int c = Serial.read();
        if( c==-1 ) {
          for( int i=0; i<5; i ++ ) {   // say we had an error via the LED
            digitalWrite(ledPin, HIGH);
            delay(50);
            digitalWrite(ledPin, LOW); 
            delay(50);
          }
        }
        sensorbytes[noparse][[/noparse]i++] = c;
      }   
    }
    
    



    More specifically, what I noticed about the behavior of the code, the error statement NEVER comes true, so the arduino IS seeing some serial data coming from the roomba (aka c is never = -1). I will also note it is EXTREMELY hard to debug what is going on in the code, due to the fact that unlike the BS2, the arduino only has two pins that it can use for serial communication, and they are BOTH being used when connected to the roomba; this isn't like an I2C interface.

    It may also help if you look in that forum (HERE) about this issue, because there's something that this guy posted there about there being a problem with the 'transistors on the RX and TX pins of the Arduino interfering with communication' or something along those lines.

    Let's NOT focus on bringing the BS2 with the master/slave config. into the equation UNLESS you think that it would be easier to do so. Again, the reason why I wanted to do that in the first place is because I knew that the BS2 was already able to receive the data from the roomba, and so I could just use it as a slave w/ the arduino, and have it send the data to the arduino when called upon. Anyone with a good programming background in C (or a combination of C-based languages) should be able to help me try to troubleshoot getting the arduino to receive the sensor data from the roomba...

    Another stab I took at it was I thought maybe I had done something terrible wrong that had destroyed the roomba's TX pin. I will note that I have NOT been able, with ANY program (be it hyperterminal, roombacomm, roomba status, etc.) to receive the sensor data...maybe it's a coincidence, I don't know, but I DO know that the BS2 can receive the sensor packet, which boggles my mind...

    I hope that clears things up a bit. smilewinkgrin.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Giggly Googley!
  • NoBo780NoBo780 Posts: 94
    edited 2008-11-29 04:28
    I promise to have pictures soon; let that be a motivator! smilewinkgrin.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Giggly Googley!
  • SRLMSRLM Posts: 5,045
    edited 2008-11-29 04:49
    So, in one sentence, your problem is:

    You don't know if the problem is that the Roomba is sending the data incorrectly (or not at all) or that the uC is not getting it correctly.

    Correct? If so, an oscilloscope would be very handy. Simply hook it up and see what shows on the screen. You may be able to get away with an LED and watch for flashes. Another thought is to have the uC watch for a pin state. If it changes, you can (possibly) assume that data is being sent. Also, if this is an Arduino question, their forums can probably answer better any uC specific problems.
  • NoBo780NoBo780 Posts: 94
    edited 2008-11-29 04:57
    No, actually. I have concluded that the problem is the timing in which the arduino receives the sensor data. But that still leaves the question of why my PC can't receive the sensor data...

    UPDATE: I used hyperterminal, and my PC successfully received serial information from the roomba, so at least I know that it doesn't have to do with
    a) the RS232-TTL cable I made
    b) my PC; it must have to do with the programs I was using/the configuration.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Giggly Googley!

    Post Edited (NoBo780) : 11/29/2008 5:19:03 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-11-30 16:20
    So it appears to me that the BASIC Stamp code works, but your Arduino does not. Since this is a Parallax Support Forum you will really need to post the Arduino problems on an Arduino support forum.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • NoBo780NoBo780 Posts: 94
    edited 2008-11-30 18:36
    Yes, that would be a good idea. I came to this forum first because I feel that it is more active than the arduino forums; I've noted that before. But if there is no one here that can help, I guess it would be wise to post elsewhere...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Giggly Googley!
  • SRLMSRLM Posts: 5,045
    edited 2008-11-30 21:46
    It's sort of asking a Navy F-22 pilot to fly a Russian MIG: they both do more or less the same thing, but they are very different in how they work.
  • NoBo780NoBo780 Posts: 94
    edited 2008-12-01 01:57
    Ok. How about this; let's go back to my original trial, getting the BS2 to communicate with the arduino. I just need to get the TIMING right. HOW do I do that? Of course, first of all, I know you need the baud rate set the same for both microcontrollers. And I know that before sending serial data from the BS2 to the arduino and vice-versa, you need to send some sort of notification, then wait for an 'OK I can receive data now' from the other microcontroller.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Giggly Googley!

    Post Edited (NoBo780) : 12/1/2008 2:31:38 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-12-02 15:24
    Going back to your original question would put us back in the same situation as before…having to know the architecture and programming for the Arduino, which we cannot support here. If you have questions about the BASIC Stamp serial communication that are not already answered by the manual, we could answer those. But in relation to communication with another microcontroller is off topic. The other device is programmable and may or may not have specific hardware for accomplishing the task.

    Serial communication with the BASIC Stamp is pretty straight forward. I’m sorry that is not the case with your other microcontroller. Perhaps they have a support forum that can help you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-12-02 15:32
    Okay, I was asked via private message in relation to this thread what the difference is between talking to an accessory and another microcontroller, so I am going to cover that.

    When you are communicating to a serial accessory via the BASIC Stamp you are using a fixed communication protocol specified in the accessory datasheet. Conversely, when you are communicating with another microcontroller, there is no defined or fixed protocol. You define it. You become responsible for defining the way these two devices will communicate with the code on each unit.

    When talking to an accessory or peripheral device/chip you are sending/receiving bytes defined by the device datasheet using the specified protocol. You don’t have to write code on the target device to establish communication. Conversely when talking to another microcontroller you need to know the language of the target device in order to program it. You also need to know the architecture of the device as it may or may not have specific hardware designed for this communication and that may require additional programming considerations.

    This is why we have to defer issues regarding other microcontrollers to their own support forums. This way there are people there who know this information and can offer the proper assistance. I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • SRLMSRLM Posts: 5,045
    edited 2008-12-02 16:17
    You could use an EEPROM to communicate. I tried it with two BS2s and it worked, although it was a bit slow. Anyway, what you do is you dedicate three pins on each uC: two for the I2C to the EEPROM, and one direct link between the two. You use the direct link as sort of a simple high-low flag from master to slave, to let it know when it's okay to write/read the EEPROM. Then, simple have each uC work on the same spots in the EEPROM (by giving each the address of the workspace). I'm assuming that the ardruino can do I2C EEPROMs, and I know that the BS2 can.

    If you don't like that, then you could do two general types of communication: synchronous or asynchronous. I have no idea which is supported by the ardruino, but those are your choices (not including tm'd protocols like I2C and OneWire)
  • MovieMakerMovieMaker Posts: 502
    edited 2009-07-11 02:57
    It may be a baud rate thingy. I have recently also been trying to get the arduino mega to talk to the roomba 530.· It sends commands, they make the roomba move. but, i think it is not listening to the roomba.· I only tried it once so far.· It is going to take a whole lot more reading for me. I am using a RooStick and an 8 pin straight through cable.





    By the way, did you hear about the Carniverous Robots? Do a Google Search. This was one of the coolest ideas ever. I am going to intergrate this into the robot I am working on now. It is way to cool not to include it.



    Good Luck!·· tongue.gif
  • NoBo780NoBo780 Posts: 94
    edited 2009-07-11 03:43
    At this point in time, I have returned to this (yet again), and now it's seriously pissing me off. I have not a clue what I am doing wrong. I am even going to start getting help from some EE students on this issue. But that isn't going to be until a bit. For now I'm on my own, and all I can say is, I'm stumped more than I've ever been before, and it royally sucks. mad.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Giggly Googley!
  • Mike GreenMike Green Posts: 23,101
    edited 2009-07-11 03:53
    When you have timing errors, it's a bear to sort out if you don't have some kind of logic analyzer or oscilloscope. You're guessing otherwise. Try to find someone with either or both instruments.
  • NoBo780NoBo780 Posts: 94
    edited 2009-07-11 20:14
    Yup. I should have access to those instruments very soon; Hope it will help...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Giggly Googley!
Sign In or Register to comment.