No communication with a pair of XBees

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have been trying to send a set of values from an Arduino to an ATmega 2560 development board. I have been observing the output on an 8 LED array connected to PORT B of the AVR.

Wiring (XBee to Arduino):

RX<->TX

TX<->RX

3.3V<->3.3V

GND<->GND

 

 

Wiring (XBee to dev board):

RX<->PJ1

TX<->PJ0

3.3V<->to a separate Arduino 3.3V pin

GND<->GND

 

The code I have on the AVR side is:


#define F_CPU 14745600UL
#include <avr/io.h>
#include <util/delay.h>
#include <avr/eeprom.h>
#include <math.h>
#include <avr/interrupt.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>

#define BAUD 9600									//serial com;
#define BAUDRATE  ((F_CPU/(BAUD*16UL)-1))
//Serial intialization
//Serial end

void serialstart_3();

int main(void)
{
	serialstart_3();
	sei();
	/* Replace with your application code */
	while (1)
	{
		
	}
}

ISR(USART3_RX_vect)
{
	
	RX_raw=UDR3;

}

void serialstart_3()
{
	UBRR3H=BAUDRATE>>8;
	UBRR3L=BAUDRATE;
	UCSR3B=0b10011000;//enable RXEN TXEN
	UCSR3C=0b00000110;// UCSZ1 UCSZ0
}

When I'm sure that I'm receiving the values properly, I will be using to values to drive motors, toggle LEDs, etc.

 

I'm not really proficient in how an XBee works, and it'd be really useful if anyone has any links that I can refer to for Xbees.

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Haven't looked at your code, but have you got your LED arrary working? I.e are you able to display characters and/ or strings etc? It could be working you just are seeing it because there's a problem with your display code.

 

Apart from that, this raises an eyebrow:

 

VoltAmpereWatt wrote:

RX<->TX

TX<->RX

3.3V<->3.3V

GND<->GND

 

 

Wiring (XBee to dev board):

RX<->PJ1

TX<->PJ0

3.3V<->to a separate Arduino 3.3V pin

GND<->GND

 

If you are using your Arduino to supply both XBee modules with +3.3V, then you need to connect the grounds together.

 

Also it might be helpful to anyone else reading this that might want to contribute and help you if you post a link to a datasheet or any relevant info for your ATmega2560 dev board, unless it is something you have designed yourself of course...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Had you properly configured both Xbee devices to opperate at least one as coordinator ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

VoltAmpereWatt wrote:
I'm not really proficient in how an XBee works, and it'd be really useful if anyone has any links that I can refer to for Xbees.

 

Colour me obvious, but how about https://www.digi.com/lp/xbee

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can you connect tx->rx, rx->tx, plus gnd between your two arduino's and get it to work without the radios?   That would be my first troubleshooting step.

 

Jim

 

 

FF = PI > S.E.T

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Howard_Smith wrote:

Haven't looked at your code, but have you got your LED arrary working? I.e are you able to display characters and/ or strings etc? It could be working you just are seeing it because there's a problem with your display code.

 

Apart from that, this raises an eyebrow:

 

VoltAmpereWatt wrote:

RX<->TX

TX<->RX

3.3V<->3.3V

GND<->GND

 

 

Wiring (XBee to dev board):

RX<->PJ1

TX<->PJ0

3.3V<->to a separate Arduino 3.3V pin

GND<->GND

 

If you are using your Arduino to supply both XBee modules with +3.3V, then you need to connect the grounds together.

 

Also it might be helpful to anyone else reading this that might want to contribute and help you if you post a link to a datasheet or any relevant info for your ATmega2560 dev board, unless it is something you have designed yourself of course...

Here you go:
http://www.nex-robotics.com/products/microcontroller-development-boards/avr-development-boards/atmega2560-development-board-mini.html

Also, are you referring to grounding the development board and the Arduino powering the Xbee connected to the development board, or the other separate Xbee?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

Can you connect tx->rx, rx->tx, plus gnd between your two arduino's and get it to work without the radios?   That would be my first troubleshooting step.

 

Jim

 

That's been tried, yes. I don't have problems with that. Since you do mention it, I'm okay with starting from scratch again and adding components to it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

andre_teprom wrote:

Had you properly configured both Xbee devices to opperate at least one as coordinator ?

Yes, I got the devices from a friend and they've been already configured by him.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, the next step is a loop back test, connect one arduino to the xbee, on the other xbee connect only power/ground and connect it's tx to rx (loopback)

Now see if you can send and receive what you sent.  i.e.  send "Hello World!" and see if you can receive it back.

Once you have that working, remove the tx/rx short and connect to the other arduino.

Good luck.

 

