2XC430-W250 won't move using PWM control

DYNAMIXEL Actuator

2XC430-W250

Issue Description

I wrote a simple code to send a PWM command to a 2XC430-W250 with their default ID (1-2) and a XC430-W240 (ID 3) on the same bus. I initilize them the same way. The XC430 responds to the PWM command, while the 2XC430-W250 won’t move. I tried with two different 2XC430-W250 without any results. However, I’m able to control all those actuators using the velocity command. Can we really control those 2XC430-W250 using the PWM control ?

1 Like

Would you be able to share the code that you are using for this?

The 2XC430-W250 should behave the same was as the XC430-W240 in PWM mode, and more information about your specific implementation may help me find a solution for you.

I can share part of the test code I used to identify the problem with the 2XC430. In this code, dxl1 and dxl2 is the 2XC430, and dxl3 is the XC430. Using this code, I’m able to control every motor in velocity mode, but I’m unable to control the 2XC430 in pwm mode. Note that I used the same code to control XM430 and XH430 motors in pwm mode also. In short the only motors that doesn’t work with this code are the 2XC430. I tested two different 2XC430 to make sure my problem was not related to a defective unit.

/***************************************************************************
Include headers :
***************************************************************************/

#include <Arduino.h>
#include <dynaUART.h>

unsigned long currentTime;
unsigned long previousTime;

/***************************************************************************
Function prototype :
***************************************************************************/

void toggleLed();

DynaUART dxl1 = DynaUART(0x01);
DynaUART dxl2 = DynaUART(0x02);
DynaUART dxl3 = DynaUART(0x03);

int16_t speed;

/****************************************************************************
Setup Program :
****************************************************************************/

void setup()
{
previousTime = 0;
speed = 300;

Serial2.begin(57600);
Serial2.setTimeout(5);
delay(1000);

dxl1.initMotor();
dxl2.initMotor();
dxl3.initMotor();

dxl1.setOperatingMode(PWM_MODE);
delay(1000);
dxl2.setOperatingMode(PWM_MODE);
delay(1000);
dxl3.setOperatingMode(PWM_MODE);
delay(1000);

}

/****************************************************************************
Main Program :
****************************************************************************/

void loop()
{
toggleLed();

delay(10);

}

/****************************************************************************
Function definition :
****************************************************************************/
void toggleLed()
{
if(millis()-previousTime > LED_INTERVAL)
{
dxl1.setPWMCommand(speed);
delay(100);
dxl2.setPWMCommand(speed);
delay(100);
dxl3.setPWMCommand(speed);
delay(100);
speed = -speed;
previousTime = millis();
}
}

void DynaUART::initMotor()
{
delay(10);
setTorque(OFF);
delay(10);
setShutdownCondition(ELECTRIC_ERROR | OVERHEATING_ERROR | INPUT_VOLTAGE_ERROR | ENCODER_ERROR | OVERLOAD_ERROR);
delay(10);
setOperatingMode(WHEEL_MODE);
delay(10);
}

void DynaUART::setOperatingMode(uint8_t mode)
{
setTorque(OFF);
delay(10);
instruction[0] = operatingMode;
instruction[1] = 0x00;
instruction[2] = mode;
preparePacket(WRITE, instruction, 3);
sendPacket();
delay(10);
setTorque(ON);
delay(10);
}

void DynaUART::setVelocityCommand(int32_t speed)
{
speed = constrain(speed, -MAX_SPEED, MAX_SPEED);
if(speed < 0)
{
speed = (~abs(speed)) + 1;
}

instruction[0] = goalVelocity;
instruction[1] = 0x00;
instruction[2] = speed & 0x000000FF;
instruction[3] = (speed >> 8) & 0x000000FF;
instruction[4] = (speed >> 16) & 0x000000FF;
instruction[5] = (speed >> 24) & 0x000000FF;
preparePacket(WRITE, instruction, 6);
sendPacket();   

}

void DynaUART::setPWMCommand(int16_t pwm)
{
pwm = constrain(pwm, -MAX_PWM, MAX_PWM);
if(pwm < 0)
{
pwm = (~abs(pwm)) + 1;
}

instruction[0] = goalPWM;
instruction[1] = 0x00;
instruction[2] = pwm & 0x000000FF;
instruction[3] = (pwm >> 8) & 0x000000FF;
preparePacket(WRITE, instruction, 4);
sendPacket();   

}

void DynaUART::setShutdownCondition(uint8_t condition)
{
instruction[0] = shutdown;
instruction[1] = 0x00;
instruction[2] = condition;
preparePacket(WRITE, instruction, 3);
sendPacket();
}

hlavigne,

It looks like you are using an unofficial DYNAMIXEL library in this sketch. Unfortunately I won’t be able to provide any assistance for the usage of this library.

I would recommend checking out the official DYNAMIXEL2Arduino or DYNAMIXELShield libraries to see if using an official library might resolve your issue.

I get it! It is indeed a custom library that we develop before your arduino and shield library were released. I’m pretty confident in our library as we use it since 2020 and never had any problem with it before. I just want to make sure that the limitation doesn’t come from the firmware on the motor itself.

May I ask you if you tried to put the 2XC430 in PWM mode and setted the PWM command with the Arduino library for example ? Having your feedback on this would help me to make sure the problem doesn’t come from your firmware.

I did just test a 2XC430 in PWM mode using an OpenRB150 controller and our DYNAMIXEL2Arduino library, and was able to control both axes using goal PWM.

It looks like it might be something in your library implementation unfortunately… I hope you’re able to figure out what the issue might be.