Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

ZigBee Broadcasting Mode and Packet Format

Bioloid robot kit from Korean company Robotis; CM5 controller block, AX12 servos..
7 postsPage 1 of 1
7 postsPage 1 of 1

ZigBee Broadcasting Mode and Packet Format

Post by bergere » Wed Jun 04, 2008 10:48 am

Post by bergere
Wed Jun 04, 2008 10:48 am

Hello again,

I have installed a ZigBee Module on my CM-5 and have some Zig2Serial on my PC.
Now i want to send Data from Zig2Serial to my CM-5 first.

The Zig2Serial is connected via J10 with 5V Power and is set to Broadcasting mode via Robot Terminal (Status LED is On all the time ==> Everthing is OK).

Because i can not use Robot Terminal to send Data over Zig2Serial to my CM-5 i wrote a little programm. That works fine when i use normal Serial connection (I changed my CM-5 file to Zig Rx).

OK know the real Question. How can i set the Broadcasting status in the Zig100 in the CM-5. I know it´s easy with Behavior Controll Programmer but which Register i have to set when I´m programming with C?
Somebody have some c example for doing this?

Just for Information My Frame Format is: FF 55 data ndata data2 ndata2

Code: Select all

unsigned char output[6];
output[0]=0xff;
output[1]=0x55;
output[2]=0x01;
output[3]=0xfe;
output[4]=0x01;
output[5]=0xfe;



I hope somebody can help me
Hello again,

I have installed a ZigBee Module on my CM-5 and have some Zig2Serial on my PC.
Now i want to send Data from Zig2Serial to my CM-5 first.

The Zig2Serial is connected via J10 with 5V Power and is set to Broadcasting mode via Robot Terminal (Status LED is On all the time ==> Everthing is OK).

Because i can not use Robot Terminal to send Data over Zig2Serial to my CM-5 i wrote a little programm. That works fine when i use normal Serial connection (I changed my CM-5 file to Zig Rx).

OK know the real Question. How can i set the Broadcasting status in the Zig100 in the CM-5. I know it´s easy with Behavior Controll Programmer but which Register i have to set when I´m programming with C?
Somebody have some c example for doing this?

Just for Information My Frame Format is: FF 55 data ndata data2 ndata2

Code: Select all

unsigned char output[6];
output[0]=0xff;
output[1]=0x55;
output[2]=0x01;
output[3]=0xfe;
output[4]=0x01;
output[5]=0xfe;



I hope somebody can help me
Für Fehler und Schrift haftet der Stift. Palim Palim
bergere
Savvy Roboteer
Savvy Roboteer
Posts: 28
Joined: Thu Nov 29, 2007 10:18 pm

Post by StuartL » Wed Jun 04, 2008 2:56 pm

Post 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);
    }
}
StuartL
Savvy Roboteer
Savvy Roboteer
Posts: 350
Joined: Mon Jun 04, 2007 3:46 pm
Location: Thatcham, Berkshire, UK

Post by JavaRN » Thu Jun 05, 2008 3:28 pm

Post by JavaRN
Thu Jun 05, 2008 3:28 pm

Excuse my ignorance but I've just started programming the cm-5 in c this week and managed to make the motors go in both directions, and read their position (taking code from there and then). Communication with zigbee was my second step (I already did it successfully but using the behaviour control programming). I assume that you have to tie this to some timer interrupt. Can anyone show me how to do this (go slow I am a newbie in microcontrollers). Thanks
Excuse my ignorance but I've just started programming the cm-5 in c this week and managed to make the motors go in both directions, and read their position (taking code from there and then). Communication with zigbee was my second step (I already did it successfully but using the behaviour control programming). I assume that you have to tie this to some timer interrupt. Can anyone show me how to do this (go slow I am a newbie in microcontrollers). Thanks
F'dan il-passatemp ghandek bzonn zewg affarijiet - FLUS u HIN. Zewg affarijiet li huma skarsi hafna u li jien minnhom ghandi vera ftit!
JavaRN
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 282
Joined: Fri Mar 02, 2007 11:01 pm

Post by JavaRN » Thu Jun 05, 2008 3:50 pm

Post by JavaRN
Thu Jun 05, 2008 3:50 pm

