XBee TO ATmega TO UART interface ??

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

Hi,
I am trying to connect the XBee module to ATmega Uc,

IT seemed easy but got really confusing on the way.

I want it to be connected directly between XBee module and ATmega RX and TX which I did.

Also I want it to be connected to PC RS232 via MAX232. So i can use API and also test it through hyper terminal.
I am confused as it also says need to connect the RTS and DTR pins of XBee to support serial firmware upgrades.

Attached is a basic diagram of what I did and need some help regarding this.

hope to hear from you..
regards
cals

Attachment(s): 

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

CALS,

STOP. Don't power up your circuit... You have a few connects that need to be corrected.

Concept first:
Mega UART TxD transmits data out to the XBee Din.
Mega UART RxD receives data in from the XBee Dout.

You have this backwards. As wired the Mega TxD and the XBee Dout will both try to drive the line, not a good thing if one device wants it low, while the other wants it high.

The Max chip will also try to drive the line it is tied too...

Next Concept:
Only one device can drive a bus wire at a time.
You have three devices: Mega UART, XBee, and Max chip.

Options:
You could have a couple of Headers with jumper, (shorting) pins to connect the XBee to either the Mega OR the Max.
Or you could have the Max just listen to the bus, and transmit the bus data to Hyperterminal, but this would not let you send the XBee commands from Hyperterminal.

Although the code is much more complex, another approach is to tie the XBee and the Max chip to separate UARTs on the Mega, and let the Mega route the data whichever direction and way you want it to go.

JC

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

Connecting three UART-based devices together is really hard. Here is the challenge:

1) Two devices, together, as JC pointed out, connect transmit of one to receive of the other.

2) How do you connect a third one? The only way that is sensible is if you can disable the inactive transmit output. You CAN do that with the AVR; disable Tx and turn the port pin into an input. You CANNOT do that with a plain MAX232 but there are versions of that chip that have an enable input; that will have to be controlled by the AVR. That leaves XBEE. You may not be able to control that.

3) Even if you are able to arrange things electrically, you still have problems. Suppose that you want to transmit data from the AVR out the RS232 port. That data is still present at the XBee DIN pin. What will the XBee unit do with that data? Likewise, when the XBee sends data, it will be present at both the RS232 and the AVR. Which one will act on it?

If you absolutely HAVE to do something like this, I would use a 4052 or 4053 analog switch to control which signal goes where.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

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

Hi,
thank you very much,
I have made few changes and attached the updated file,
with 3 jumpers.
1. For communication between Atmega and XBee --> JP3 is OUT and JP1 and JP2 are IN
2. For comm between PC and XBee (for firmware upgrades)
JP1 is OFF and JP2 and JP3 are ON
3. For atmega and PC comm --> JP1 and JP3 are ON and JP2 is OFF.

DO you think I can do it this way, and still use the X-CTU program. Did I get this right OR am I still confused ??

and also have two references attached maybe if someone else is confused !

regards
cals

Attachment(s):