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

Bioloid - Programming with CM510 USB2Dynamixel and Zigbee

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

Bioloid - Programming with CM510 USB2Dynamixel and Zigbee

Post by balo » Thu Mar 15, 2012 3:44 pm

Post by balo
Thu Mar 15, 2012 3:44 pm

Hello,

I'm beginning in robotic. I'm sorry for my english but I speak french.

I have a bioloid premium kit type A and I will make a program in C++ for controlling them with my computer. I have a USB2Dynamixel with Zig2Serial and Zig 100 and Zig 110 in the robot. When I use the serial cable and roboPlus I have no problem but when I change the serial cable for Zig2serial, RoboPlus did'nt work. I have read that if i will use Zig2Serial, I must do my program. I read the documentation and I check the code given by Robotis and i didn't understood how communicate with my robot.

Have you an simple example code in C++ for communicate with a robot via a computer in wireless ?

Thank's
Balo
Hello,

I'm beginning in robotic. I'm sorry for my english but I speak french.

I have a bioloid premium kit type A and I will make a program in C++ for controlling them with my computer. I have a USB2Dynamixel with Zig2Serial and Zig 100 and Zig 110 in the robot. When I use the serial cable and roboPlus I have no problem but when I change the serial cable for Zig2serial, RoboPlus did'nt work. I have read that if i will use Zig2Serial, I must do my program. I read the documentation and I check the code given by Robotis and i didn't understood how communicate with my robot.

Have you an simple example code in C++ for communicate with a robot via a computer in wireless ?

Thank's
Balo
balo
Robot Builder
Robot Builder
Posts: 11
Joined: Thu Mar 15, 2012 3:11 pm

Post by siempre.aprendiendo » Thu Mar 15, 2012 6:21 pm

Post by siempre.aprendiendo
Thu Mar 15, 2012 6:21 pm

Hi and welcome, Balo

I used bluetooth and a bluetooth to serial converter for CM-5/CM-510, you can see it here (the battery and the BT<->serial are on the "neck"). Later I get a Zig2Serial and the same code worked ok using Zig110.

Writing your own program in the PC (or any other computer) you can use Zig2Serial+ZIG-100/110, sending the Dynamixel hexadecimal commands to the serial port. Using the standard firmware with the Toss Mode (57600) or with this firmware (57600 or 115200) that offers commands to read sensor values.

You can find several simple examples sending commands to serial port in C# and C++ at www.softwaresouls.com
Hi and welcome, Balo

I used bluetooth and a bluetooth to serial converter for CM-5/CM-510, you can see it here (the battery and the BT<->serial are on the "neck"). Later I get a Zig2Serial and the same code worked ok using Zig110.

Writing your own program in the PC (or any other computer) you can use Zig2Serial+ZIG-100/110, sending the Dynamixel hexadecimal commands to the serial port. Using the standard firmware with the Toss Mode (57600) or with this firmware (57600 or 115200) that offers commands to read sensor values.

You can find several simple examples sending commands to serial port in C# and C++ at www.softwaresouls.com
siempre.aprendiendo
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 559
Joined: Wed Aug 08, 2007 9:13 pm
Location: Barcelona

Post by Compadre » Sat Mar 17, 2012 8:35 am

Post by Compadre
Sat Mar 17, 2012 8:35 am

The topic of wireless control of bioloid via cm-510 is hot.

If the same code runs with blutu and with zigbee then the problem is more of a algoritmic issue where one of the questions is which kind of codes are to be sent.

Hopping to work more on this with some students and my self in the near future.
The topic of wireless control of bioloid via cm-510 is hot.

If the same code runs with blutu and with zigbee then the problem is more of a algoritmic issue where one of the questions is which kind of codes are to be sent.

Hopping to work more on this with some students and my self in the near future.
Compadre
Robot Builder
Robot Builder
Posts: 10
Joined: Fri Jul 22, 2011 3:58 am

Post by balo » Wed Mar 21, 2012 2:39 pm

Post by balo
Wed Mar 21, 2012 2:39 pm

Thank's to your answers.

I have check exemples at www.softwaresouls.com but I have some problem. I have copy th SerialPort class but I have bug, it must include some library ?
It's possible to give me the class Dynamixel.cpp? Some methode is not in the website and I must it for following my code.
Thank's to your answers.

I have check exemples at www.softwaresouls.com but I have some problem. I have copy th SerialPort class but I have bug, it must include some library ?
It's possible to give me the class Dynamixel.cpp? Some methode is not in the website and I must it for following my code.
balo
Robot Builder
Robot Builder
Posts: 11
Joined: Thu Mar 15, 2012 3:11 pm

