G´day everyone.
I´ve been working on this project and it´s about generating data and sending it through xbee´s. The purpose is to use one as coordinator and multiple end devices (which leads me to API mode). Basically those end devices will be collecting data from a PIC18f25k20 and sending it to the coordinator (which is attached to a USB Adapter on my PC), the data will be manipulated using labview, and the coordinator will be sending some data back to the end devices.
Here are some details:
Xbee Pro Serie 2 - Model - xbeepro2
Modem type - XBP24-B
Firmware version 21A7.
Right now, I´m working with 2 xbee´s and trying to send data between them. The data is followed:
From Coord 2 EndD - 7E 00 13 10 01 00 13 A2 00 40 8D 5A 8B FF FE 00 00 48 65 6C 6C 6F 96
From EndD 2 Coord - 7E 00 13 10 01 00 00 00 00 00 00 00 00 FF FE 00 00 48 65 6C 6C 6F FD
It works just fine when I put both on the PC USB Adapter and use XCTU. However, when I try to communicate one xbee in usb(coord) with one connected to a pic(end device) I find one trouble. I can´t get the data, which is sent from coord, from the xbee end device to my microcontroller. On the terminal XCTU, I get the followed answer:
7E 00 07 8B 01 FC C3 00 00 40 74 - which tells me that the data was succesfully delivered.
I think it’s a code problem, however it could be anything else since I’m a begginer at this stage
Raw Code :
#include <18F25K20.h>
#device adc =10
#device ICD=TRUE
#FUSES noWDT // Watch Dog Timer
#fuses LP //low power crystal
#FUSES XT //Crystal osc <= 4mhz
#fuses BROWNOUT_SW //Brownout enabled during operation, disabled during SLEEP
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //brownout reset
#FUSES BORV27 //Brownout reset at 2.7V
#FUSES NOPUT //Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES noDEBUG //No Debug mode for ICD
#FUSES noLVP //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES noIESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOPBADEN //PORTB pins are configured as analog input channels on RESET
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES LPT1OSC //Timer1 configured for low-power operation
#FUSES MCLR //Master Clear pin enabled
#FUSES XINST //Extended set extension and Indexed Addressing mode enabled*/
#use delay(clock = 4000000) /* Definição do CLOCK */
#use rs232(BAUD = 9600, XMIT = PIN_C6, RCV = PIN_C7) /* Comunicação entre o PIC e o Zigbee */
int16 var;
byte var2=0x00;
long timeout;
void main() {
output_low(PIN_C5); // Turning on Xbee
delay_ms(10);
while(1) {
delay_ms(100);
output_high(PIN_C0);
delay_ms(100);
output_low(PIN_C0);
timeout=0;
while(!kbhit()&&(++timeout<5000)) delay_us(5);
if(kbhit()){
output_high(PIN_C0);
delay_ms(10);
output_low(PIN_C0);
delay_ms(10);
output_high(PIN_C0);
delay_ms(10);
output_low(PIN_C0);
delay_ms(10);
output_high(PIN_C0);
delay_ms(10);
output_low(PIN_C0);
var2 = getc();
delay_ms(1000);
}
/* Data which is succesfully sent from end-device to coord
putc(0x7E);
putc(0x00);
putc(0x13);
putc(0x10);
putc(0x01);
putc(0x00);
putc(0x00);
putc(0x00);
putc(0x00);
putc(0x00);
putc(0x00);
putc(0x00);
putc(0x00);
putc(0xFF);
putc(0xFE);
putc(0x00);
putc(0x00);
putc(0x48);
putc(0x65);
putc(0x6C);
putc(0x6C);
putc(0x6F);
putc(0xFD);*/
}
}
As I said, it’s a raw code. What I was trying to see is a blinking LED (PIN_C0) with 100 ms, and I would see a faster blinking if any charecter is received. However it doesn’t work as I planned and I have no clue why.
If somebody could help me, I’d appreciate a lot!
Cheers,
PS.: Sry for any english mistakes