General

Using Smart Servo Shield for AX-12A in servo mode

userHead tedkurtz 2015-07-22 05:23:29 15466 Views18 Replies
I am trying to use the Smart Servo Shield with an Arduino Uno to drive AX-12A servos in servo mode. I have copied the software for testing the shield from the DFROBOT web site and am using it without modification. Here is that code:
Code: Select all
/*
/*
# This Sample code is for testing the Digital Servo Shield.

# Editor : YouYou
# Date : 2014.10.24
# Ver : 1.0
# Product: Digital Servo Shield for Arduino
# SKU :

# Hardwares:
1. Arduino UNO
2. Digital Servo Shield for Arduino
3. Digital Servos( Compatible with AX-12,CDS55xx...etc)
4. Power supply:6.5 - 12V

*/

#include <SPI.h>
#include <ServoCds55.h>
ServoCds55 myservo;

void setup (void)
{
Serial.begin (115200);
myservo.begin ();
}

void loop (void)
{

if(Serial.available()){
char val = Serial.read();
if(val != -1)
{
switch(val)
{
case 'p':
myservo.write(1,300);//ID:1 Pos:300 velocity:150
delay(3000);
myservo.write(1,0);//ID:1 Pos:0 velocity:150
break;

case 'v':
myservo.setVelocity(100);// set velocity to 100(range:0-300) in Servo mode
break;

case 'm':
myservo.rotate(1,150);// CCW ID:1 Velocity: 150 middle velocity 300 max
delay(2000);
myservo.rotate(1,-150);// CW ID:1 Velocity: -150 middle velocity -300 max
break;

// case 'i':
// myservo.SetID(1,2);//ID:1 newID:2
// break;
//
// case 'r':
// myservo.Reset(2);//Restore ID2 servo to factory Settings ( ID:1 Baud rate:1000000)
// break;

}
}
else
Serial.println("Wait");
delay(500);

}

}


I am using that code without modification..

Using the character 'p' causes the servo to rotate CCW endlessly.

Using the character 'm' causes the servo to rotate CCW for a few seconds and then to rotate CW endlessly.

I need to use the servos in servo mode; i.e. I want them to turn to specific positions and then hold that position. Can anyone tell me how to do that?

Thank you.

Ted
2015-07-28 04:46:29 Hello,

The second link was not a mistake. It is a link to John Wakefield's blog, an entry for 2014 where he shows how to control the position of an AX-12A servo using a CDS55xx Driver Board. I have used his method successfully.

I'm afraid that I have concluded that your board cannot be used to control the position of an AX-12A servo.

I am going to use a CDS55xx Driver Board with a 6-Port AX MX Power Hub. I have just realized that I can in that way drive the number of servos I want in my project. By the way, the CDS55xx board is no longer in production, but I fortunately have a few.

If you can figure out how to use your board to control the servo position you should have a very successful product. I'm sure there is a market for an Arduno shield capable of doing that. Please let me know if you ever do figure this out.

Thank you for your help. I'm sorry things did not work out.

Best regards,
Ted
userHeadPic tedkurtz
2015-07-28 04:46:29 Hello,

The second link was not a mistake. It is a link to John Wakefield's blog, an entry for 2014 where he shows how to control the position of an AX-12A servo using a CDS55xx Driver Board. I have used his method successfully.

I'm afraid that I have concluded that your board cannot be used to control the position of an AX-12A servo.

I am going to use a CDS55xx Driver Board with a 6-Port AX MX Power Hub. I have just realized that I can in that way drive the number of servos I want in my project. By the way, the CDS55xx board is no longer in production, but I fortunately have a few.

If you can figure out how to use your board to control the servo position you should have a very successful product. I'm sure there is a market for an Arduno shield capable of doing that. Please let me know if you ever do figure this out.

Thank you for your help. I'm sorry things did not work out.

Best regards,
Ted
userHeadPic tedkurtz
2015-07-27 19:56:37 Hi Ted,

The guy had the same problem with you in the arduino forum, and funny comments there were~

But the second link you gave me are talking about how to let robot walk~ is it a mistake?

