DRS-0101

Hello,

I have bought 14 servos DRS-0101 and I have a problem with them. I have a program that works perfectly with the DRS-0201(reboot command, stat command, moving command, read position) but with the DRS-0101 it blinks red after the reboot command (I see this command work with the led). STAT command, Clear error, read Ram, write Ram works, always blink red after executing command, and never move. I don’t understand why it works with the DRS-0201 but not with the DRS-0101 knowing that it is the same datasheet so the program should work.

I hope you could help me.

Bye.

Hi,

]How do you control the DRS-0101 ? Are you using an Arduino ? If so, which library do you use ?/:m]
]Are the servos daisy-chained or you are controlling one servo at once ?/:m]
]Have you verified if you have the good ID in your code for the servo you trying to control ? Did you try to do a factory reset on the servo ?/:m]Regards,

Yes I’m using an arduino Uno. I am controlling just one servo. I join you my program

[code]#include “SoftwareSerial.h”

#define ID 0xfd

unsigned char REBOOT_64] = {0xff,0xff,0x07,ID,0x09,0x4e,0xb0};
unsigned char RAM_WRITE_TORQUE_ON_64] = {0xff,0xff,0x0a,ID,0x03,0xa0,0x5e,0x34,0x01,0x60};
unsigned char I_JOG1_64] = {0xff,0xff,0x0c,ID,0x05,0x3e,0xc0,0x50,0x46,0x08,ID,0x3C}; //Led Blue
unsigned char RAM_READ_POSITION_64] = {0xff,0xff,0x09,ID,0x04,0xc4,0x3a,60,0x02};
unsigned char RAM_WRITE_PWM_64] = {0xff,0xff,0x0b,ID,0x03,0xa0,0x5e,16,0x02,0xff,0x03}; //0-> 3FF
unsigned char STAT] = {0xff,0xff,0x07,ID,0x07,0xfc,0x02};//,0x00,0x40};
unsigned char RAM_CLEAR_ERROR] = {0xff,0xff,0x0b,ID,0x03,0xa0,0x5e,48,0x02,0x00,0x00};

SoftwareSerial mySerial(10, 11); // RX, TX

unsigned char bufRecep[100];
unsigned int deplacement;
unsigned char checkSum1;
unsigned char checkSum2;

unsigned int positionMin = 0x2310;
unsigned int positionMax = 0x59AB;

boolean flag = false;
int sens = 1;

void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
mySerial.begin(115200);

delay(500);
int len = sizeof(REBOOT_64);
CheckSum(REBOOT_64, len, &checkSum2, &checkSum1);
Serial.print(“checkSum1=”);
Serial.println(checkSum1,HEX);
Serial.print(“checkSum2=”);
Serial.println(checkSum2,HEX);

REBOOT_64[5] = checkSum1;
REBOOT_64[6] = checkSum2;

for (int i = 0; i<len;i++)
{
mySerial.write(REBOOT_64);
}
delay(500);

len = sizeof(RAM_WRITE_TORQUE_ON_64);
CheckSum(RAM_WRITE_TORQUE_ON_64, len, &checkSum2, &checkSum1);
Serial.print(“checkSum1=”);
Serial.println(checkSum1,HEX);
Serial.print(“checkSum2=”);
Serial.println(checkSum2,HEX);

RAM_WRITE_TORQUE_ON_64[5] = checkSum1;
RAM_WRITE_TORQUE_ON_64[6] = checkSum2;

for (int i = 0; i<len;i++)
{
mySerial.write(RAM_WRITE_TORQUE_ON_64);
}
delay(200);
Serial.println(“RAM_WRITE_TORQUE_ON_64”);
readSerial();
delay(200);

Stat();
delay(1000);
readSerial();

ClearError();
delay(1000);
readSerial();

len = sizeof(RAM_WRITE_PWM_64);
CheckSum(RAM_WRITE_PWM_64, len, &checkSum2, &checkSum1);
RAM_WRITE_PWM_64[5] = checkSum1;
RAM_WRITE_PWM_64[6] = checkSum2;
for (int i = 0; i<len;i++)
{
mySerial.write(RAM_WRITE_PWM_64);
}
delay(200);
Serial.println(“RAM_WRITE_PWM_64”);
readSerial();

delay(400);

len = sizeof(RAM_READ_POSITION_64);
CheckSum(RAM_READ_POSITION_64, len, &checkSum2, &checkSum1);
RAM_READ_POSITION_64[5] = checkSum1;
RAM_READ_POSITION_64[6] = checkSum2;

for (int i = 0; i<len;i++)
{
mySerial.write(RAM_READ_POSITION_64);
}
delay(200);
Serial.println(“RAM_READ_POSITION_64”);
readSerial();
Serial.print(“flag=”);
Serial.println(flag);

len = sizeof(RAM_CLEAR_ERROR);

CheckSum(RAM_CLEAR_ERROR, len, &checkSum2, &checkSum1);
RAM_CLEAR_ERROR[5] = checkSum1;
RAM_CLEAR_ERROR[6] = checkSum2;
for (int i = 0; i<len;i++)
{
mySerial.write(RAM_CLEAR_ERROR);
}
delay(200);
Serial.println(“RAM_CLEAR_ERROR”);
readSerial();
delay(400);

