Hi - i am trying to use the dsPIC30f3012 MCU to get UART data to a PC and am having some trouble setting up the xbee link. I am using the series 1 xbees with the wire antenna, and have the transmitter connected to an xbee board to breadboard it (http://www.nodna.com/print_product_info … cts_id=868) and the receiver connected to the PC through a usb board (http://www.dontronics-shop.com/990002-x … board.html). Since I am only using the MCU UART to get data to the XBee transmitter, I have a logic level converter (http://www.sparkfun.com/commerce/produc … ts_id=8745) that takes the 5V MCU UART to 3.3V for the xbee’s DIN pin (the converter doesn’t work with analog signals). Xbee firmware is version 10E6. I configured the xbees as follows using xctu:
Transmitter: Baud=9600; PAN ID =1111; MY = 10; DL = 11; CH=C (default)
Receiver: Baud=9600; PAN ID =1111; MY = 11; DL = 10; CH=C (default)
Everything else i left the way it was for both xbees: IU=1;IT=1;IR=0; RO=3;A1=0;CE=0 to name a few parameters. I am simply interested in getting MCU UART data to the PC through the xbees; it is very likely that the transmitter will only transmit and the receiver will only receive. Both the xbees, the MCU UART, and the xctu are set at 9600 baud, with the 8,N,1 configuration. The 2 xbees are maybe 12 feet apart in the lab.
I did a node detect with the xctu (atnd) and the receiver successfully detects the transmitter. But i tried doing a range test, and i get “Timeout waiting for data” error all the time and every tx is bad. I just went into the range test tab, and clicked start - i hope i am doing the range test correctly?
Also, i setup the MCU uart and tested it using a loopback test and the MCU UART seems to work. But i tried sending data (decimal 100 a few times) through the UART to the xbee’s DIN pin for tx, and nothing is received in the terminal window of xctu on the PC end. Apart from the node detection, nothing else seems to work. I am obviously doing something wrong, maybe i did not configure something right?
To do a range test you need to have two XBees. One is connected to your PC, and of course you have XCTU connecting to it. The other must have power, and it must have the DIN and DOUT pins connected together, so that whatever data it receives it retransmits imediately. The XBee connected to XCTU sends out a string, and listens for that string to be sent back to it - that’s how it knows that it has made contact.
This doesn’t make sense. The XBee’s Addresses are 64bits long and require 8 bytes (16 ASCII chars).
For one XBee to send to another XBee the sending XBee’s DL & DH must match the SL & SH of the receiving XBee.
Re-check these parameters.
I assume he’s giving the decimal equivalent of the DL addresses. If you run XCTU and read the parameters it’ll tell you that the DL = 0 by default, and it’s not unusual to set it to 1 or 2 or 3. Of course “0” means 0000000000000000… but for obvious reasons, we usually just say “0” (or “1”, or “11”, or whatever).
In addition, it’s not necessary that the DL and DH match SL and SH. DH is usually left at 0 (the default value). The MY of the receiving module must equal the DL of the sending module, as he has it. Perhaps you’re working with somewhat different modules? I’ve never concerned myself at all with SL and SH.
You probably right as I do use the Series 2 modules but have made this suggestion to people with Series 1 modules and it did work. So there are a few ways to get one module to connect to another.
You’re probably right as well, but more importantly, his “MY = 10, DL = 11” on one module and “MY = 11, DL = 10” on the other should be just fine. That’s not causing the problem.
For the range test, my DIN and DOUT for the remote xbee were NOT connected together; i will make that change and let you know how it goes.
Do you have any insight into why i am not being able to get any MCU UART data to the PC through the xbee link? Perhaps i made a mistake somewhere else?
First connect the MCU UART with wire to the the PC with an RS232 translator. You can remove the XBee’ from the the PC side adapter and wire the Din to Dout lines. Get this working first to ensure that the MCU UART is setup correctly. Once you can get the MCU talking to the PC add the XBees back to create the wireless link.
Getting the PIC’s UART setup is a task in of itself. You don’t need to complication of the XBees when getting this to work.
You can use X-CTU as a terminal to test the PIC without the XBees.
Here is a link to info on setting up Series 1 XBees:
I agree with WaltR: get your project working one part at a time.
The XBee simply accepts serial data and transmits them. On the receiving end, the XBee simply takes whatever data it receives, and sends them out the DOUT pin as serial data. You need to make certain that you’re able to send the right serial data out the PIC, and that on the receiving end, you’re able to receive serial data and display them properly.
It does sound (based on your first post) as though you’ve thought of much of that already, but it’d be worth verifying. If the range test works properly, then you know you have a valid setup between the two XBees, and if you’re not getting your data, it’s something about how you’re connecting to the XBees.
I tied DIN and DOUT together on the remote XBee to do the range test and then it worked. During the range testing, i found that there was some loose connection between the remote xbee board and the pin headers that i was using to connect the xbee board to the breadboard (the board fits on top of the pin headers with the headers going through holes in the board) - it seemed that the xbee board had to be pushed in/out a certain distance onto the pins to connect properly - leaving the board right on the edge of the pins seems to work the best. I thought there might be loose connection with the logic level converter board too (which was connected to the breadboard in a similar way with pin headers) so i replaced the level converter board with a resistor to bring the MCU UART voltage down to 3.3 from 5. After that change, i was able to transmit MCU UART data to the PC through the xbees and receive it on the terminal screen. So it worked out. Though i am still a bit puzzled with the whole loose connection business, if that was truly what it was.
The next step for me now is to try and get the xbee serial port data on the PC receiving end with MATLAB, so i will start working on that.
Hi again - does anyone know what data format/byte-order/data frame the xbee transmission packet comes in at the PC serial port? I know it starts with a 7E sync byte, followed by length bytes, API type, source, etc. I found an example of this in this forum (interfacing xbee with accelerometer) where the data format is specified when the A to D pins were being used.
However, since i am not using any AD pins and will only use the UART for serial communication, i am wondering what data format serial communication only would appear in? Some identifying bytes/framing bytes will not be needed (compared to the AD data format).
i wanted to know the xbee packet data format since i will need that to try and read the MCU UART data with matlab on the PC end.
The format you found is only if you’re using API mode, which I don’t think you are. You have to explicitly turn it on in the AT settings, and you didn’t mention doing so.
Otherwise it’s straight serial data: you send a character, and that character is passed through.
thanks sylvie - no i am not doing anything in API mode, its all in AT mode. So if i read the serial port, i will just read whatever number i have sent?
Do you know if this number will still have the start and stop bits around it and if i will have to discard those when reading with matlab? Meaning if i send ‘8’ for example from the transmitter xbee to the receiver xbee, will the serial port read (i am using the 8-N-1 setting): 0 (start bit), 00001000 (8 in 8 bits), 1 (stop bit) so this would mean that i would have to discard the start and stop bits after reading them from the serial port to get the actual character transmitted? I think the xbee UART works in this format?
Or is the case that when i read the serial port, i will only get the character/number transmitted, so i will only read 00001000 and turn that into 8 with matlab?
The XBee UART’s for both receiving and sending are 8N1 Async, so yes, there is one start bit, 8 data bits and a stop bit.
If MATLAB is running on your PC (or MAC) The XBee to USB adapter will strip off the start ans stop bits (just like the UART in the PIC does) and MATLAB should only be getting the 8 data bits.