Post by balo » Thu Mar 22, 2012 2:49 pm

Post by balo
Thu Mar 22, 2012 2:49 pm

Hi,

I have find bugs of SerialPort in including
Code: Select all
#include <cstdlib>
#include <windows>
#include <iostream>


I have change the argument in connect fonction. Argument is now "char *" because the "CreateFile" didn't accept the "wchar_t *".

I have some problem for 2 methodes use in the exemple code
Code: Select all
toHexHLConversion(goal, &hexH, &hexL);
checkSumatory(buffer, pos);


Something can me explain this methode or give me this methode sending with "WriteFile"?

If I use the default Firmware can I communicate with this packet "OXFF 0XFF ID LENGTH INSTRUCTION PARAMETER1 …PARAMETER N CHECK SUM" ?
Hi,

I have find bugs of SerialPort in including
Code: Select all
#include <cstdlib>
#include <windows>
#include <iostream>


I have change the argument in connect fonction. Argument is now "char *" because the "CreateFile" didn't accept the "wchar_t *".

I have some problem for 2 methodes use in the exemple code
Code: Select all
toHexHLConversion(goal, &hexH, &hexL);
checkSumatory(buffer, pos);


Something can me explain this methode or give me this methode sending with "WriteFile"?

If I use the default Firmware can I communicate with this packet "OXFF 0XFF ID LENGTH INSTRUCTION PARAMETER1 …PARAMETER N CHECK SUM" ?
balo
Robot Builder
Robot Builder
Posts: 11
Joined: Thu Mar 15, 2012 3:11 pm

Post by siempre.aprendiendo » Thu Mar 22, 2012 6:32 pm

Post by siempre.aprendiendo
Thu Mar 22, 2012 6:32 pm

Well, it's not really a bug, in this post I didn't include a complete example, only the main sources.

If you can wait until the weekend I will upload the full example zipped, else I think that you can get these functions from the Linux example (this is a complete example).
Well, it's not really a bug, in this post I didn't include a complete example, only the main sources.

If you can wait until the weekend I will upload the full example zipped, else I think that you can get these functions from the Linux example (this is a complete example).
siempre.aprendiendo
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 559
Joined: Wed Aug 08, 2007 9:13 pm
Location: Barcelona

Post by balo » Fri Mar 23, 2012 2:38 pm

Post by balo
Fri Mar 23, 2012 2:38 pm

If you can upload your zip that it will help me.

I have see the linux code but I don't understood because the communication system is not the same
If you can upload your zip that it will help me.

I have see the linux code but I don't understood because the communication system is not the same
balo
Robot Builder
Robot Builder
Posts: 11
Joined: Thu Mar 15, 2012 3:11 pm

Post by siempre.aprendiendo » Fri Mar 23, 2012 8:07 pm

Post by siempre.aprendiendo
Fri Mar 23, 2012 8:07 pm

Here you have. I hope this helps you :)

Keep in mind that it's a an example that only pretends to be easy, clear and simple. It uses the COM1 and AX-12 ID=15, you can change it in the code.
Here you have. I hope this helps you :)

Keep in mind that it's a an example that only pretends to be easy, clear and simple. It uses the COM1 and AX-12 ID=15, you can change it in the code.
Last edited by siempre.aprendiendo on Sat Mar 24, 2012 6:43 pm, edited 1 time in total.
siempre.aprendiendo
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 559
Joined: Wed Aug 08, 2007 9:13 pm
Location: Barcelona

Post by balo » Sat Mar 24, 2012 3:56 pm

Post by balo
Sat Mar 24, 2012 3:56 pm

Thank's. He move :D

If I want to read the information of motor, I must change de firmware to this or with de default firmware that was possible ?
Thank's. He move :D

If I want to read the information of motor, I must change de firmware to this or with de default firmware that was possible ?
balo
Robot Builder
Robot Builder
Posts: 11
Joined: Thu Mar 15, 2012 3:11 pm

Post by siempre.aprendiendo » Sat Mar 24, 2012 5:19 pm

Post by siempre.aprendiendo
Sat Mar 24, 2012 5:19 pm

You don't need to change the firmware to read the Dynamixel attributes. This other firmware is mainly to read the sensors connected to the CM-510 ports.

Before moving the servo the program reads the AX-12 position.

Code: Select all
      int pos=dynamixel.getPosition(&serialPort, idAX12);

      if (pos>250 && pos <1023)
         dynamixel.setPosition(&serialPort, idAX12, pos-100);
      else
         printf ("\nPosition [%i] under 250 or over 1023", pos);


