(Help)Xbee series 1 point to point communication

Bluetooth, XBee, RF......

(Help)Xbee series 1 point to point communication

Postby Chuen88 » Mon Jul 30, 2012 5:55 pm

Im working on a project require Xbee communication module. Here is my configuration setting:

1) Xbee starter kit series 1(connect to PC) using X-CTU software provided :
- Channel = C
- PAN ID = 3456
- MY(Source) address = 11
- DL(Destination) address = 22


2) Xbee series 1(Connect to microcontroller PIC18F4550) :
- Data Out(Xbee) connect to RC7(RX) Port C of PIC18F4550
- Data In(Xbee) connect to RC6(TX) Port C of PIC18F4550
- Channel = C
- PAN ID = 3456
- MY(Source) address = 22
- DL (Destination) address = 11

Im using the sample Visual Basic GUI project from the link http://tutorial.cytron.com.my/2011/07/30/gui-control-flexibot-by-using-skxbee-wireless-communicate/ (Xbee starter kit connected to PC) and try to receive the data sent from the Xbee connected to PIC18F4550. Im doing in this way, give external power supply after programmed the PIC18F4550 repeat sending the data using forever loop. For example: while(1){uart_str("1234");}. So that, on the other side (Xbee starter kit connected to PC) will receive the data. Am i doing in the correct way? But, i cant receive any data on the Xbee starter kit connected to PC using the sample Visual Basic GUI program as mentioned above. Of course, i have modified some visual basic coding inside. For example, read the com port and display the data on the message box if the button is clicked. Besides, i have also measure the voltage on the PortC RC7 (RX) and RC6 (TX) from the PIC18F4550. I can see the voltage varying and keep changing from 3.0V~4.95V for RC6(TX) and 0.10~0.15V for RC7(RX). Is it normal? Please do let me know if i have done any mistakes. Thanks.
Chuen88
Freshie
 
Posts: 4
Joined: Mon Jul 30, 2012 5:38 pm

Re: (Help)Xbee series 1 point to point communication

Postby robosang » Mon Jul 30, 2012 8:43 pm

Show us the hardware, wiring connection.... :mrgreen:
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: (Help)Xbee series 1 point to point communication

Postby Chuen88 » Mon Jul 30, 2012 10:04 pm

I have attached the circuit diagram and this is my coding in C for PIC18F4550:
CODE: SELECT_ALL_CODE
#include <p18f4550.h>
#include <delays.h>
#include <usart.h>

#pragma config FOSC = INTOSC_HS //Internal Oscillator
#pragma config WDT = OFF //turn off watchdog timer

/*global variables*/
unsigned int rec_data,a;

//UART Zigbee

void uart_init(void)
{
   OSCCON = 0x62;//4 MHz

   SPBRG = 25; //4MHz set baud rate as 9600 baud or 129 for 20Mhz
   TXSTAbits.BRGH=1; //baud rate high speed option
   TXSTAbits.TXEN=1; //enable transmission
   TXSTAbits.TX9 =0; //8-bit transmission

   RCSTAbits.RX9 =0; //8-bit reception
   RCSTAbits.CREN=1; //enable reception
   RCSTAbits.SPEN=1; //enable serial port
   
}

unsigned char uart_rec(void) //receive uart value
{
   unsigned int rec_data;
   while(PIR1bits.RCIF==0); //wait for data
      rec_data = RCREG;
   return rec_data; //return the data received
}
 
void uart_send(unsigned char data)
{
   while(PIR1bits.TXIF==0); //only send the new data after
      TXREG=data; //the previous data finish sent
}
   
void uart_str(const char *s)
{
   while(*s)
      uart_send(*s++); // UART sending string
}

