OpenCM9.04 and XL-320 motors not working

Hello, I’m trying to make a 2-axis system using the parts listed below, but I’m struggling to get it off the ground. I have

  • 2x XL-320 motors
  • OpenCM9.04 board, connected to PC via USB
  • Arduino IDE v1.8.13
  • OpenCM9.04 boards package v1.5.1
  • Dynamixel2Arduino library v0.5.1
  • no external power supply

I can’t seem to connect anything - the “scan_dynamixel” example says 0 dyanmixels found, and none of the other examples appear to function at all.

I’m unclear on the significance of the 4 different connectors on the board (labelled X1, X2, X3, and X4TTL), but have tried the scan example with each of them.

Worth noting that I have seen both motors run with this board using the OpenCM software and no external supply (but I believe I can’t use this moving forward as it doesn’t support multiple motors).

Please help me turn this on? Thanks!

Image from iOS (3)

Image from iOS (2)

1 Like

Have you tried connecting a power source? As mentioned here you will not be able to move the servos without:

I power mine with a pair of JST PH 2.0 2-pin pig tails, from which I have removed one red and one black cable so it matches the series connected layout of the power plug (for schematics of the power port, see the eManual linked above):

image

In addition you should consider setting individual ID’s for the servos to move them independently.

1 Like

Hello @seansies, Welcome to this community although we have few people really playing around in this community. I am trying to energize this community to be grown up with my little knowledge.

#1 What WaldoPepper suggested is also very worthy of attemption.

#2. CHECK POTION OF Conditional-compilation DIRECTIVE. As the OpenCM 9.04 uses differnt Serial port, you have to compile the code with Serial1 for DXL_SERIAL otherwise the DYNAMIXEL will not get the packet from the serial port properly.

For you, the below preprocessor may work with OpenCM 9.04 standalone.

  • Replace the portion of “if” conditional directive with the below code
#define DXL_SERIAL   Serial1 //OpenCM9.04 EXP Board's DXL port Serial. (Serial1 for the DXL port on the OpenCM 9.04 board)
#define DEBUG_SERIAL Serial
const uint8_t DXL_DIR_PIN = 22; //OpenCM9.04 EXP Board's DIR PIN. (28 for the DXL port on the OpenCM 9.04 board)

Hi @Yogurt_Man and @WaldoPepper , thanks for responding!

I tried connecting my OpenCR9.04 to a 7.4V supply as in the image you sent but no change… I also read through the “id” example but I don’t think I can set any IDs without first having them recognized.

I did also set the preprocessor lines in the scan example (and others) as you suggested @Yogurt_Man (will paste that example to confirm I understood) but again no change.

Any other ideas? May post to the arduino forum too perhaps.

Thanks again,
Sean

