Dynamixel Recognized nad moves using U2D2 (Dynamixel Wizard) but can't run any of the Arduino IDE examples

Use the following template to help create your post:

  1. State the model of servo you are using.
    I’ve tried with both Protocol 1.0 AX-12A and MX-106. Boards that I’m using are OpenCM 9.04 with the 485 expansion.

  2. Describe your control environment. This includes the controller or interface, computer and OS, and any power source you are using

Simple Arduino IDE examples for OpenCM 9.04 board

  1. Specify the operating mode you are using, for applicable models.

  2. Specify and link any manuals or resources you have used related to your inquiry.

Everything on the internet plus the 2020 series of YouTube videos on how to setup the boards.

  1. Include pictures if possible. This can help our members see how wires are connected, how hardware is installed, or to identify other possible issues.
  1. Paste your code, and I can look into,

  2. What library are you importing? Dynamixel2Arduino or DynamixelShield?

Hi, thank you so much for the quick reply. Here is the code:

/*

  • Dynamixel : AX-series with Protocol 1.0
  • Controller : OpenCM9.04C + OpenCM 485 EXP
  • Power Source : SMPS 12V 5A
  • AX-Series are connected to Dynamixel BUS on OpenCM 485 EXP board or DXL TTL connectors on OpenCM9.04
  • OpenCM 485 EXP
  • This example will test only one Dynamixel at a time.
    */

#include <DynamixelSDK.h>

// AX-series Control table address
#define ADDR_AX_TORQUE_ENABLE 24 // Control table address is different in Dynamixel model
#define ADDR_AX_GOAL_POSITION 30
#define ADDR_AX_PRESENT_POSITION 36

// Protocol version
#define PROTOCOL_VERSION 1.0 // See which protocol version is used in the Dynamixel

// Default setting
#define DXL_ID 1 // Dynamixel ID: 1
#define BAUDRATE 1000000
#define DEVICENAME “3” //DEVICENAME “1” → Serial1(OpenCM9.04 DXL TTL Ports)
//DEVICENAME “2” → Serial2
//DEVICENAME “3” → Serial3(OpenCM 485 EXP)
#define TORQUE_ENABLE 1 // Value for enabling the torque
#define TORQUE_DISABLE 0 // Value for disabling the torque
#define DXL_MINIMUM_POSITION_VALUE 100 // Dynamixel will rotate between this value
#define DXL_MAXIMUM_POSITION_VALUE 1000 // and this value (note that the Dynamixel would not move when the position value is out of movable range. Check e-manual about the range of the Dynamixel you use.)
#define DXL_MOVING_STATUS_THRESHOLD 20 // Dynamixel moving status threshold

#define ESC_ASCII_VALUE 0x1b

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

Serial.println(“Start…”);

// Initialize PortHandler instance
// Set the port path
// Get methods and members of PortHandlerLinux or PortHandlerWindows
dynamixel::PortHandler *portHandler = dynamixel::PortHandler::getPortHandler(DEVICENAME);

// Initialize PacketHandler instance
// Set the protocol version
// Get methods and members of Protocol1PacketHandler or Protocol2PacketHandler
dynamixel::PacketHandler *packetHandler = dynamixel::PacketHandler::getPacketHandler(PROTOCOL_VERSION);

int index = 0;
int dxl_comm_result = COMM_TX_FAIL; // Communication result
int dxl_goal_position[2] = {DXL_MINIMUM_POSITION_VALUE, DXL_MAXIMUM_POSITION_VALUE}; // Goal position

uint8_t dxl_error = 0; // Dynamixel error
int16_t dxl_present_position = 0; // Present position

// Open port
if (portHandler->openPort())
{
Serial.print(“Succeeded to open the port!\n”);
}
else
{
Serial.print(“Failed to open the port!\n”);
Serial.print(“Press any key to terminate…\n”);
return;
}

// Set port baudrate
if (portHandler->setBaudRate(BAUDRATE))
{
Serial.print(“Succeeded to change the baudrate!\n”);
}
else
{
Serial.print(“Failed to change the baudrate!\n”);
Serial.print(“Press any key to terminate…\n”);
return;
}

// Enable Dynamixel Torque
dxl_comm_result = packetHandler->write1ByteTxRx(portHandler, DXL_ID, ADDR_AX_TORQUE_ENABLE, TORQUE_ENABLE, &dxl_error);
if (dxl_comm_result != COMM_SUCCESS)
{
packetHandler->getTxRxResult(dxl_comm_result);
}
else if (dxl_error != 0)
{
packetHandler->getRxPacketError(dxl_error);
}
else
{
Serial.print(“Dynamixel has been successfully connected \n”);
}

