interfacing xbee,atmega168 and serial port

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

Hi friends,
I am doing a project in which i have to take data from an xbee receiver to the atmega168 and then to a serial port through a level converter like max232.
my question is how to interface these three.if you have some idea then please help me.

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

Run the tx pin from the transmitter to the rx pin on the receiver. Make sure the electrical spec is the same.... either 0 and 5V ttl levels, or +-12v RS232 levels.

Imagecraft compiler user

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

Well the xbee datasheet shows how to interface to a micro controller and the max232 datasheets shows how to wire it to convert the PC serial interface to the micro controller.

Using the 168 USART to receive data from the Xbee and transmit to the PC you should be all set to go.

If you need two serial connections for two way communication on both the PC side and the xbee side i would use an atmel chip that has 2 usarts like the mega 162. You could bit bang the PC to avr communication using the 168 I suppose since the xbee I assume would be real time to the AVR and you have time to send the data to the PC. Depends on the data rate.

Another way if you don't need to process any of the data on the micro controller is to just set up an interrupt on change pin and mirror that on another pin to the max232 but then you may as well just use the max232 and forget about the 168.

Another way you could receive the xbee data directly through the max232 and use another com port on the PC to interface to the micro using one usart on the 168.

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

metron9 wrote:
Well the xbee datasheet shows how to interface to a micro controller and the max232 datasheets shows how to wire it to convert the PC serial interface to the micro controller.

Thank you for your kind response, but i need a little more help
I already connected the Tx and Rx of the micro to xbee to recieve data then what pins of the micro should i connect to the max232.also i am not interfacing with PC, i have to connect the serial port to the serial port on my robotic arm servo card.
here's the incomplete schematic in which i have connected the xbee and the micro but don't know how to connect to maz232.

Attachment(s): 

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

The way you have it, you can't without bit-banging a second serial port. As was suggested before, if you do not need bidirectional comms, connect the TX of the XBEE to the RX of the processor. Then connect the TX of the processor to the MAX chip.

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

It is possible to do in software what a uart does in hardware... shifting 1s and 0s in and out with microsecond precise bit times (they call it Bit Banging), but its sort of a kludge and not as fast or as accurate as a real hw uart. Seems lile Plan A would be use an AVR with 2 uarts.... one for the rf and one for the robot arm. Plan B is search thru the user projects here... there are several flavors of 'software uart' there. I'd get the avr uart working on the max232 and talking to the pc using hyperterminal. Write a little menu with items like 'send UUUU' 'arm up one step' 'arm down one step' and look at the sw uart commands on a scope. The UUUUU should be 104usec on, 104 usec off at 9600 bps.

Imagecraft compiler user

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

If your robotic arm requires a serial interface then you will need to connect the max232 to the micros serial port RX and TX pins. I have an xbee but I don't know how fast or slow it can be set for serial communications. You could use a tiny avr with a serial port to the xbee and then use a bit bang or 2 wire shifting algorithm using interrupts to communicate between the tiny avr and the main micro controller.

Like I said, the amount of data you are sending and receiving is needed to make a better decision on how to make the interface work reliably.

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

Hi Hobadirl,
After seeing your schematic I am just making a suggestion I think it may increase your circuit size but can come to your use
Use a multiplexer IC and connect the output of those to the VCC of MAX232 and XBEE(you cann use a DC-DC converter to come down to CMOS logic levels or 3.3 in this case).

Multiplexer can be connect to any general i/o pins and then at first use to select XBEE and then activate reception and after that select max232 for transmission.