	*** OLIMEX demo project for the MOD-ZIGBEE ***

1. Requirements
	- At least 2 MOD-ZIGBEE demo boards by Olimex
	- RS232 level converter or adapter board (ex. MOD-USB-RS232 by Olimex)
	- Compatible debugger, for example PICkit3 or ICD2
	- MPLAB IDE by Microchip with installed MPLAB C18 Compiler 
	- Terminal program (Hyper Terminal, PuTTY, etc.)
	- Power source - CR2032 lithium battery or external source
	
2. Description
	This sample project demonstrates the functionality of the onboard processor, the radio transceiver and the thermometer. The demo is built upon the following Microchip's freely distributed support libraries:
	- Microchip MiWi Development Environment version 3.1

	The demo defines 2 types of devices: Coordinator and End Devices. According to Microchip MiWi specifications the MiWi network requires one Coordinator and one or many End Devices. The demo consists of separate projects for the Coordinator (called 'Coordinator') and End Devices (called 'EndDevice'). 
	
	Upon startup the Coordinator forms a network with PAN ID 0x1234 on the channel with the least amount of noise, LED1 is lit and the program starts waiting for client devices to connect. Status messages are printed over UART and can be displayed on a terminal program on a PC (please see next chapter). The Coordinator is configured to accept connections from up to 10 devices. The Coordinator accepts connections from any device that requests joining but will only recognise messages about name and temperature of end devices using the other part of the demo. Received and recognised messages are printed on the terminal and LED2 toggles at any successful reception. Here is a sample terminal log from the operation of a Coordinator:
	
-----------------------------------------------------------------------------------------

Input Configuration:
           Button 1: RB5
           Button 2: RB4
Output Configuration:
                     RS232 port
              LED 1: RA0
              LED 2: RA1
     RF Transceiver: MRF24J40
   Demo Instruction:
                     Power on the board until LED 1 lights up
                     to indicate it is ready to establish new
                     connections. Push Button 1 to perform
                     frequency agility procedure. Push Button
                     2 to unicast encrypted message. LED 2 will
                     be toggled upon receiving messages.


Feature MiWi DemMRF24J40 Node 1
Starting Active Scan...
Scan Channel 11
Scan Channel 12
Scan Channel 13
Scan Channel 14
Scan Channel 15
Scan Channel 16
Scan Channel 17
Scan Channel 18
Scan Channel 19
Scan Channel 20
Scan Channel 21
Scan Channel 22
Scan Channel 23
Scan Channel 24
Scan Channel 25
Scan Channel 26
Active Scanning Energy Scanning
Energy Scan Results:
Channel 11: -------------- 48
Channel 12: ------------- 41
Channel 13: ----------------- 58
Channel 14: ------------------ 5E
Channel 15: ----------------------- 76
Channel 16: -------------------- 67
Channel 17: ------------------------------ 9A
Channel 18: ---------------------- 72
Channel 19: ------------------------------------- BC
Channel 20: -------------------------------- A0
Channel 21: ------------------------------------------------ F0
Channel 22: -------------------------------------------------- FA
Channel 23: -------------------------------------------------- FB
Channel 24: ---------------------------------------------- E8
Channel 25: --------------------------------------- C4
Channel 26: ------------------------------------- BC
Start Wireless Communication on Channel 12
Start Connection on Channel 12
From 0081, RSSI B4, NAME: DEFAULT NAME 000
From 0081, RSSI BC, TEMPR: 24.0625oC
From 0081, RSSI C3, TEMPR: 24.0000oC
From 0081, RSSI C1, TEMPR: 24.0000oC

-----------------------------------------------------------------------------------------
	
	Upon startup an End Device starts searching for a network with PAN ID 0x1234 on any available channel. If such a network is not found then the device enters deep sleep mode and reattempts connecting after some time. When a suitable network is found (formed by the Coordinator) the device joins it and sends to the Coordinator its specific name and measured temperature. Then it enters deep sleep mode and sends its measured temperature again after some time. The sleep may be prematurely terminated by a press of any of the two buttons (not the RESET button!).
	If the Coordinator disappears for some reason the end device enters startup state again.
	
*Note: With the introduction of MOD-LCD1x9 and MOD-ZIGBEE rev.B you have the ability to make an assembly between the two and have status messages and current temperature value displayed on the LCD, even when deep sleeping. To enable this feature of the End Device demo just uncomment "USING_MOD_LCD1x9" in 'main.c'.
		
3. How to setup Coordinator to print messages:
	The easiest configuration is to have available MOD-ZIGBEE rev.B board and a MOD-USB-RS232 board. Then you will just have to configure MOD-USB-RS232 in host mode (TX on pin 3 of the UEXT, RX on pin 4) plug one into the other and that is all.
	
	In any other case you will have to manually connect pins RC6 (TX as seen from the MCU), and RC7 (RX as seen from the MCU) and GND of the MOD-ZIGBEE board to the respective pins of the level converter.

4. How to use this demo
	The board ships with demo firmware for the End Device preinstalled which has the same functionality as in this project at time of manufacture (maybe there is an update to the demo when you read this).
	
	To download the firmware to the board you need some sort of programmer/debugger compatible with the PIC18F26K20 processor.
	
	The fastest possible way to get things running is to download the precompiled hex file to the processor memory. The file needed for the Coordinator is called "Coordinator_Thermometer.hex" and for end devices it is "EndDevice_Thermometer.hex". Import this file in MPLAB and select processor PIC18F26K20.

	IMPORTANT NOTE:
		Due to specifications of MiWi and the lack of unique hardware address in the radio chips of devices, programming more than one device with the same hex file will result in identical and indistinguishable devices. Such devices will get same addresses from the Coordinator and behave the same way. I order to deal with this situation without having to recompile between programming of many devices a special tool is included in this demo package called "SerializatorDotNET.exe". The tool works only with PicKit3 and gives you the ability to change MAC address and name of end devices prior to programming them. You should provide a precompiled hex file compiled with symbol "OUTPUT_FOR_SERIALIZATOR_PROGRAM" defined (see top of 'main.c').
	
	An alternative is to open the workspace (\Coordinator.mcw or \EndDevice.mcw) in MPLAB, compile it and then debug the application. This	sample workspace may also be your starting point in developing new applications using the board.
	
	Build info:
		MPLAB IDE v8.63
		MPLAB C18 v3.34
		Microchip MiWi Development Environment version 3.1
		
	Debugger used:
		PICKit3 by Microchip

5. Further reading
	User's manual for the MOD-ZIGBEE board. Also feel free to consult all documents released by Microchip regarding their MiWi DE support and related PIC18 support documents and application notes.

6. Support
	http://www.microchip.com/
	http://www.olimex.com/dev/
	
Last edit
	17 Feb 2011
