I’m trying to send some info to me base xbee form my remote xbee, but at the same time I want to send something form the base one to the remote one.
I’ve read somewhere that it cannot be done at exactly the same time but if the Xbee is configured in transparent mode (which is) it should multiplex my signals on it’s on and it may seem like a half duplex.
Can amyone tell me how to do this, is there any configuration that can be done on the xbee, or does it have to be all programmed on a microncontroler or somewhere else.
Has anyone ever done this, are there any codes I could use to solve my issue, Thanks
Yes this does work however you must understand how the communication works.
The RF link is only one way at a time (half duplex) but the XBees UART have independent TX and RX lines and internal FIFO buffers. So, the serial connection to the XBEE’s UART can send and receive at the same time.
This should be working if the XBee’s are properly setup in Transparent mode.
Then its up the the XBee’s configuration (AT settings) and firmware to group together the data in the TX FIFO and send it as an RF packet. Same with receiving an RF packet, the XBee will decode the RF packet and put the data into the TX FIFO.
Some of the AT command settings to consider is the number of data bytes in the RX FIFO before the data is packetized and sent and the time out to send data in the FIFO after no new data is received. The defaults for these should work fine but its good to check what these settings are and read the XBee document on all the AT commands.
The devices connected to the XBee’s serial line also need to buffer data in and out. On you PC the OS and the terminal program does buffing of data both ways. For a micro-processor (Adrino, PIC, etc) the code should setup the UART as Interrupt driven with a ring buffer (which is how the serial port in a PC is setup).
Now data should pass in both directions. I’ve done this the send/receive data to a PIC processor on a robot form/to a PC.
One hint: Do a direct connection (with a RS232 chip) between the processor and the PC to test and debug the code. Once that is working correctly then insert the XBees to make a wireless link. This removes any XBee issues from the code and comm link.
I’m using micro-processor PIC16F876A to connect my remote xbee, and a Sparkfun USB dongle to connect my base xbee to the computer.
This is the code (based on C language) I’m currently implementing on the processor:
#include <16F876A.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES WRT_50% //Lower half of Program Memory is Write Protected
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#define putc putchar
#int_RDA
char dato;
RDA_isr()
{
dato=getc();
set_pwm1_duty(dato);
}
void main()
{
int16 x=300;
int16 y=6000;
char a;
char b;
char c;
char d;
unsigned char e=-120;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_1,255,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);
// TODO: USER CODE!!
while(true){
a=make8(x,1);
b=make8(x,0);
c=make8(y,1);
d=make8(y,0);
putchar(e);
putchar(a);
putchar(b);
putchar(c);
putchar(d);
}
}
But so far it hasn’t work. I don’t really know which part is going wrong.
waltr:
This should be working if the XBee’s are properly setup in Transparent mode.
Then its up the the XBee’s configuration (AT settings) and firmware to group together the data in the TX FIFO and send it as an RF packet. Same with receiving an RF packet, the XBee will decode the RF packet and put the data into the TX FIFO.
This is my configuration for the xbees, the other parameters are set as default:
BASE
ATID 3456
ATMY 1
ATDL 2
ATWR
REMOTE
ATID 3456
ATMY 2
ATDL 1
ATWR
waltr:
I’ve done this the send/receive data to a PIC processor on a robot form/to a PC.
Could you help me sending me an example just like the one you worked with your robot, it will be greatly appreciated.
Ok, since you are using a PIC (I used the 16F873 on my Bot) read and study the Microchip App Note AN774. This has the Interrupt driven, ring buffer UART code I used (also download the example code). It is in assembler but it is not hard to understand and port to C.
Which C compiler are you using? CCS or MikroC?
I do not use those, I use an older HiTech C for 16F and 18F PICs.
But looking through your code I do not see any UART initialization so I don’t see how the UART could be working.
For help with the code check into a forum for the compiler you are using (or maybe someone here know this compiler).
And Again… Get the PIC’s serial (UART) connected to your PC before even thinking about connecting the XBees. You really want and to the issues with the PIC code worked out bee having to deal with any XBee setup and issues.
Since you have the Sparkfun USB dongle the PIC’s UART pins can directly connect to get the serial between the PIC and PC working.