Go Down

Topic: Using Dynamixel AX-12A with Arduino (Read 2566 times) previous topic - next topic

basesim

Hello,

I want to know if it is possible to use Dynamixel AX-12A actuators (http://www.crustcrawler.com/motors/AX12/index.php) with Arduino. In my project, I'm using 2 normal servos and 2 AX-12A. I have no problem with the normal servos, but I have serious issues with my AX-12A. I'm trying to send information packet to my AX-12A with a virtual serial communication ( with SoftwareSerial), but it doesn't work.

I want the commands that I send from my computer (through the usb cable) to be sent to my normal servos or to my AX-12A through my SofwareSerial port. For the AX-12A communication buffer, I'm using this : http://www.robotshop.com/productinfo.aspx?pc=RB-Dfr-142&lang=fr-CA

Finaly, this is my code :
Code: [Select]
#include <Servo.h>
#include <SoftwareSerial.h>

int incomingChar = 0;
int pos1 = 90;
int pos2 = 90;
int i=0;

Servo grip1;
Servo grip2;

SoftwareSerial axSerial(13,8);
void axSerialWrite(int id);

void setup()
{                

 grip1.attach(7);
 grip1.write(pos1);
 grip2.attach(2);
 grip2.write(pos2);
 
 Serial.begin(9600);
 axSerial.begin(57600);
 
 //Set the speed on all AX-12A
 axSerial.print(0xFF,HEX);
 axSerial.print(0xFF,HEX);
 axSerial.print(0xEF,HEX);
 axSerial.print(0x04,HEX);
 axSerial.print(0x03,HEX);
 axSerial.print(0x20,HEX);
 axSerial.print(0x00,HEX);
 axSerial.print(0xE9,HEX);
}

void loop()
{
 if (Serial.available() > 0)
 {
   incomingChar = Serial.read();
 }
 switch(incomingChar)
 {
 case 'g':
   grip1.write(52);
   pos1=50;
   break;
 case 'h':
   grip1.write(130);
   pos1=172;
   break;
 case 'i':
   grip2.write(49);
   pos2=55;
   break;
 case 'j':
   grip2.write(135);
   pos2=95;
   break;
  case 'w':
   delay(5000);
   for(i=pos1;i>=135;i-=3)
   {
     grip1.write(i);
     pos1=i;
     delay(100);
   }
   delay(5000);
   for(i=pos1;i>=95;i-=3)
   {
     grip1.write(i);
     pos1=i;
     delay(100);
   }
   break;
 case 'x':
   grip1.write(172);
   pos1=172;
   break;
 case 'y':
   delay(5000);
   for(i=pos2;i>=155;i-=3)
   {
     grip2.write(i);
     pos2=i;
     delay(100);
   }
   delay(5000);
   for(i=pos2;i>=95;i-=3)
   {
     grip2.write(i);
     pos2=i;
     delay(100);
   }
   break;
 case 'z':
   grip2.write(179);
   pos2=179;
   break;
   //====================Commands for AX-12A========================
 case 'a':
   axSerialWrite(2);
   axSerial.print(0x2B8,HEX);
   axSerial.print(0x20,HEX);
   break;  
 case 'b':
   axSerialWrite(2);
   axSerial.print(0x18D,HEX);
   axSerial.print(0x4B,HEX);
   break;
 case 'c':
   axSerialWrite(2);
   axSerial.print(0x55,HEX);
   axSerial.print(0x83,HEX);
   break;
 case 'k':
   axSerialWrite(2);
   axSerial.print(0x3EF,HEX);
   axSerial.print(0xE9,HEX);
   break;
 case 'd':
   axSerialWrite(4);
   axSerial.print(0x58,HEX);
   axSerial.print(0x7E,HEX);
   break;
 case 'e':
   axSerialWrite(4);
   axSerial.print(0x3EE,HEX);  
   axSerial.print(0xE8,HEX);
   break;
 case 'f':
   axSerialWrite(4);
   axSerial.print(0x2BD,HEX);
   axSerial.print(0x19,HEX);
   break;
 case 'l':
   axSerialWrite(4);
   axSerial.print(0x18B,HEX);
   axSerial.print(0x4B,HEX);
   break;  
 default:
   break;
 }
}

void axSerialWrite(int id)
{
 axSerial.print(0xFF,HEX);
 axSerial.print(0xFF,HEX);
 if(id==2)
   axSerial.print(0x02,HEX);
 else
   axSerial.print(0x04,HEX);
 axSerial.print(0x04,HEX);
 axSerial.print(0x03,HEX);
 axSerial.print(0x1E,HEX);
}


LuisGIII

Hello!
I think that I can help you with your problem. There is a new board called CM-900 is from ROBOTIS (Bioloid, Darwin-OP) and they are giving this board for beta-testing you just need to pay the shipment to your place!
Enter to this forum:

http://www.robotsource.org/xe/Circle_CM9_Developer_World

Create an account and ask for one! you only need to explain one of your projects and they will send it to you :)
Hope it helps! it's a good option for Ax and Rx/Mx Dynamixel series.

Go Up