I found a temporary solution for this, I've included the code in the main() method and it seems to have worked, of course the check is done once at the beginning of the program so if I want to check whether the link is connected or not I have to reset the program, not a big deal. Thanks StuartL for your code.
I found a temporary solution for this, I've included the code in the main() method and it seems to have worked, of course the check is done once at the beginning of the program so if I want to check whether the link is connected or not I have to reset the program, not a big deal. Thanks StuartL for your code.
F'dan il-passatemp ghandek bzonn zewg affarijiet - FLUS u HIN. Zewg affarijiet li huma skarsi hafna u li jien minnhom ghandi vera ftit!
JavaRN
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 282
Joined: Fri Mar 02, 2007 11:01 pm

Post by StuartL » Fri Jun 06, 2008 4:44 pm

Post by StuartL
Fri Jun 06, 2008 4:44 pm

JavaRN wrote:I found a temporary solution for this, I've included the code in the main() method and it seems to have worked, of course the check is done once at the beginning of the program so if I want to check whether the link is connected or not I have to reset the program, not a big deal. Thanks StuartL for your code.


I'll get some timer code pasted on here at some point, but in the mean time just put it in the main loop of your code, perhaps check it once every thirty iterations with something like:

Code: Select all
{
    int count = 30;
    /* ... */
    while (1) { // Main loop
        /* ... stuff and things ... */
        if (!(--count)) {
            count = 30;
            uart_ticktock();
        }
    }
}
JavaRN wrote:I found a temporary solution for this, I've included the code in the main() method and it seems to have worked, of course the check is done once at the beginning of the program so if I want to check whether the link is connected or not I have to reset the program, not a big deal. Thanks StuartL for your code.


I'll get some timer code pasted on here at some point, but in the mean time just put it in the main loop of your code, perhaps check it once every thirty iterations with something like:

Code: Select all
{
    int count = 30;
    /* ... */
    while (1) { // Main loop
        /* ... stuff and things ... */
        if (!(--count)) {
            count = 30;
            uart_ticktock();
        }
    }
}
StuartL
Savvy Roboteer
Savvy Roboteer
Posts: 350
Joined: Mon Jun 04, 2007 3:46 pm
Location: Thatcham, Berkshire, UK

Post by JavaRN » Fri Jun 06, 2008 10:21 pm

Post by JavaRN
Fri Jun 06, 2008 10:21 pm

Thanks again StuartL. Programming is something which I really like (I've been doing it for the past 14 years in various languages), but my programming was always for the PC - Java, Delphi, C# and VB are the languages I know most. Programming for microcontrollers is something new for me, and something which I am really enjoying, but I need time to get used to it. If you know of any good programming tutorial on the web for the Atmel microcontroller, please let me know.
Thanks again StuartL. Programming is something which I really like (I've been doing it for the past 14 years in various languages), but my programming was always for the PC - Java, Delphi, C# and VB are the languages I know most. Programming for microcontrollers is something new for me, and something which I am really enjoying, but I need time to get used to it. If you know of any good programming tutorial on the web for the Atmel microcontroller, please let me know.
F'dan il-passatemp ghandek bzonn zewg affarijiet - FLUS u HIN. Zewg affarijiet li huma skarsi hafna u li jien minnhom ghandi vera ftit!
JavaRN
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 282
Joined: Fri Mar 02, 2007 11:01 pm

Post by lrice648 » Fri Oct 29, 2010 6:09 pm

Post by lrice648
Fri Oct 29, 2010 6:09 pm

I know this thread is really old but I'm working using the zig100 wireless for a bioloid using the libbioloid libraries.

Is the code in this thread related? Can anyone offer any suggestions on how to get started? I have the zig's paired and have used them in the bhc program, but I'm not sure how to get started communicating in C. I've read through the libbioloid source a fair bit but I have no examples on how to get started with the wireless specifically.

If anyone can help I would be grateful.

Luke
I know this thread is really old but I'm working using the zig100 wireless for a bioloid using the libbioloid libraries.

Is the code in this thread related? Can anyone offer any suggestions on how to get started? I have the zig's paired and have used them in the bhc program, but I'm not sure how to get started communicating in C. I've read through the libbioloid source a fair bit but I have no examples on how to get started with the wireless specifically.

If anyone can help I would be grateful.

Luke
lrice648
Robot Builder
Robot Builder
Posts: 7
Joined: Thu Apr 15, 2010 11:25 pm


7 postsPage 1 of 1
7 postsPage 1 of 1