Look in Dynamixel.cpp for the source code.
You don't need to change the firmware to read the Dynamixel attributes. This other firmware is mainly to read the sensors connected to the CM-510 ports.

Before moving the servo the program reads the AX-12 position.

Code: Select all
      int pos=dynamixel.getPosition(&serialPort, idAX12);

      if (pos>250 && pos <1023)
         dynamixel.setPosition(&serialPort, idAX12, pos-100);
      else
         printf ("\nPosition [%i] under 250 or over 1023", pos);


Look in Dynamixel.cpp for the source code.
siempre.aprendiendo
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 559
Joined: Wed Aug 08, 2007 9:13 pm
Location: Barcelona

Post by balo » Sat Mar 24, 2012 5:59 pm

Post by balo
Sat Mar 24, 2012 5:59 pm

if I want to read Gyro Sensor for exemple, I need an other firmware ?
if I want to read Gyro Sensor for exemple, I need an other firmware ?
balo
Robot Builder
Robot Builder
Posts: 11
Joined: Thu Mar 15, 2012 3:11 pm

Post by Compadre » Sat Mar 24, 2012 10:06 pm

Post by Compadre
Sat Mar 24, 2012 10:06 pm

ok

I now read more slowly and I understood that this sis only sendin commands to Dynamixel and Back to PC using zigbee instead of serail cable.

The thing is that zigbee sends only one byte at each time. I will continue checking this interesting topic and making test
ok

I now read more slowly and I understood that this sis only sendin commands to Dynamixel and Back to PC using zigbee instead of serail cable.

The thing is that zigbee sends only one byte at each time. I will continue checking this interesting topic and making test
Compadre
Robot Builder
Robot Builder
Posts: 10
Joined: Fri Jul 22, 2011 3:58 am

Post by balo » Tue Mar 27, 2012 2:03 am

Post by balo
Tue Mar 27, 2012 2:03 am

If I have correctly understood, if I want to read values of sensors in my robot, I must change the Firmware.

I have 2 questions :
- With this firmware can I use the same code of default firmware for the motor ?

- Can I take again the default firmware when I change them ?
If I have correctly understood, if I want to read values of sensors in my robot, I must change the Firmware.

I have 2 questions :
- With this firmware can I use the same code of default firmware for the motor ?

- Can I take again the default firmware when I change them ?
balo
Robot Builder
Robot Builder
Posts: 11
Joined: Thu Mar 15, 2012 3:11 pm

Post by siempre.aprendiendo » Tue Mar 27, 2012 6:37 pm

Post by siempre.aprendiendo
Tue Mar 27, 2012 6:37 pm

Yes.

That firmware basically sends to the Dynamixel bus whatever it receives from the serial bus. And sends back to the serial bus any data it receives from the Dynamixel bus.

It supports queries to the CM-510 ports (this is the reason I developed it), for example, a C# call:

Code: Select all
private static int getSensorValueCommand(byte[] buffer, byte function, byte port)
        {
            int pos = 0;
            buffer[pos++] = 0xff;   // header
            buffer[pos++] = 0xff;   // header
            buffer[pos++] = idCM510;   // CM510 ID=200
            buffer[pos++] = 0x04;   // length
            buffer[pos++] = 0x02;   // instruction 2 = read
            buffer[pos++] = function;    // function = 1, read one port value
            buffer[pos++] = port;    // port
            byte checksum = Util.checkSumatory(buffer, pos);
            buffer[pos++] = checksum;
 
            return pos;
        }
Yes.

That firmware basically sends to the Dynamixel bus whatever it receives from the serial bus. And sends back to the serial bus any data it receives from the Dynamixel bus.

It supports queries to the CM-510 ports (this is the reason I developed it), for example, a C# call:

Code: Select all
private static int getSensorValueCommand(byte[] buffer, byte function, byte port)
        {
            int pos = 0;
            buffer[pos++] = 0xff;   // header
            buffer[pos++] = 0xff;   // header
            buffer[pos++] = idCM510;   // CM510 ID=200
            buffer[pos++] = 0x04;   // length
            buffer[pos++] = 0x02;   // instruction 2 = read
            buffer[pos++] = function;    // function = 1, read one port value
            buffer[pos++] = port;    // port
            byte checksum = Util.checkSumatory(buffer, pos);
            buffer[pos++] = checksum;
 
            return pos;
        }
siempre.aprendiendo
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 559
Joined: Wed Aug 08, 2007 9:13 pm
Location: Barcelona

