Zigbee to PIC18F252

Forum for problems or queries regarding Flowcode Comms Components. Eg LIN, I2C, SPI, RS232, CAN, IrDA etc

Moderators: Benj, Mods

Post Reply
Johan Gagiano
Posts: 7
Joined: Mon Jun 11, 2007 10:58 am
Location: South Africa
Contact:

Zigbee to PIC18F252

Post by Johan Gagiano »

Hello

I have the following setup:
PIC18F252
Zigbee Module
LCD 16x2 Module
Flowcode V3.6.11.53

Problem is as follow:
I have originally wrought the program for the PIC16F88, and it worked 100%.
Now I have changed to the PIC18F252 with higher pin count and altered the software for the later PIC. The problem is that the PIC18F252 stop at the point where the Zigbee Init_Network macro is called. I have checked the communication between the module and the PIC and it looks fine. I have rewritten the software for the PIC18F252 but the problem persists. I have scaled down the software to find the problem, to no avail.
Is it possible that the Zigbee component is malfunction?
If I select the verbose option on the Zigbee module setup, it does display. I have worked through the Zigbee Teachers Course Notes and still can not find the problem.
Help please!!

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Zigbee to PIC18F252

Post by Benj »

Hello

Does anything appear on the LCD when your in verbose mode or is it simply left blank? If you get some data then please can you post it here as this may help.

Also check that the pins are defined correctly in the component connections window and that the E-Block hardware is configured correctly to allow said connections.

Johan Gagiano
Posts: 7
Joined: Mon Jun 11, 2007 10:58 am
Location: South Africa
Contact:

Re: Zigbee to PIC18F252

Post by Johan Gagiano »

Hello Ben

Yes, there is some data that is displayed on the LCD.
On start-up there is a short message that state my current “attempt” on the right hand side of a 16x2 LCD. After 5 seconds the LCD clears and data is displayed on the left hand side (not in the software).
It looks like AT parameters with values. This parameters will cycle through, 5 -10 seconds apart.
ATGT 28, ATATD6 1, ATD7 1, ATRO 0, ATEE 0, ATID FFFF, ATNI Devic, ATSP 7D0

I am not using the Zigbee E-Block, instead I have the PIC18F252 and the Zigbee module on one pcb. I have the Zigbee module set-up with Digi’s X-CTU software.
The PIC16F88 works fine with this setup.

Johan

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Zigbee to PIC18F252

Post by Benj »

Hello Johan,

Right thats ok you should be receiving the words OK on the second line of the LCD. If you are not getting this then it is likely that the module cannot get into the AT command mode and is therefore not replying to commands. The command mode is activated by using specific guard times and sending three + characters. You may need to adjust the guard times using the X-CTU software to allow the Xbee to go into AT mode.

Here is the piece of code responsible for the guard time.

Code: Select all

	Wdt_Delay_Ms(200);					//Fixed delay before sending command
	Send_Char('+');						//Send characters to enter command mode
	Send_Char('+');
	Send_Char('+');
	Wdt_Delay_Ms(50);					//Fixed delay before sending command
	Get_AT_Response(0);					//Collect Response
If you change the guard time to 50ms then hopefully this will allow the device to work correctly.

Let me know how you get on.

Johan Gagiano
Posts: 7
Joined: Mon Jun 11, 2007 10:58 am
Location: South Africa
Contact:

Re: Zigbee to PIC18F252

Post by Johan Gagiano »

Hello Ben

I have checked the guard time and change it from 40ms to 50ms. Still not solving the problem in both the coordinator and the router node. I have tried another approach, and turned of the verbose and start scanning for network including signal strength value. After 5min the node return the signal value and conformation on connecting with coordinator.
My hardware consist now of a dip switch selecting the PIC18F252 or RS232. Funny thing is that the modem configuration tab in X-CTU work perfect and it will enter the AT command mode, but not in the terminal tab. I have bought 12 modules and found that 3 of them do not enter the AT command mode via the X-CTU software. One of the modules does not want to be update with the newer version software. I presume that my hardware and software setup is correct and that the problem might be on Digi’s side. My previous attempts with PIC16F88 went very smooth.
Thanks for the help, anyway!
Johan

Johan Gagiano
Posts: 7
Joined: Mon Jun 11, 2007 10:58 am
Location: South Africa
Contact:

Re: Zigbee to PIC18F252

Post by Johan Gagiano »

Hello Ben

I have gone trough all the possibilities causing my problems. But I have not yet resolved it. The piece of code you have pasted is for Flowcode 4 and not 3. I have the latest update, Flowcode 3.6.11.53. The previous code that I have written for the PIC18F252 where not made by this version of Flowcode. I have update sins and do not remember what the previous version. Any way I have compare the V3 and V4 code for the Zigbee module and all I can find is the difference in timers used or added. Now if configure the PIC18F252 with watchdog bit enabled, and the watchdog press caller to 1:2. The code will stop function when it call the LCD Int. command.
Any help?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Zigbee to PIC18F252

Post by Benj »

Hello,

Does the Zigbee code work ok with the watchdog turned off?

In v4 we have implemented a software delay that allows the watchdog timer to automatically be cleared during long delays such as the delay used by the LCD initialisation macro. If you really need to enable watchdog in your program then I recommend upgrading to v4 as it will save you a lot of fiddling about adding watchdog clear commands.

Johan Gagiano
Posts: 7
Joined: Mon Jun 11, 2007 10:58 am
Location: South Africa
Contact:

Re: Zigbee to PIC18F252

Post by Johan Gagiano »

Hello Ben

Yes I do need the watchdog timer, but there are some other possibilities as well.
I think that the solution to the problem might be to upgrade as Fowcode save me a lot of time in coding.
Johan

Johan Gagiano
Posts: 7
Joined: Mon Jun 11, 2007 10:58 am
Location: South Africa
Contact:

Re: Zigbee to PIC18F252

Post by Johan Gagiano »

Hello Ben

I have upgraded to V4. I had to wait 27days for delivery. Not Matrix’s problem, but with service in my country, anything be possible!
OK here is it. I have run my test again and still have not solved my problem. If it is possible can you send me the Zigbee parameters?
You said I have to change the guard time to 50ms. What I have seen so far is that the Zigbee module does receive the parameters from the pic. If I check the modules parameters, specifically the ATGT it will change to 0x28, no matter what it were set via X-CTU software. I have seen in the Zigbee Component Code, (initiate low speed command mode) that the guard time is set for 40ms (0x28). This override my settings via X-CTU.

Johan

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Zigbee to PIC18F252

Post by Benj »

Hello Johan,

The guard time is current hard coded by Flowcode. You can adjust this by editing the Zigbee component C file in V3 of Flowcode or by using the code customisation feature of V4.

Basically the line of code you are looking for is included in the Init_Network function.

Send_AT_Command("ATGT 28",7); //Set to guard time to 40ms

Post Reply