Jim

 

 

FF = PI > S.E.T

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For simple point to point serial comms you do not need to configure a coordinator/endpoint.  The XBEE does simple serial comms very well if you set it up properly.  I have several zipping around here as dedicated point to points without them crashing into one another.

 

What baud rate are you communicating at - I have not looked at your code?  The XBEE needs to be matched to your baud rate or vice versa or you are not going to get anywhere.

 

Now to do simple serial communication you need a few things

 

1) a PAN id - Personal Area Network id...This can be any four digit number  Lets use 1234

 

2) a unique address for each radio.  Lets say 1 and 2

 

3) the baudrate your devices are communicating at.

 

Setup:

Download and install XCTU to your PC.  I suggest you use the $50.00 development kit as it comes with two programming boards and USB cables if your friend will loan you one of them great

 

Mount a radio into the programming board and plug it into the PC...Let windows find and install the FTDI drivers

 

Launch XCTU, and discover the radio.

 

On the right side you will see the parameters of the unit you can program.  I would default the unit so you can start over.

 

OK, now based on the unit being defaulted do the following:

 

At the top of the list should be the PAN  I think the default is 3332 or 3335...change this to 1234

 

Next should be the remote ID - again I cannot remember the exact nomenclature but it will have a high address, and a low address.  put the number 2 in the LOW address

 

Below that should be MYid or MYaddress...Again with a high address and a LOW address....put the number 1 in the LOW address.

 

Scroll down until you find the BAUD rate..I think its right below the MYid.  There will be a dropdown with common baud rates.  This is where you choose one of the common baud rates...9600 is the default.

 

Click on WRITE at the top of the list to save this to the radio.

 

Unplug the board, and mount the other radio in it and plug it into the PC, re-discover the new radio and repeat the above steps

 

Set teh PAD id to 1234

 

In the REMOTE ID LOW address, put the number 1 as this radio is communicating with the one you just configured.

 

In the MyID or MyAddress LOW address put the number 2

 

set the baud rate to 9600 if it is not already done.

 

CLick on WRITE at teh top of the list to program the radio.

 

The radios should now be paired to one another and communicate at 9600 baud.  THere is a white paper on this in the support secion of DIGI's website that Andy was nice enough to post.

 

I am not in front of my PC right now, but will be in a few hours and can make screenshots if need be.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgmdesign wrote:

For simple point to point serial comms you do not need to configure a coordinator/endpoint.  The XBEE does simple serial comms very well if you set it up properly.  I have several zipping around here as dedicated point to points without them crashing into one another.

 

What baud rate are you communicating at - I have not looked at your code?  The XBEE needs to be matched to your baud rate or vice versa or you are not going to get anywhere.

 

Now to do simple serial communication you need a few things

 

1) a PAN id - Personal Area Network id...This can be any four digit number  Lets use 1234

 

2) a unique address for each radio.  Lets say 1 and 2

 

3) the baudrate your devices are communicating at.

 

Setup:

Download and install XCTU to your PC.  I suggest you use the $50.00 development kit as it comes with two programming boards and USB cables if your friend will loan you one of them great

 

Mount a radio into the programming board and plug it into the PC...Let windows find and install the FTDI drivers

 

Launch XCTU, and discover the radio.

 

On the right side you will see the parameters of the unit you can program.  I would default the unit so you can start over.

 

OK, now based on the unit being defaulted do the following:

 

At the top of the list should be the PAN  I think the default is 3332 or 3335...change this to 1234

 

Next should be the remote ID - again I cannot remember the exact nomenclature but it will have a high address, and a low address.  put the number 2 in the LOW address

 

Below that should be MYid or MYaddress...Again with a high address and a LOW address....put the number 1 in the LOW address.

 

Scroll down until you find the BAUD rate..I think its right below the MYid.  There will be a dropdown with common baud rates.  This is where you choose one of the common baud rates...9600 is the default.

 

Click on WRITE at the top of the list to save this to the radio.

 

Unplug the board, and mount the other radio in it and plug it into the PC, re-discover the new radio and repeat the above steps

 

Set teh PAD id to 1234

 

In the REMOTE ID LOW address, put the number 1 as this radio is communicating with the one you just configured.

 

In the MyID or MyAddress LOW address put the number 2

 

set the baud rate to 9600 if it is not already done.

 

Will report back when I get the Xbees back later in the day.

CLick on WRITE at teh top of the list to program the radio.

 

The radios should now be paired to one another and communicate at 9600 baud.  THere is a white paper on this in the support secion of DIGI's website that Andy was nice enough to post.

 

I am not in front of my PC right now, but will be in a few hours and can make screenshots if need be.

 

JIm