/*******************************************************************************
* Copyright 2016 ROBOTIS CO., LTD.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

#include <Dynamixel2Arduino.h>

// Please modify it to suit your hardware.
//#if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_MEGA2560) // When using DynamixelShield
//  #include <SoftwareSerial.h>
//  SoftwareSerial soft_serial(7, 8); // DYNAMIXELShield UART RX/TX
//  #define DXL_SERIAL   Serial
//  #define DEBUG_SERIAL soft_serial
//  const uint8_t DXL_DIR_PIN = 2; // DYNAMIXEL Shield DIR PIN
//#elif defined(ARDUINO_SAM_DUE) // When using DynamixelShield
//  #define DXL_SERIAL   Serial
//  #define DEBUG_SERIAL SerialUSB
//  const uint8_t DXL_DIR_PIN = 2; // DYNAMIXEL Shield DIR PIN
//#elif defined(ARDUINO_SAM_ZERO) // When using DynamixelShield
//  #define DXL_SERIAL   Serial1
//  #define DEBUG_SERIAL SerialUSB
//  const uint8_t DXL_DIR_PIN = 2; // DYNAMIXEL Shield DIR PIN
//#elif defined(ARDUINO_OpenCM904) // When using official ROBOTIS board with DXL circuit.
//  #define DXL_SERIAL   Serial3 //OpenCM9.04 EXP Board's DXL port Serial. (Serial1 for the DXL port on the OpenCM 9.04 board)
//  #define DEBUG_SERIAL Serial
//  const uint8_t DXL_DIR_PIN = 22; //OpenCM9.04 EXP Board's DIR PIN. (28 for the DXL port on the OpenCM 9.04 board)
//#elif defined(ARDUINO_OpenCR) // When using official ROBOTIS board with DXL circuit.
//  // For OpenCR, there is a DXL Power Enable pin, so you must initialize and control it.
//  // Reference link : https://github.com/ROBOTIS-GIT/OpenCR/blob/master/arduino/opencr_arduino/opencr/libraries/DynamixelSDK/src/dynamixel_sdk/port_handler_arduino.cpp#L78
//  #define DXL_SERIAL   Serial3
//  #define DEBUG_SERIAL Serial
//  const uint8_t DXL_DIR_PIN = 84; // OpenCR Board's DIR PIN.    
//#else // Other boards when using DynamixelShield
//  #define DXL_SERIAL   Serial1
//  #define DEBUG_SERIAL Serial
//  const uint8_t DXL_DIR_PIN = 2; // DYNAMIXEL Shield DIR PIN
//#endif

#define DXL_SERIAL   Serial1 //OpenCM9.04 EXP Board's DXL port Serial. (Serial1 for the DXL port on the OpenCM 9.04 board)
#define DEBUG_SERIAL Serial
const uint8_t DXL_DIR_PIN = 22; //OpenCM9.04 EXP Board's DIR PIN. (28 for the DXL port on the OpenCM 9.04 board)
 

#define MAX_BAUD  5
const int32_t buad[MAX_BAUD] = {57600, 115200, 1000000, 2000000, 3000000};

Dynamixel2Arduino dxl(DXL_SERIAL, DXL_DIR_PIN);

//This namespace is required to use Control table item names
using namespace ControlTableItem;

void setup() {
  // put your setup code here, to run once:
  int8_t index = 0;
  int8_t found_dynamixel = 0;

  // Use UART port of DYNAMIXEL Shield to debug.
  DEBUG_SERIAL.begin(115200);   //set debugging port baudrate to 115200bps
  while(!DEBUG_SERIAL);         //Wait until the serial port is opened
    
  for(int8_t protocol = 1; protocol < 3; protocol++) {
    // Set Port Protocol Version. This has to match with DYNAMIXEL protocol version.
    dxl.setPortProtocolVersion((float)protocol);
    DEBUG_SERIAL.print("SCAN PROTOCOL ");
    DEBUG_SERIAL.println(protocol);
    
    for(index = 0; index < MAX_BAUD; index++) {
      // Set Port baudrate.
      DEBUG_SERIAL.print("SCAN BAUDRATE ");
      DEBUG_SERIAL.println(buad[index]);
      dxl.begin(buad[index]);
      for(int id = 0; id < DXL_BROADCAST_ID; id++) {
        //iterate until all ID in each buadrate is scanned.
        if(dxl.ping(id)) {
          DEBUG_SERIAL.print("ID : ");
          DEBUG_SERIAL.print(id);
          DEBUG_SERIAL.print(", Model Number: ");
          DEBUG_SERIAL.println(dxl.getModelNumber(id));
          found_dynamixel++;
        }
      }
    }
  }
  
  DEBUG_SERIAL.print("Total ");
  DEBUG_SERIAL.print(found_dynamixel);
  DEBUG_SERIAL.println(" DYNAMIXEL(s) found!");
}

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

Have your tried using 28 for the DXL_DIR_PIN pin (instead of 22, since you are obviously not using an EXP board)?

@seansies

Oh… I forgot to change the DIR pin. Thank @WaldoPepper for pointing it out.

Finally back at my desk and changing the DXL_DIR_PIN along with the other preprocessor changes sorted it!

I’ll move on to the real project and update further. For now, I also noticed that in the other examples I tried, the baudrate for the motor serial was set in the code at 57600, but my motor was at 1Mbs- so all the position, etc examples wouldn’t run until I changed that.

1 Like

To summarize for future people like me:

  • the preprocessor lines in the examples seem to be unusable - for using the OpenCM9.04 board I replaced them with:
#define DXL_SERIAL   Serial1 //OpenCM9.04 EXP Board's DXL port Serial. (Serial1 for the DXL port on the OpenCM 9.04 board)
const uint8_t DXL_DIR_PIN = 28; //OpenCM9.04 EXP Board's DIR PIN. (28 for the DXL port on the OpenCM 9.04 board)
  • the default baud rate of an XL-320 is 1Mbps, but the examples all assumed it was 57600 (might apply for a different motor)
  • while the motors do move without external power supplied, the performance appears much better with 7.4 supplied as @WaldoPepper suggested

Thanks again

1 Like

Looking forward to seeing your full project :slight_smile:

What should be the DXL_DIR_PIN value to control dynamixel XL320 using arduino DUE. I could control xl320 using OpenCM 9.04 but couldn’t control using Arduino Due.
I am using TX1(pin 18) and Rx1 (pin 19) of Due. I am debugging using Serial1 command and fixing baud rate 112500. As there is no TTL communication available in Arduino DUE, I am currently using SN74LS241N as a tristate buffer to handle transmission and reception. Where I am missing out. Kindly help.
Thanks.

The DXL_DIR_PIN setting is only meaningful is you are using the ROBOTIS DXL Shield with the DUE

And then it is supposed to be “2”

image

Also have you seen the following post? There seems to be a “voltage” problem because the DUE can only provide 3.3 V and the DXL Shield needs a minimum of 5 V. Also, the XL-320 needs 7.5 V to operate properly.