Post by balo » Thu Mar 29, 2012 1:57 pm

Post by balo
Thu Mar 29, 2012 1:57 pm

I have succes install the firmware. The code for change values of AX-12 run again.

But I don't read sensor values. If I have correctlly understand, I must change the mode in tossMode to PortMode. But I didn't know how change this...

I have try this
Code: Select all
int MotorAx12::PortMode(Serial *serialPort)
{
    // Open Toss Mode
    byte _InitBuffer[15];
    _InitBuffer[0] = 't';
    _InitBuffer[1] = '\n';
    _InitBuffer[2] = 1; //??? because TossMode this value is 0

    int _N = serialPort->SendArray(_InitBuffer, 2);
    Sleep(200);

    serialPort->Clear();
    Sleep(5);

    return _N;
}


And for read values of sensor, I have tryed this :
Code: Select all
int MotorAx12::GetSensorValue(Serial *serialPort, int port)
{
    int ret = 0;

    int n = GetSensorValueCommand(port);
    serialPort->SendArray(buffer,n);
    Sleep(waitTime);

    memset(bufferIn,0,BufferSize);
    n = serialPort->GetArray(bufferIn, 8);

    short _Position = -1;
    if (n > 7) _Position = FromHexHLConversion(bufferIn[5], bufferIn[6]);

    printf("\nid=[i] position=[i] length=[i]\n", port, _Position, n);
    if (_Position<0> 1023)
    {
        ret =- 2;
    }
    else{
        ret = _Position;
    }
    return ret;
}
int MotorAx12::GetSensorValueCommand( byte port)
{
    int pos = 0;
    buffer[pos++] = 0xff;   // header
    buffer[pos++] = 0xff;   // header
    buffer[pos++] = 200;   // CM510 ID=200
    buffer[pos++] = 0x04;   // length
    buffer[pos++] = 0x02;   // instruction 2 = read
    buffer[pos++] = 1;    // function = 1
    buffer[pos++] = port;    // port
    byte checksum = CheckSumatory(buffer, pos);
    buffer[pos++] = checksum;
 
    return pos;
}


This code don't function :(

Can you explain to me what is the value in buffer "function" because I didn't know ??

Can you give me, the list of different port use in CM510 ?

Thank's a lot for your help !
I have succes install the firmware. The code for change values of AX-12 run again.

But I don't read sensor values. If I have correctlly understand, I must change the mode in tossMode to PortMode. But I didn't know how change this...

I have try this
Code: Select all
int MotorAx12::PortMode(Serial *serialPort)
{
    // Open Toss Mode
    byte _InitBuffer[15];
    _InitBuffer[0] = 't';
    _InitBuffer[1] = '\n';
    _InitBuffer[2] = 1; //??? because TossMode this value is 0

    int _N = serialPort->SendArray(_InitBuffer, 2);
    Sleep(200);

    serialPort->Clear();
    Sleep(5);

    return _N;
}


And for read values of sensor, I have tryed this :
Code: Select all
int MotorAx12::GetSensorValue(Serial *serialPort, int port)
{
    int ret = 0;

    int n = GetSensorValueCommand(port);
    serialPort->SendArray(buffer,n);
    Sleep(waitTime);

    memset(bufferIn,0,BufferSize);
    n = serialPort->GetArray(bufferIn, 8);

    short _Position = -1;
    if (n > 7) _Position = FromHexHLConversion(bufferIn[5], bufferIn[6]);

    printf("\nid=[i] position=[i] length=[i]\n", port, _Position, n);
    if (_Position<0> 1023)
    {
        ret =- 2;
    }
    else{
        ret = _Position;
    }
    return ret;
}
int MotorAx12::GetSensorValueCommand( byte port)
{
    int pos = 0;
    buffer[pos++] = 0xff;   // header
    buffer[pos++] = 0xff;   // header
    buffer[pos++] = 200;   // CM510 ID=200
    buffer[pos++] = 0x04;   // length
    buffer[pos++] = 0x02;   // instruction 2 = read
    buffer[pos++] = 1;    // function = 1
    buffer[pos++] = port;    // port
    byte checksum = CheckSumatory(buffer, pos);
    buffer[pos++] = checksum;
 
    return pos;
}


This code don't function :(

Can you explain to me what is the value in buffer "function" because I didn't know ??

Can you give me, the list of different port use in CM510 ?

Thank's a lot for your help !
balo
Robot Builder
Robot Builder
Posts: 11
Joined: Thu Mar 15, 2012 3:11 pm

Next
23 postsPage 1 of 21, 2
23 postsPage 1 of 21, 2