anyway, for I could not find a ax servo or cds55xx servo , so I have no way to have a test. I asked my colleague about it. He told me : In rotation mode , it should be ok. And if it was transfered into servo mode from rotation mode, it should be initialized in the code. Then it will be ok.

can you have a try according to that?
userHeadPic Leff
2015-07-27 19:56:37 Hi Ted,

The guy had the same problem with you in the arduino forum, and funny comments there were~

But the second link you gave me are talking about how to let robot walk~ is it a mistake?

anyway, for I could not find a ax servo or cds55xx servo , so I have no way to have a test. I asked my colleague about it. He told me : In rotation mode , it should be ok. And if it was transfered into servo mode from rotation mode, it should be initialized in the code. Then it will be ok.

can you have a try according to that?
userHeadPic Leff
2015-07-25 07:44:09 Hello again,

Here is a link to the Arduino Forum for someone having the same problem I'm having:

http://forum.arduino.cc/index.php?topic=268727.0

His servo operates only in motor mode with your board.

My servos run OK when I use the techniques and hardware described by John Wakefield on Sunday 23 March 2014 in this blog:

http://dynamicnotions.blogspot.com/sear ... -results=8

I can control the servo position OK that way. The servos are OK. Unfortunately, the board he used (AX-12 CDS55xx Driver Board) cannot supply enough power to drive the number of servos I need. By the way, he shows an excellent picture of the type of servo I'm using.

I think the problem must lie either in your board or your software.

Please sort this out.

Thank you.

Ted
userHeadPic tedkurtz
2015-07-25 05:01:02 They are both Robotis Dynamixel AX-12A servos.

I tried to insert a picture but can't figure out how to do it. Tried "Insert image" but that did not seem to work. They are both just standard AX-12A servos and my only electrical connections are USB to the Arduino, your shield plugged into the Arduino, an 11.1 v LiPo connected to your shield and the servo plugged into your shield.

The servos run, but in motor mode instead of servo mode.

Could there be a problem with the shield? I bought it from the Robot Shop where I am a frequent customer, and could probably exchange it.

Ted
userHeadPic tedkurtz
2015-07-25 05:01:02 They are both Robotis Dynamixel AX-12A servos.

I tried to insert a picture but can't figure out how to do it. Tried "Insert image" but that did not seem to work. They are both just standard AX-12A servos and my only electrical connections are USB to the Arduino, your shield plugged into the Arduino, an 11.1 v LiPo connected to your shield and the servo plugged into your shield.

The servos run, but in motor mode instead of servo mode.

Could there be a problem with the shield? I bought it from the Robot Shop where I am a frequent customer, and could probably exchange it.

Ted
userHeadPic tedkurtz
2015-07-24 20:15:08 O, strange, what kind of servo do you use? Can you take a photo? userHeadPic Leff
2015-07-24 20:15:08 O, strange, what kind of servo do you use? Can you take a photo? userHeadPic Leff
2015-07-24 05:13:58 Hello,

Thank you. I copied your code and ran it. Results: 'p' made the servo run CCW endlessly; 'm' made the servo run CCW several seconds and then run CW endlessly. I get the same results for two servos, so it looks to me like the servos are OK and the problem lies in the SercoCds55.cpp code. I think that is the way the servos behaved when I first contacted you.

Ted
userHeadPic tedkurtz
2015-07-24 05:13:58 Hello,

Thank you. I copied your code and ran it. Results: 'p' made the servo run CCW endlessly; 'm' made the servo run CCW several seconds and then run CW endlessly. I get the same results for two servos, so it looks to me like the servos are OK and the problem lies in the SercoCds55.cpp code. I think that is the way the servos behaved when I first contacted you.

Ted
userHeadPic tedkurtz
2015-07-24 01:20:40 Yes, try this to find if it could work? :P

