Home/Support/Support Forum/Can transmit and receive using mbed.

Can transmit and receive using mbed.

0 votes
I am using two XBEE S1 devices and want to communicate using an mbed microcontroller. I set both PAN IDs to 3332 using the XCTU app. For first XBEE: MY=1, DH=0, DL = 2 and second XBEE: MY=2, DH=0, DL=1 -- all else is default. My simple initial test is to use a single mbed to send/receive bytes to/from the first XBEE and use the second XBEE + XCTU to receive and transmit bytes.

The mbed rx/tx port is set to 9600baud, 1 stop bit, no parity, no flow control. I also use a terminal program to see the bytes transmitted & received via the mbed.

I am using a XBEE breakout/USB device that is here:

When I use the two XBEEs with the breakout boards and both connected to the PC, The byte communication works as expected. I can communicate both ways.

The mbed and its XBEE are set up using a protoboard and the second XBEE is connected to the PC via its USB/breakout device -- for this initial attempt.

What I see is that I can receive bytes at the mbed sent via the XCTU with its XBEE. However, I cannot seem to send bytes from the mbed to the second XBEE. Oddly, it seems that the mbed bytes are sent to its XBEE but immediately they are received back at the mbed from where they were transmitted. Its working like a tx-to-rx loopback.

The mbed serial rx/tx lines are connected to breakout board: rx-to-rx and tx-to-tx.
asked Oct 17, 2015 in RF Solutions and XBee by jekain314 New to the Community (5 points)

Please log in or register to answer this question.

1 Answer

0 votes
It sounds like you are connected into an RS485 serial port instead of a 3VCMOS level UART or you have a Bridge occurring between the lines. May I suggest taking the radios out of the picture and just connecting the processor to the PC to start with? This way you have a few less items that can be giving you issues to work from.
answered Oct 19, 2015 by mvut Veteran of the Digi Community (15,195 points)
Thanks for the rapid response.

The mbed connection to the pc works. I am very familiar with this device and have used it frequently. However, I will describe below a very simple exercise that uses only one xbee/mbed in the loop.

The microcontroller I am using is the mbed LPC1768 which uses 3.3V logic levels. Also, I checked the serial out with a scope and can see the 3.3V serial from the mbed. The mbed is powered by the USB and I have a terminal program to see the diagnostic bytes accessed by the mbed.

 I have placed a simple program on the mbed device to send bytes to the mbed tx line and into the rx line of the xbee. The xbee is connected to the mbed using a foca USB breakout board with discrete breadboard wiring. The tx line from the xbee is connected to the rx line of the mbed. I am powering the xbee from a separate 3.3V supply ands the power light stays steady.

I can see that the bytes I transmit to the xbee from the mbed are received back at the mbed. This suggests that there is some bridge (as you suggest) between the xbee rx-tx lines; what is received at the xbee rx is transmitted out the tx line. I have tested the lines and there is no electrical continuity between them. I see this same result on two different xbee/breakout boards. I have ordered two additional xbee S1 devices and Sparkfun USB breakout boards to restart this later this week.

The xbee devices were set up with the XCTU utility. The only settings changes from default were: ID=3332, MY=1, DL=2  and ID=3332, MY=2, DL=1. I have tested the communication between two xbee devices without the mbeds and using AT commands and all looks good. I have added the simple mbed code below. I also have placed a similar question on the mbed forum.

#include "mbed.h"
Serial xbee(p9, p10); //Creates a variable for serial comunication through pin 9 and 10
DigitalOut rst1(p11); //Digital reset for the XBee, 200ns for reset
DigitalOut myled1(LED3);//Create variable for Led 3 on the mbed
DigitalOut myled2(LED4);//Create variable for Led 4 on the mbed

Serial pc(USBTX, USBRX);

void ReceiveXbee()  //Interrupt service routine upon receipt of an xbee byte
    unsigned char c = xbee.getc();  //get the byte from xbee
    pc.putc(c);  //put the received byte to the pc terminal window
    myled1 = !myled1;  //blink an LED

int main() {
    xbee.attach(&ReceiveXbee);  //attach the xbee interrupt service upon byte receipt
    xbee.baud(9600);  //xbee baud rate
    pc.baud(9600);  //pc serial baud rate

    while (1) {
        wait(0.50);   //wait 0.5 secs
        xbee.putc(0x55);  //send a byte out the mbed tx to the xbee rx
        wait(0.50); //wait 0.5 secs
        xbee.putc(0xAA); //send another byte out the mbed tx to the xbee rx
        myled2 = !myled2;  //blink an LED
You have eliminated the radios already so the issue is not on the radio but must exists within the processor or the connection in the processor.  Again I would suggest removing the radio out of the system and then run a wire between the Tx of one side to the Rx of the other and then back the other way.  This way you can see if you have the same issue with a hard wire connection. If you do, then you know that you must have a Code issue or a connection issue at the processor.
I have ordered/received all new xbee hardware considering that I may have damaged the xbee or explorer devices. I have two new Sparkfun explorer boards and two new xbee series 1 devices. I am attempting to connect the two xbee radios to two mbed microcontrollers (LPC1768).

As an experiment, I have set up two separate Rx/Tx serial ports on both mbed devices and have communicated successfully between the two mbed devices. There is no pc in the loop; I just light an onboard LED when I transmit and receive a byte to each mbed. But with the xbee radios in the loop, I cannot get this to work. I can also communicate successfully between the two xbees using the XCTU utility so all the hardware I am using tests successful when used independently.

My latest experiment is to use a single xbee and connect its DIN pin to the TX1 pin of a single mbed and the xbee DOUT pin to the RX2 pin of the mbed. The TX1 and RX2 pins are from two separate serial ports on the mbed to prevent potential crosstalk. The RX1 and TX2 mbed pins are not connected to anything. These are the only cabled connections and the xbee attached to the explorer board is NOT even powered in any way. When I run the mbed in this way, I see that the bytes sent out the mbed TX1 pin to the DIN are reflected back out the DOUT pin of the xbee and received at the RX2 pin. This is clearly shown by the flashing LEDs. If I unplug either of the DOUT or DIN wires from the xbee, the byte reflection stops. I have used the 100% default xbee settings as well as 100% default but with: ATMY=1, ATDL=2;

Any assistance would be appreciated.