Arduino + Cytron G15 shield + Dynamixel AX12 Servo

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

Arduino + Cytron G15 shield + Dynamixel AX12 Servo

Postby Jim » Fri Mar 07, 2014 5:38 pm

I am trying to move the dynamixel ax12a servo motor by using arduino and the cytron G15 shield. The descriptions in the cytron G15 shield stated that it is compatible with the dynamixel ax12 servos but when i tried to move the servo by using all the tutorials, library and example, it doesnt work. I am currently using Arduino UNO, G15 shield and Dynamixel AX12A servo motor. Kindly provide some advise as it will be greatly appreciated. Thank You.
Jim
Freshie
 
Posts: 4
Joined: Fri Mar 07, 2014 5:31 pm

Re: Arduino + Cytron G15 shield + Dynamixel AX12 Servo

Postby yonghui » Sat Mar 08, 2014 8:13 pm

Hi Jim,
Can u show us the code and also the photo of hardware setup?
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: Arduino + Cytron G15 shield + Dynamixel AX12 Servo

Postby Jim » Sat Mar 08, 2014 8:52 pm

The coding and hardware setup is exactly the same as shown under the description/link of the cytron G15 shield product page.
the following are the codings:
CODE: SELECT_ALL_CODE
#include <G15.h>    // include the library
#define LED_BOARD 13


/*Return Error definitions & Mask
=====Higher 8 bits of Word=========
packet length error :       0x0100
packet header error:        0x0200
ID mismatch error:          0x0400
packet checksum mismatch :  0x0800
====Lower 8 bits of word==========
Error status return by G15:
INST         0x0040      
OVERLOAD      0x0020
CHECKSUM      0x0010
RANGE         0x0008
OVERHEAT      0x0004
ANGLELIMIT            0x0002
VOLTAGE              0x0001
*/


//declaration of variables & object
word ERROR=0;
byte DATA[10];
word STATUS;

//declare G15 Class Object
//servo1 ID=1
AX12 servo1(1);
//servo2 ID=2
AX12 servo2(2);


void setup(){
 
//initialize the arduino main board's serial/UART and Control Pins
  G15ShieldInit(19200,3,8);
 
//call the init function to init servo obj
  servo1.init();           
  servo2.init();

//init LED indicator as output
  pinMode(LED_BOARD,OUTPUT); 
  digitalWrite(LED_BOARD, LOW);
 
  delay(500);
  digitalWrite(LED_BOARD, HIGH);
 
}
void loop(){
   
    servo1.SetLED(ON,iWRITE_DATA);
   
    servo1.SetSpeed(500,iWRITE_DATA);
    servo1.SetPos(ConvertAngle2Pos(0),iWRITE_DATA);    //goto 0 degree pos
   
    delay(1000);
     
    servo1.SetPos(ConvertAngle2Pos(90),iWRITE_DATA);   //goto 90 degree pos
    servo1.SetSpeed(250,iWRITE_DATA);
   
     servo1.SetLED(OFF,iWRITE_DATA);
   
    delay(1000);
   
    servo2.SetLED(ON,iWRITE_DATA);
   
    servo2.SetSpeed(250,iWRITE_DATA);
    servo2.SetPos(ConvertAngle2Pos(0),iWRITE_DATA);     //goto 0 degree pos
   
    delay(1000);
   
    servo2.SetSpeed(500,iWRITE_DATA);
    servo2.SetPos(ConvertAngle2Pos(90),iWRITE_DATA);   //goto 90 degree pos
   
    servo2.SetLED(OFF,iWRITE_DATA);
    delay(1000);
   

}


Image


I have checked the pin connection to tally with the coding of G15shieldInit(),
I have checked the id no of the individual dynamixel servos,
even if i tried to change the id using the code provided, it is not successful,
Thank you for the help and it is much appreciated.
Jim
Freshie
 
Posts: 4
Joined: Fri Mar 07, 2014 5:31 pm

Re: Arduino + Cytron G15 shield + Dynamixel AX12 Servo

Postby yonghui » Mon Mar 10, 2014 9:36 am

Hi Jim,
sorry i dint reply during weekend,

looking at your code, i see one significant thing,

if u had looked at dynamixels servo user manual, the default baudrate for the servo should be 1MBPS?

the code used 19200, which is default baudrate for G15 servo, this code is not suitable for dynamixel's.
u can try to change the baudrate.
the arduino library by cytron is using official Arduino serial library, which im not sure it can support 1MBPs for receiving the response from the servo, but i think sending out command should be no problem. try it 1st.
mayb u can try to change the servo baudrate to a lower baudrate of 19200bps 1st and try again the other code.
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: Arduino + Cytron G15 shield + Dynamixel AX12 Servo

Postby Jim » Mon Mar 10, 2014 5:47 pm

Thank you for the reply.
Now i am able to move the dynamixel ax12a servo motor already.
However, there is some command such as RotateCW, RotateCCW and SetTorqueOnOff could not be used. Not sure whether is it related to the status return since i do not know how to check it. Not all commands have been tested.
Is there any way to change the directions of the dynamixel ax12a servos? because currently both of my motors are rotating in a different rotation.
Thank you for all the help as it is much appreciated.
Jim
Freshie
 
Posts: 4
Joined: Fri Mar 07, 2014 5:31 pm

Re: Arduino + Cytron G15 shield + Dynamixel AX12 Servo

Postby yonghui » Tue Mar 11, 2014 10:33 am

Hi Jim,

for the rotateCW or CCW which related to 360 degree rotation, most probably cytron's arduino library cant support for dynamixels servo. the protocol of 360 rotation for G15 servo and AX12 are different in this case. u will probably need to open out the library and do some modifications to the packet sent for the rotate function. refer to ax12 user manual for the packet format and data need to be sent.
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: Arduino + Cytron G15 shield + Dynamixel AX12 Servo

Postby Jim » Tue Mar 11, 2014 7:01 pm

Okay, thanks for all the help. You are such a kind person. Have a great day.
Jim
Freshie
 
Posts: 4
Joined: Fri Mar 07, 2014 5:31 pm


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 18 guests