Code: Select all
 /*
/*
 # This Sample code is for testing the Digital Servo Shield.
   
 # Editor : YouYou
 # Date   : 2014.10.24
 # Ver    : 1.0
 # Product: Digital Servo Shield for Arduino
 # SKU    :
   
 # Hardwares:
 1. Arduino UNO
 2. Digital Servo Shield for Arduino
 3. Digital Servos( Compatible with AX-12,CDS55xx...etc)
 4. Power supply:6.5 - 12V
   
 */
 
#include <SPI.h>
#include <ServoCds55.h>
ServoCds55 myservo;
 
void setup (void)
{
  Serial.begin (115200);
  myservo.begin ();
}
 
void loop (void)
{
 
  if(Serial.available()){
    char val = Serial.read();
    if(val != -1)
    {
      switch(val)
      {
      case 'p':
 
   myservo.write(1,300);//ID:1  Pos:300  velocity:150
        delay(3000);

  myservo.write(1,0);//ID:1  Pos:0  velocity:150 
        delay(3000);
        break;
 
      case 'v':
        myservo.setVelocity(100);// set velocity to 100(range:0-300) in Servo mode
        break; 
 
      case 'm':
        myservo.rotate(1,150);//   CCW    ID:1  Velocity: 150  middle velocity  300 max   
        delay(2000);
        myservo.rotate(1,-150);//  CW     ID:1  Velocity: -150  middle velocity  -300 max     
        break; 
 
//      case 'i':
//        myservo.SetID(1,2);//ID:1   newID:2
//        break;
//       
//        case 'r':
//         myservo.Reset(2);//Restore ID2 servo to factory Settings ( ID:1  Baud rate:1000000)
//         break;
   
      }
    } 
    else 
      Serial.println("Wait");
    delay(500);
 
  }
 
}
userHeadPic Leff
2015-07-24 01:20:40 Yes, try this to find if it could work? :P

Code: Select all
 /*
/*
 # This Sample code is for testing the Digital Servo Shield.
   
 # Editor : YouYou
 # Date   : 2014.10.24
 # Ver    : 1.0
 # Product: Digital Servo Shield for Arduino
 # SKU    :
   
 # Hardwares:
 1. Arduino UNO
 2. Digital Servo Shield for Arduino
 3. Digital Servos( Compatible with AX-12,CDS55xx...etc)
 4. Power supply:6.5 - 12V
   
 */
 
#include <SPI.h>
#include <ServoCds55.h>
ServoCds55 myservo;
 
void setup (void)
{
  Serial.begin (115200);
  myservo.begin ();
}
 
void loop (void)
{
 
  if(Serial.available()){
    char val = Serial.read();
    if(val != -1)
    {
      switch(val)
      {
      case 'p':
 
   myservo.write(1,300);//ID:1  Pos:300  velocity:150
        delay(3000);

  myservo.write(1,0);//ID:1  Pos:0  velocity:150 
        delay(3000);
        break;
 
      case 'v':
        myservo.setVelocity(100);// set velocity to 100(range:0-300) in Servo mode
        break; 
 
      case 'm':
        myservo.rotate(1,150);//   CCW    ID:1  Velocity: 150  middle velocity  300 max   
        delay(2000);
        myservo.rotate(1,-150);//  CW     ID:1  Velocity: -150  middle velocity  -300 max     
        break; 
 
//      case 'i':
//        myservo.SetID(1,2);//ID:1   newID:2
//        break;
//       
//        case 'r':
//         myservo.Reset(2);//Restore ID2 servo to factory Settings ( ID:1  Baud rate:1000000)
//         break;
   
      }
    } 
    else 
      Serial.println("Wait");
    delay(500);
 
  }
 
}
userHeadPic Leff
2015-07-23 11:13:35 Thank you. Is this what you meant for the 'p' command??

Code: Select all
 /*
/*
 # This Sample code is for testing the Digital Servo Shield.
   
 # Editor : YouYou
 # Date   : 2014.10.24
 # Ver    : 1.0
 # Product: Digital Servo Shield for Arduino
 # SKU    :
   
 # Hardwares:
 1. Arduino UNO
 2. Digital Servo Shield for Arduino
 3. Digital Servos( Compatible with AX-12,CDS55xx...etc)
 4. Power supply:6.5 - 12V
   
 */
 
