by StuartL » Wed Jun 04, 2008 2:56 pm
by StuartL
Wed Jun 04, 2008 2:56 pm
Ok, there are a lot of dependencies to getting the Zigbee modules working properly. You've completed the first dependency by ensuring that it works over serial.
Problem 1: Pairing the Zigbee modules.
The Zigbees have to be paired. The way they are shipped from Robotis is that they are paired, which is good. If you tinker with the settings at all (e.g. enabling broadcast support) they will no longer be paired and will no longer talk to each other. The communication is connection-oriented so both seem to have to be configured with the other's ID for it to work at all.
If you have unpaired the Zigbee modules then you'll need to reconfigure them to be paired with each other. This is documented in the Zigbee PDF and is relatively easy to do, but you may need to unsolder the one in the CM5 (or write some software to dynamically reconfigure it).
Problem 2: Selecting the Zigbee module.
This doesn't affect the CM5 transmitting data but it DOES affect the CM-5 receiving data.
This is my CM-5 code to toggle the Zigbee/serial transmission, it happens every tenth of a second. It checks to see if the serial cable is inserted. If it's inserted it enables the serial port (PD5 high, PD6 low), if it's not inserted it enables the zigbee (PD5 low, PD6 high). Do NOT put both PD5 and PD6 high at the same time.
Also be sure that port D's DDR (data direction register) is set correctly.
- Code: Select all
/* header file */
#define BIT_ZIGBEE_LED PD1
#define BIT_ZIGBEE_RESET PD4 //out : default 1 //PORTD
#define BIT_ENABLE_RXD_LINK_PC PD5 //out : default 1
#define BIT_ENABLE_RXD_LINK_ZIGBEE PD6 //out : default 0
#define BIT_LINK_PLUGIN PD7 //in, no pull up
/* elsewhere */
{
/* Inefficient but only done once and very readable */
DDRD = 0;
sbi(DDRD, BIT_ZIGBEE_RESET);
sbi(DDRD, BIT_ENABLE_RXD_LINK_PC);
sbi(DDRD, BIT_ENABLE_RXD_LINK_ZIGBEE);
sbi(PORTD, BIT_ZIGBEE_RESET);
sbi(PORTD, BIT_ENABLE_RXD_LINK_PC);
sbi(PORTD, BIT_LINK_PLUGIN);
/* ... */
}
/* routinely check serial cable */
static void uart_ticktock(void) {
if (bit_is_set(PIND, BIT_LINK_PLUGIN)) { // Serial cable inserted
cbi(PORTD, BIT_ENABLE_RXD_LINK_ZIGBEE);
sbi(PORTD, BIT_ENABLE_RXD_LINK_PC);
} else {
cbi(PORTD, BIT_ENABLE_RXD_LINK_PC);
sbi(PORTD, BIT_ENABLE_RXD_LINK_ZIGBEE);
}
}
Ok, there are a lot of dependencies to getting the Zigbee modules working properly. You've completed the first dependency by ensuring that it works over serial.
Problem 1: Pairing the Zigbee modules.
The Zigbees have to be paired. The way they are shipped from Robotis is that they are paired, which is good. If you tinker with the settings at all (e.g. enabling broadcast support) they will no longer be paired and will no longer talk to each other. The communication is connection-oriented so both seem to have to be configured with the other's ID for it to work at all.
If you have unpaired the Zigbee modules then you'll need to reconfigure them to be paired with each other. This is documented in the Zigbee PDF and is relatively easy to do, but you may need to unsolder the one in the CM5 (or write some software to dynamically reconfigure it).
Problem 2: Selecting the Zigbee module.
This doesn't affect the CM5 transmitting data but it DOES affect the CM-5 receiving data.
This is my CM-5 code to toggle the Zigbee/serial transmission, it happens every tenth of a second. It checks to see if the serial cable is inserted. If it's inserted it enables the serial port (PD5 high, PD6 low), if it's not inserted it enables the zigbee (PD5 low, PD6 high). Do NOT put both PD5 and PD6 high at the same time.
Also be sure that port D's DDR (data direction register) is set correctly.
- Code: Select all
/* header file */
#define BIT_ZIGBEE_LED PD1
#define BIT_ZIGBEE_RESET PD4 //out : default 1 //PORTD
#define BIT_ENABLE_RXD_LINK_PC PD5 //out : default 1
#define BIT_ENABLE_RXD_LINK_ZIGBEE PD6 //out : default 0
#define BIT_LINK_PLUGIN PD7 //in, no pull up
/* elsewhere */
{
/* Inefficient but only done once and very readable */
DDRD = 0;
sbi(DDRD, BIT_ZIGBEE_RESET);
sbi(DDRD, BIT_ENABLE_RXD_LINK_PC);
sbi(DDRD, BIT_ENABLE_RXD_LINK_ZIGBEE);
sbi(PORTD, BIT_ZIGBEE_RESET);
sbi(PORTD, BIT_ENABLE_RXD_LINK_PC);
sbi(PORTD, BIT_LINK_PLUGIN);
/* ... */
}
/* routinely check serial cable */
static void uart_ticktock(void) {
if (bit_is_set(PIND, BIT_LINK_PLUGIN)) { // Serial cable inserted
cbi(PORTD, BIT_ENABLE_RXD_LINK_ZIGBEE);
sbi(PORTD, BIT_ENABLE_RXD_LINK_PC);
} else {
cbi(PORTD, BIT_ENABLE_RXD_LINK_PC);
sbi(PORTD, BIT_ENABLE_RXD_LINK_ZIGBEE);
}
}