deplacement = 0x3ff/2;

Stat();
delay(1000);
readSerial();

//while(1);
}

void loop() {
// put your main code here, to run repeatedly:

char ch = deplacement>>8;
char cl = deplacement & 0x00ff;
I_JOG1_64[7] = cl;
I_JOG1_64[8] = ch;

int len = sizeof(I_JOG1_64);
CheckSum(I_JOG1_64, len, &checkSum2, &checkSum1);
/*
Serial.print(“checkSum1=”);
Serial.println(checkSum1,HEX);
Serial.print(“checkSum2=”);
Serial.println(checkSum2,HEX);
*/
I_JOG1_64[5] = checkSum1;
I_JOG1_64[6] = checkSum2;

for (int i = 0; i<len;i++)
{
//Serial.print(I_JOG1_64,HEX);
//Serial.print(" ");
mySerial.write(I_JOG1_64);
}

if (deplacement > 250)
sens = -1;
else
if (deplacement < 50)
sens = 1;

Serial.println();
Serial.print(“deplacement=”);
Serial.println(deplacement,HEX);
//Serial.println(“I_JOG1_64”);
Serial.print(“sens=”);
Serial.println(sens);

delay(1000);

readSerial();

deplacement = deplacement + (50 * sens);

len = sizeof(RAM_READ_POSITION_64);

CheckSum(RAM_READ_POSITION_64, len, &checkSum2, &checkSum1);
RAM_READ_POSITION_64[5] = checkSum1;
RAM_READ_POSITION_64[6] = checkSum2;

for (int i = 0; i<len;i++)
{
mySerial.write(RAM_READ_POSITION_64);
}
delay(200);
Serial.println(“RAM_READ_POSITION_64”);
readSerial();
delay(1000);

int position = bufRecep[10];
position = position << 8;
position = position | (bufRecep[9] & 0x00ff);
Serial.print("Position = ");
Serial.println(position,HEX);

}

void CheckSum(unsigned char* tab, int len, unsigned char* checkSum1, unsigned char* checkSum2)
{
//Serial.print(len,DEC);
unsigned char sum1=0;
for (int i = 2; i<len;i++)
{
if (i != 5 || i != 6)
sum1 = sum1^tab;
}
sum1 = sum1 & 0xfe;
*checkSum1 = sum1;
*checkSum2 = ~sum1 & 0xfe;
}

void Stat()
{
int len = sizeof(STAT);
CheckSum(STAT, len, &checkSum2, &checkSum1);
Serial.print(“checkSum1=”);
Serial.println(checkSum1,HEX);
Serial.print(“checkSum2=”);
Serial.println(checkSum2,HEX);

STAT[5] = checkSum1;
STAT[6] = checkSum2;

for (int i = 0; i<len;i++)
{
mySerial.write(STAT);
}
Serial.println(“STAT”);
}

void ClearError()
{
int len = sizeof(RAM_CLEAR_ERROR);
CheckSum(RAM_CLEAR_ERROR, len, &checkSum2, &checkSum1);
Serial.print(“checkSum1=”);
Serial.println(checkSum1,HEX);
Serial.print(“checkSum2=”);
Serial.println(checkSum2,HEX);

RAM_CLEAR_ERROR[5] = checkSum1;
RAM_CLEAR_ERROR[6] = checkSum2;

for (int i = 0; i<len;i++)
{
mySerial.write(RAM_CLEAR_ERROR);
}
Serial.println(“RAM_CLEAR_ERROR”);
}

int readSerial()
{
int cptRecep=0;
int incomingByte = 0; // for incoming serial data

while (mySerial.available() > 0)
{
incomingByte = mySerial.read();
bufRecep[cptRecep] = incomingByte;
//Serial.print(cptRecep);
//Serial.print("=");
Serial.print(incomingByte, HEX);
Serial.print(" ");
cptRecep++;
}
Serial.println();
return incomingByte;
}[/code]

Hi,

When the Red Led of the DRS-0101 blinks when receiving a command, this means that the servo is encountering an error.
There are several reasons that can cause an error with the Herkulex servo (checksum error, command error, address error, position limit error…).
We suggest you to try with a different Arduino code. One that is simple and easy to debug in case the servo still gives an error.
You will also confirm if the issue comes from the Arduino code or from the servo itself.
Try to use this Arduino Library for Herkulex Servos with its example codes.

Regards,

But this code works perfectly with my DRS-0201, I don’t understand why …

Hi,

The DRS-0101 and the DRS-0201 might not have the same ID and/or the same baudrate. That can explain why your code works with only the DRS-0201 and not the DRS-0101.
Check your DRS-0101 ID and baudrate and verify if it matches the ID and baudrate in your Arduino code (115200).
You might also need to reset your DRS-0101 to clear the error.

Regards,

probably a limit sett. I had a issue when writing my driver for this where i set the PWM limit too low.