while(1)
{
Serial.print(“Press any key to continue! (or press q to quit!)\n”);

while(Serial.available()==0);

int ch;

ch = Serial.read();
if( ch == 'q' )
  break;

// Write goal position
dxl_comm_result = packetHandler->write2ByteTxRx(portHandler, DXL_ID, ADDR_AX_GOAL_POSITION, dxl_goal_position[index], &dxl_error);
if (dxl_comm_result != COMM_SUCCESS)
{
  packetHandler->getTxRxResult(dxl_comm_result);
}
else if (dxl_error != 0)
{
  packetHandler->getRxPacketError(dxl_error);
}

do
{
  // Read present position
  dxl_comm_result = packetHandler->read2ByteTxRx(portHandler, DXL_ID, ADDR_AX_PRESENT_POSITION, (uint16_t*)&dxl_present_position, &dxl_error);
  if (dxl_comm_result != COMM_SUCCESS)
  {
    packetHandler->getTxRxResult(dxl_comm_result);
  }
  else if (dxl_error != 0)
  {
    packetHandler->getRxPacketError(dxl_error);
  }

  Serial.print("[ID:");      Serial.print(DXL_ID);
  Serial.print(" GoalPos:"); Serial.print(dxl_goal_position[index]);
  Serial.print(" PresPos:");  Serial.print(dxl_present_position);
  Serial.println(" ");


}while((abs(dxl_goal_position[index] - dxl_present_position) > DXL_MOVING_STATUS_THRESHOLD));

// Change goal position
if (index == 0)
{
  index = 1;
}
else
{
  index = 0;
}

}

// Disable Dynamixel Torque
dxl_comm_result = packetHandler->write1ByteTxRx(portHandler, DXL_ID, ADDR_AX_TORQUE_ENABLE, TORQUE_DISABLE, &dxl_error);
if (dxl_comm_result != COMM_SUCCESS)
{
packetHandler->getTxRxResult(dxl_comm_result);
}
else if (dxl_error != 0)
{
packetHandler->getRxPacketError(dxl_error);
}

// Close port
portHandler->closePort();

}

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

}

I am using DynamixelSDK on Arduino and the example for Protocol 1.0. I’m able to run the blinker test just fine and I also see the light when the Dynamixels get power, I just need to move them. Am I using the wrong ports to write to the Dynamixels?

Regards,
Dynamixel

I forgot to mention that my OpenCM 9.04 board is type C

Hi @anacaona

The example will start running the code after opening the Serial Monitor from Arduino IDE.
If you want to run the example without opening the serial monitor, comment out the while(!Serial); in the setup() function.

Hi,

While running that example, I opened the serial monitor. However, I tried removing that line and still nothing happens. Should I check my soldering?

Regards,
Dynamixel

1 Like

Hi,

I got it to work. Here are the things I did, I don’t know which combination of these things actually worked:

  • Went to the lab and tried the example code in my lab computer. This one has Arduino 1.8.10 instead of 1.8.13 that I was using somewhere else
  • Revised all my solderings, especially the ports that connect the OpenCM 9.04 with the OpenCM 485 EXP board
1 Like

Hello @anacaona, it’s great to hear you were able to resolve the issue with the OpenCM9.04 and OpenCM485 EXP board and thanks for sharing the update.

While it’s hard to say after the fact, in my opinion it sounds like there may possibly have been an cold solder joint or other imperfection in a pin connection. It’s always a good idea to check solder joints and watch for the signs of a cold solder connection. I’ve linked an excellent guide from Adafruit for reference if you’re interested!

Hi,

After a more careful inspection, what was happening was related to my installation of Arduino in the first computer. I uninstalled and reinstalled Arduino and everything worked.

Regards,
Dynamixel

Hello,

I was having the same problem using arduino 1.8.12 but everything was fixed once i reverted back to 1.8.10. I am not using the u2d2 however, I am using the openCM 9.04 with the exp board and a xl430-w250-t. Hope this helps someone like it helped me.

Did you solve it? I missed it …

Hi,

I got it to work. Here are the things I did, I don’t know which combination of these things actually worked:

  • Went to the lab and tried the example code in my lab computer. This one has Arduino 1.8.10 instead of 1.8.13 that I was using somewhere else
  • Revised all my solderings, especially the ports that connect the OpenCM 9.04 with the OpenCM 485 EXP board
1 Like

Soldering may work to correct your issue.

I’ve been using Arduino 1.8.3 without issues.