#include <SPI.h>
#include <ServoCds55.h>
ServoCds55 myservo;
 
void setup (void)
{
  Serial.begin (115200);
  myservo.begin ();
}
 
void loop (void)
{
 
  if(Serial.available()){
    char val = Serial.read();
    if(val != -1)
    {
      switch(val)
      {
      case 'p':
        myservo.WritePos(1,300);//ID:1  Pos:300  velocity:150
//        myservo.write(1,300);//ID:1  Pos:300  velocity:150
        delay(3000);
        myservo.WritePos(1,300);//ID:1  Pos:300  velocity:150
//        myservo.write(1,0);//ID:1  Pos:0  velocity:150 
        break;
 
      case 'v':
        myservo.setVelocity(100);// set velocity to 100(range:0-300) in Servo mode
        break; 
 
      case 'm':
        myservo.rotate(1,150);//   CCW    ID:1  Velocity: 150  middle velocity  300 max   
        delay(2000);
        myservo.rotate(1,-150);//  CW     ID:1  Velocity: -150  middle velocity  -300 max     
        break; 
 
//      case 'i':
//        myservo.SetID(1,2);//ID:1   newID:2
//        break;
//       
//        case 'r':
//         myservo.Reset(2);//Restore ID2 servo to factory Settings ( ID:1  Baud rate:1000000)
//         break;
   
      }
    } 
    else 
      Serial.println("Wait");
    delay(500);
 
  }
 


This still runs the servo endlessly.

Ted
userHeadPic tedkurtz
2015-07-23 11:13:35 Thank you. Is this what you meant for the 'p' command??

Code: Select all
 /*
/*
 # This Sample code is for testing the Digital Servo Shield.
   
 # Editor : YouYou
 # Date   : 2014.10.24
 # Ver    : 1.0
 # Product: Digital Servo Shield for Arduino
 # SKU    :
   
 # Hardwares:
 1. Arduino UNO
 2. Digital Servo Shield for Arduino
 3. Digital Servos( Compatible with AX-12,CDS55xx...etc)
 4. Power supply:6.5 - 12V
   
 */
 
#include <SPI.h>
#include <ServoCds55.h>
ServoCds55 myservo;
 
void setup (void)
{
  Serial.begin (115200);
  myservo.begin ();
}
 
void loop (void)
{
 
  if(Serial.available()){
    char val = Serial.read();
    if(val != -1)
    {
      switch(val)
      {
      case 'p':
        myservo.WritePos(1,300);//ID:1  Pos:300  velocity:150
//        myservo.write(1,300);//ID:1  Pos:300  velocity:150
        delay(3000);
        myservo.WritePos(1,300);//ID:1  Pos:300  velocity:150
//        myservo.write(1,0);//ID:1  Pos:0  velocity:150 
        break;
 
      case 'v':
        myservo.setVelocity(100);// set velocity to 100(range:0-300) in Servo mode
        break; 
 
      case 'm':
        myservo.rotate(1,150);//   CCW    ID:1  Velocity: 150  middle velocity  300 max   
        delay(2000);
        myservo.rotate(1,-150);//  CW     ID:1  Velocity: -150  middle velocity  -300 max     
        break; 
 
//      case 'i':
//        myservo.SetID(1,2);//ID:1   newID:2
//        break;
//       
//        case 'r':
//         myservo.Reset(2);//Restore ID2 servo to factory Settings ( ID:1  Baud rate:1000000)
//         break;
   
      }
    } 
    else 
      Serial.println("Wait");
    delay(500);
 
  }
 


This still runs the servo endlessly.

Ted
userHeadPic tedkurtz
2015-07-22 19:42:13 Hi,

I didnot play it before, but when I opened the library .h file. I found this: void WritePos(int ID,int Pos);

You can add
Code: Select all
  void WritePos(int ID,int Pos);

to your sketch to make it! :)
Code: Select all
#ifndef __ServoCds55_H
#define __ServoCds55_H

#if ARDUINO >= 100
 #include "Arduino.h"
#else
 #include "WProgram.h"
#endif

#include <SPI.h>

class ServoCds55
{
public:
    ServoCds55(int CS=10);
   void begin();
    void WritePos(int ID,int Pos);
    void write(int ID,int Pos);
    void setVelocity(int velocity);
    void setPoslimit(int posLimit);
    void rotate(int ID,int velocity);
    void SetServoLimit(int ID,int upperLimit);
    void SetMotormode(int ID, int velocity);
    void SetID(int ID, int newID);
    void Reset(int ID);
    byte transferAndWait (const byte what);

private:
    int velocity_temp;
    int upperLimit_temp;
    int cs;
};

#endif
userHeadPic Leff
2015-07-22 19:42:13 Hi,

I didnot play it before, but when I opened the library .h file. I found this: void WritePos(int ID,int Pos);

You can add
Code: Select all
  void WritePos(int ID,int Pos);

to your sketch to make it! :)
Code: Select all
#ifndef __ServoCds55_H
#define __ServoCds55_H