void xbee_init(void)
{
   OSCCON = 0x62;//4 MHz
   uart_str("+++");//send command to enter XBee command mode
   Delay10KTCYx(200);//2000ms
   //delay_ms(200);// waiting for finish sending and XBee respond

   uart_str("atchC"); //channel
   uart_send(0xD);// 0XD is hexa code of &quot;Enter&quot;key
   Delay10KTCYx(20);//200ms

   uart_str("atwr");// send &quot;WR&quot; (write)command to SKXBee
   uart_send(0xD);//0XD is hexa code of &quot;Enter&quot;key
   Delay10KTCYx(20);//200ms
   //delay_ms(200);

   uart_str("atid3456"); //PAN ID
   uart_send(0xD);// 0XD is hexa code of &quot;Enter&quot;key
   Delay10KTCYx(20);//200ms

   uart_str("atwr");// send &quot;WR&quot; (write)command to SKXBee
   uart_send(0xD);//0XD is hexa code of &quot;Enter&quot;key
   Delay10KTCYx(20);//200ms
   //delay_ms(200);
   
   uart_str("atmy22");//send command to setting Source address
   uart_send(0xD);// 0XD is hexa code of &quot;Enter&quot;key
   Delay10KTCYx(20);//200ms
   //delay_ms(200);
   
   uart_str("atwr");// send &quot;WR&quot; (write)command to SKXBee
   uart_send(0xD);//0XD is hexa code of &quot;Enter&quot;key
   Delay10KTCYx(20);//200ms
   //delay_ms(200);
   
   uart_str("atdl11");// send command to setting Destination address
   uart_send(0xD);//0XD is hexa code of &quot;Enter&quot;key
   Delay10KTCYx(20);//200ms
   //delay_ms(200);
   
   uart_str("atwr");//send &quot;WR&quot; (write)command to SKXBee
   uart_send(0xD);//0XD is hexa code of &quot;Enter&quot;key
   Delay10KTCYx(20);//200ms
   //delay_ms(200);
   
   uart_str("atcn");// send command for Exit AT Command Mode
   uart_send(0xD);//0XD is hexa code of &quot;Enter&quot;key
   Delay10KTCYx(20);//200ms
   //delay_ms(200);
}
void main(void)
{
   OSCCON = 0x62;//4MHz
   TRISC = 0b10000000;                  //configure PORTC I/O direction
   uart_init();
   xbee_init();
   while(1)
   {
      
      uart_str("1234");
      Delay10KTCYx(20);//200ms
      uart_send(123);
      Delay10KTCYx(20);//200ms
   }
}

Have a look.Thanks! :D
Attachments
xbee module.jpg
Circuit diagram
Chuen88
Freshie
 
Posts: 4
Joined: Mon Jul 30, 2012 5:38 pm

Re: (Help)Xbee series 1 point to point communication

Postby robosang » Tue Jul 31, 2012 4:40 pm

Well, I am hoping to see the actual hardware connection. You never know what you will get :mrgreen:

OK, my way will be to verify the XBee pair-up wireless communication first, using computer. If they are working fine, I check the communication of the PIC to computer, then only I combine PIC, Xbee and computer.
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: (Help)Xbee series 1 point to point communication

Postby yonghui » Wed Aug 01, 2012 11:22 am

u can verify the signal from the controller using the uc00A or ucooB from cytron. xbee is working on 3.3V. not so sure your controller is working on that voltage. i guess it will shorter the life span if u operate 5v on the 3.3v pin of the xbee.
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: (Help)Xbee series 1 point to point communication

Postby Chuen88 » Fri Aug 03, 2012 3:10 am

yonghui WROTE:u can verify the signal from the controller using the uc00A or ucooB from cytron. xbee is working on 3.3V. not so sure your controller is working on that voltage. i guess it will shorter the life span if u operate 5v on the 3.3v pin of the xbee.

How to verify the signal from the controller using the uc00A or ucooB from cytron??sorry. im newbie for xbee devices.... :)
Chuen88
Freshie
 
Posts: 4
Joined: Mon Jul 30, 2012 5:38 pm

Re: (Help)Xbee series 1 point to point communication

Postby robosang » Mon Aug 06, 2012 8:46 pm

check out the tutorial by Cytron, I guess they might have some on that :mrgreen:
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: (Help)Xbee series 1 point to point communication

Postby Chuen88 » Wed Aug 08, 2012 11:02 am

robosang WROTE:check out the tutorial by Cytron, I guess they might have some on that :mrgreen:

Ok..Thanks!

Btw, i have solved my problem. It is because the Xbee module (not SKXbee) unable enter to the AT Command mode through PIC. So, i have modified my C coding by adding the delay 6s before and after the "+++" command is sent to the UART of the PIC. After that, send again the command "<cr>"(carriage return). At this time, the xbee module is successfully in the AT command mode. Lastly, change the AT parameter(dl,my,PANID,channel) accordingly by sending the command to the UART again. Somehow, it is worked for me! :lol:

Thanks to those ppl who reply on this topic..Appreciate your help! :D
Chuen88
Freshie
 
Posts: 4
Joined: Mon Jul 30, 2012 5:38 pm

Re: (Help)Xbee series 1 point to point communication

Postby robosang » Thu Aug 16, 2012 7:40 am

Good to hear that, but why don you configure all the setting needed using computer and connect to microcontroller?
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm


Return to Wireless Device

Who is online

Users browsing this forum: No registered users and 22 guests

cron