PIC18F4520 with xbee (need help pls!!)

Off-topic Or Otherwise...Say/Ask It Here
Dratsaboy
Newbie Pyro
Posts: 3
Joined: Wed Aug 10, 2011 1:07 am

PIC18F4520 with xbee (need help pls!!)

Postby Dratsaboy » Wed Aug 10, 2011 6:05 am

I am doing a project that requires (Pic with Xbee) to (Xbee with Pic) wireless serial communication and i lack the knowledge of programming the pic with the codes about how to make the transmitter pic talking with the receiver pic... i am running out of time and i really hope that you could help me with the codes... i m using PIC18F4520 and my xbee is XB24-Z7WIT-004... I really appreciate if you could teach me about the codes steps by steps or any valauble information that can help me in learning to program the codes...

ThePyroElectro
PyroElectro Admin
Posts: 1181
Joined: Mon Nov 12, 2007 9:24 pm
Location: Earth
Contact:

Postby ThePyroElectro » Wed Aug 10, 2011 5:20 pm

Hi Dratsaboy,

Did you already look through my Xbee Tutorial:
http://www.pyroelectro.com/tutorials/xbee_wireless_interface/

I suggest using the PIC18LF452 or PIC18LF4520. The LF version can operate at 3.3v which the Xbee modules use. The PIC18F4520 cannot run off of 3.3v so you would need to use two power supplies: +5v and +3.3v.

The Xbee module should be transparent. Set your USART transmit and receive to 9600 Baud, connect power, ground and DIN // DOUT on your two Xbee modules, then you're ready to go.

Dratsaboy
Newbie Pyro
Posts: 3
Joined: Wed Aug 10, 2011 1:07 am

Postby Dratsaboy » Thu Aug 11, 2011 4:26 am

Hi PyroElectro

I have seen the link and i understand about the 3.3v logic but can i use the PIC18F4520(+5v) together with the Xbee(+3.3v regulated breakout board)?

sorri i cant post any link yet but i will post it when i can.

The breakout board has a inbuilt regulator and it accepts +5v input.

The name of the breakout board is XBee Explorer Regulated and i think this is its serial number sku: WRL-09132.]

The XBee Explorer Regulated takes care of the 3.3V regulation, signal conditioning, and basic activity indicators (Power, RSSI and DIN/DOUT activity LEDs). It translates the 5V signals to 3.3V so that you can connect a 5V (down to 3.3V) system to any XBee module. (This is taken from sparkfun website.)

ThePyroElectro
PyroElectro Admin
Posts: 1181
Joined: Mon Nov 12, 2007 9:24 pm
Location: Earth
Contact:

Postby ThePyroElectro » Fri Aug 12, 2011 1:20 am

Hello,

If the module takes care of the power concern then you should only need to connect that +5v, ground and then Din/Dout.

From that point you could follow the tutorial I wrote, just be sure to set the PIC USART to 9600 baud Tx/Rx, because that is the standard speed those Xbee modules are set to initially.

Dratsaboy
Newbie Pyro
Posts: 3
Joined: Wed Aug 10, 2011 1:07 am

Postby Dratsaboy » Fri Aug 12, 2011 2:12 am

I have configured my xbee to 9600 baud rate and its dh and dl on X-CTU already... one of the xbee is in at coordinator mode and the other is in router mode... i have tried my xbee with my aduino and it is working in a doorbell project but i just cant make ur project work...

And i found some things in the tx codes that is weird...

if(PORTAbits.RD0 == 1 &&
PORTAbits.RD1 == 1){
//Turn LED ON
putcUSART( '0' ); //write value of PORTA
Delay10KTCYx(10);
putcUSART( 'L' ); //write value of PORTA
Delay10KTCYx(10);

PORTAbits.RD0... it sld be PORTAbits.RA0 am i right?

i did everything as in ur project except that i change the pic and add a 3.3v regulated breakout board to my xbee... but still it didn't work...

//PORTC Bit 6 Is TX (PIN 25)
TRISCbits.TRISC6 = 0;
//PORTC Bit 6 Is RX (PIN 26)
TRISCbits.TRISC7 = 1;

i check my PIC18F4520 concise data book and i understood that
PORTCbits.RC6 is the Tx and PORTCbits.RC7 is the Rx so can the
codes be written as

TRISC=0b01111111;

ThePyroElectro
PyroElectro Admin
Posts: 1181
Joined: Mon Nov 12, 2007 9:24 pm
Location: Earth
Contact:

Postby ThePyroElectro » Fri Aug 12, 2011 3:31 am

Yea, that is strange,

Should be:

Code: Select all

PORTAbits.RA0
PORTAbits.RA1


I updated my code to fix that.

From The Data Sheet:

Code: Select all

-> bit TRISC<6> must be cleared (= 0), and
-> bit TRISC<7> must be set (=1)


This is wrong: TRISC=0b01111111;

So either way you have is correct. You shouldn't have to change anything on the Xbee modules, as they come standard set at 9600 baud to transmit using Din/Dout, so I'm not sure if you reconfigured something incorrectly on the Xbee's.

Here are the troubleshooting steps I would take:
[1] Make sure the USART outputs something, connect DMM or Oscilloscope to PIC Tx. Is the USART transmitting when you turn the system on?
[2] If nothing is output from Tx, check configuation bits (crystal configuration XT/HS?..etc) and re-program the PIC
[3] If output is transmitting, connect the Transmitter and Receiver directly using a wire. PIC#1 Tx -> PIC#2 Rx. If the system works when you press the buttons, now it's time to connect the PICs to the Xbee modules.
[4] Connect Rx (RC7) to Dout and Tx (RC6) to Din. Give the Xbee Power and Ground and you should see output at the receiver (use DMM or Oscilloscope to check Xbee receiver Dout).

These steps should help you to identify where the problem is.


Return to “Put'm Here”

Who is online

Users browsing this forum: No registered users and 1 guest