#if ARDUINO >= 100
 #include "Arduino.h"
#else
 #include "WProgram.h"
#endif

#include <SPI.h>

class ServoCds55
{
public:
    ServoCds55(int CS=10);
   void begin();
    void WritePos(int ID,int Pos);
    void write(int ID,int Pos);
    void setVelocity(int velocity);
    void setPoslimit(int posLimit);
    void rotate(int ID,int velocity);
    void SetServoLimit(int ID,int upperLimit);
    void SetMotormode(int ID, int velocity);
    void SetID(int ID, int newID);
    void Reset(int ID);
    byte transferAndWait (const byte what);

private:
    int velocity_temp;
    int upperLimit_temp;
    int cs;
};

#endif
userHeadPic Leff
2015-07-22 05:23:29 I am trying to use the Smart Servo Shield with an Arduino Uno to drive AX-12A servos in servo mode. I have copied the software for testing the shield from the DFROBOT web site and am using it without modification. Here is that code:
Code: Select all
/*
/*
 # This Sample code is for testing the Digital Servo Shield.
   
 # Editor : YouYou
 # Date   : 2014.10.24
 # Ver    : 1.0
 # Product: Digital Servo Shield for Arduino
 # SKU    :
   
 # Hardwares:
 1. Arduino UNO
 2. Digital Servo Shield for Arduino
 3. Digital Servos( Compatible with AX-12,CDS55xx...etc)
 4. Power supply:6.5 - 12V
   
 */
 
#include <SPI.h>
#include <ServoCds55.h>
ServoCds55 myservo;
 
void setup (void)
{
  Serial.begin (115200);
  myservo.begin ();
}
 
void loop (void)
{
 
  if(Serial.available()){
    char val = Serial.read();
    if(val != -1)
    {
      switch(val)
      {
      case 'p':
        myservo.write(1,300);//ID:1  Pos:300  velocity:150
        delay(3000);
        myservo.write(1,0);//ID:1  Pos:0  velocity:150 
        break;
 
      case 'v':
        myservo.setVelocity(100);// set velocity to 100(range:0-300) in Servo mode
        break; 
 
      case 'm':
        myservo.rotate(1,150);//   CCW    ID:1  Velocity: 150  middle velocity  300 max   
        delay(2000);
        myservo.rotate(1,-150);//  CW     ID:1  Velocity: -150  middle velocity  -300 max     
        break; 
 
//      case 'i':
//        myservo.SetID(1,2);//ID:1   newID:2
//        break;
//       
//        case 'r':
//         myservo.Reset(2);//Restore ID2 servo to factory Settings ( ID:1  Baud rate:1000000)
//         break;
   
      }
    } 
    else 
      Serial.println("Wait");
    delay(500);
 
  }
 


I am using that code without modification..

Using the character 'p' causes the servo to rotate CCW endlessly.

Using the character 'm' causes the servo to rotate CCW for a few seconds and then to rotate CW endlessly.

I need to use the servos in servo mode; i.e. I want them to turn to specific positions and then hold that position. Can anyone tell me how to do that?

Thank you.

Ted
userHeadPic tedkurtz