1

I have been playing around with this shield for a couple of days now and I have to agree with some statements made in the comments that the "library" lacks many functions.

However I have discovered the following library which was built for the Dynamixel shield: https://github.com/zcshiner/Dynamixel_Serial

I wanted to know since I am using an Arduino Uno, which parameters I would have to change to make it work.

Sorry I am not very fluent in C++. I have tried just changing the direction pin to 10 but it's obviously not sufficient.

Shield to be dealt with: https://dfrobot.com/index.php?route=product/product&product_id=958

The following code should work afterwards:

#include <dynamixel_serial.h> // Library needed to control Dynamixel servo

#define SERVO_ID 0x01 // ID which we will set Dynamixel to
#define SERVO_ControlPin 0x0A // Control pin of buffer chip, NOTE: this does not matter because we are not using a half to full control buffer.
#define SERVO_SET_Baudrate 57600 // Baud rate speed which the Dynamixel will be set to (57600)
#define CW_LIMIT_ANGLE 0x001 // lowest clockwise angle is 1, as when set to 0 it sets servo to wheel mode
#define CCW_LIMIT_ANGLE 0xFFF // Highest anti-clockwise angle is 0XFFF, as when set to 0 it sets servo to wheel mode

void setup() {
  delay(1000); // Give time for Dynamixel to start on power-up
  Dynamixel.begin(SERVO_SET_Baudrate); // We now need to set Arduino to the new baud rate speed
  Dynamixel.setDirectionPin(SERVO_ControlPin); // Optional. Set direction control pin
  Dynamixel.setMode(SERVO_ID, SERVO, CW_LIMIT_ANGLE, CCW_LIMIT_ANGLE); // set mode to SERVO and set angle limits
  Serial.begin(115200);
  Serial.println("Setup Done!");
  pinMode(13, OUTPUT);
}

void loop() {
  digitalWrite(13, HIGH);
  Dynamixel.servo(SERVO_ID,0x001,0x100); // Move servo to angle 1(0.088 degree) at speed 100
  delay(4000);
  Dynamixel.servo(SERVO_ID,0xFFF,0x3FF); // Move servo to max angle at max speed (1023)
  delay(4000);
}
per1234
  • 4,278
  • 2
  • 24
  • 43
Schaschi
  • 21
  • 1

1 Answers1

1

You are setting the baudrate to 57.6K however, you need to communicate with the Dynamixel at the baudrate it is set to. I believe the Dynamixel comes with a preset baudrate of 1Mbs. The first thing thing I would do is to change your 57.6K to 1Mbs and try that. This is assuming the ID is actually 1 (also a default)

Here are two links for info on Arduino baud rates and Dynamixel serial communications.

Controlling AX-12 Servos

How high of a baud rate can I go (without errors)?

atland
  • 179
  • 4