Below is my setup:
- DXL Shield is powered by 12 V PS to its Terminal Block. VIN Jumper is disconnected.
- UNO-R3 is powered by USB cable.
- I am using a 2XL-430 actuator.
Below is the Arduino sketch I used. It is based on the example sketch “position_mode.ino” but I stripped out all the macros and DEBUG_SERIAL stuff.
#include <Dynamixel2Arduino.h>
#define DXL_SERIAL Serial
const int DXL_DIR_PIN = 2; // DYNAMIXEL Shield DIR PIN
const uint8_t DXL_ID = 1;
const float DXL_PROTOCOL_VERSION = 2.0;
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:
// Set Port baudrate to 1000000bps matching my 2XL-430's with DYNAMIXEL baudrate.
dxl.begin(1000000);
// Set Port Protocol Version. This has to match with DYNAMIXEL protocol version.
dxl.setPortProtocolVersion(DXL_PROTOCOL_VERSION);
// Get DYNAMIXEL information
dxl.ping(DXL_ID);
// Turn off torque when configuring items in EEPROM area
dxl.torqueOff(DXL_ID);
dxl.setOperatingMode(DXL_ID, OP_POSITION);
dxl.torqueOn(DXL_ID);
// Limit the maximum velocity in Position Control Mode. Use 0 for Max speed
dxl.writeControlTableItem(PROFILE_VELOCITY, DXL_ID, 30);
}
void loop() {
// put your main code here, to run repeatedly:
// Please refer to e-Manual(http://emanual.robotis.com/docs/en/parts/interface/dynamixel_shield/) for available range of value.
// Set Goal Position in RAW value
dxl.setGoalPosition(DXL_ID, 1000);
int i_present_position = 0;
float f_present_position = 0.0;
while (abs(1000 - i_present_position) > 10)
{
i_present_position = dxl.getPresentPosition(DXL_ID);
}
delay(1000);
// Set Goal Position in DEGREE value
dxl.setGoalPosition(DXL_ID, 5.7, UNIT_DEGREE);
while (abs(5.7 - f_present_position) > 2.0)
{
f_present_position = dxl.getPresentPosition(DXL_ID, UNIT_DEGREE);
}
delay(1000);
}
Below is a little video clip showing how this sketch runs - don’t forget to switch the UART switch to the DXL side, and turn on power to the DXL SHIELD and also push the RESET button on the UNO-R3 to restart the downloaded sketch:
Hopefully this sketch will work for you too. If not, there is a good chance that the DXL SHIELD is acting up somehow.