Pages: [1]   Go Down
Author Topic: XBee Shield + GPS Shield = Gibberish?  (Read 6306 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I'm relatively new to Arduino, and I am trying to get a project up and running using an Uno board, a (SparkFun) XBee and GPS shield. I'm using an XBee series 1 and an EM-406a. The XBee communicates to my computer using the SparkFun USB Explorer board over digital ports 1 and 2 (uart). My GPS is set to dline and I have it communicating over ports 2 and 3 using the newsoftserial library.

My program for the Arduino works fine if I connect to the board over USB or if I have the XBee shield stacked directly on top of the Uno. But, I'd like to put the XBee shield on top of the GPS shield so that I can easily switch the XBee off uart to program the Arduino. But, if I stack the shields like that, after the 3rd command I send to the Arduino from my computer, I get never ending gibberish in the terminal that vaguely resembles what it should output.

Anyone know what's going on here? It doesn't make sense that the order I stack the shields in should drastically alter the way my project works, does it? Thanks all!
Logged

New York
Offline Offline
Edison Member
*
Karma: 1
Posts: 1023
E != m*c^2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What does the 3rd command do? Also, you said you use 1+2 for xbee and 2 + 3 for gps. Do you mean 0+1 and 2+3?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oops, yes. I mean 0 and 1 (the default TX and RX ports).

And it's not always the third command (that's just an average, I guess). It could be before or after; I'm not sure what triggers the gibberish. But I can send it anything. My commands aren't definite. I'm sending it keystrokes through a Mac program I wrote. But again, if I plug in the USB cable and bypass the XBee or if I stack the boards Arduino -> XBee shield -> GPS shield it works fine. It's just when I put it Arduino -> GPS shield -> XBee shield that it gets messed up. Unfortunately, I need the XBee shield up top so that I can easily switch the shield from dline to uart when I need to reprogram the Arduino.
Logged

New York
Offline Offline
Edison Member
*
Karma: 1
Posts: 1023
E != m*c^2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm afraid I can't help much there, you'll have to wait for more people to show up on the new forum. I would suggest checking to see if anything shorts (perhaps a brought out pin header on your gps shield touching the bottom of the xbee shield?)

Also, this might be happening when you flip the xbee/dline switch - try reproducing this error with the arduino -->xbee --> gps setup, that way you can be sure it isn't electrical.

Or, maybe your gps is getting interference underneath the xbee.
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 38
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try disabling the communication with the xbee sheild for a bit. Now, put LEDs on the serial out to where the xbee shield would be connected. See if you get any blinking.

If you do, consider moving the connections to another port if you can.

OR...

Are you sure that the software serial ports 2 and 3 are connected to the serial ports on the xbee shield, or is it connected to the gps shield? Given that you have a somewhat matching signal, it probably isn't this.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the suggestion. Unfortunately, I don't have any LEDs to play around with, although I suppose I could pick a couple up at Radioshack if necessary.

However, I can reproduce the error when I connect the XBee directly to the Arduino, but it takes a lot longer to get it. It seems like I get the random repeating gibberish when the XBee drops a packet, which for some reason it does a lot more when I have the GPS attached. Just to check, can someone check and make sure I'm reading the Serial port correctly?

From my loop function:
Code:
if(Serial.available() >0) {
    if(index < 19) // One less than the size of the array
    {
      inChar = Serial.read(); // Read a character
      inData[index] = inChar; // Store it
      index++; // Increment where to write next
      inData[index] = '\0'; // Null terminate the string
    }

The only other thought I have is that maybe there isn't enough power to run both the XBee and GPS and that's why it keeps dropping packets. I'm running the whole thing through a 9V battery hooked up to the bullet connector on the Arduino.
« Last Edit: January 25, 2011, 10:57:46 pm by brian515 » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, I think I've solved it!   smiley

I was placed a closing curly brace too late in my loop function so that when the serial input was 0, it would kick out of the if statement, but continue the loop function and mess with my variables. smiley-red Ugh, all that time wasted...

Thanks for the help anyways!
Logged

New York
Offline Offline
Edison Member
*
Karma: 1
Posts: 1023
E != m*c^2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ehh, it happens  smiley-razz
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You should be reading the serial data using a while loop, not an if test. On every pass through loop() (or whatever function that snippet was culled from), you want to read all pending serial data, not just the next byte.
Logged

Pages: [1]   Go Up
Jump to: