Hi everyone. I am controlling two DYNAMIXEL MX28(1.0) and MX106(2.0) with OpenCM9.04. And Dynamixel2Arduino library is used for uploading the code. And power source is SMPS (12V, 5A) connected to 485 EXP board.
Sketch code includes Current-based Position control mode for MX106 protocol 2, and Extended Position control mode for MX28 protocol 1 and simple push button code to operate the DYNAMIXEL.
Here the sketch code is working fine however, sometimes either of the one or both DYNAMIXEL instantaneous stops for few Milliseconds and then run normally following the button commands. This some time happened after few rotations of MX or also by pressing the push buttons randomly.
The sample code is attached here
// DYNAMIXEL IDs and Protocol
const uint8_t DXL_ID = 1;
const uint8_t DXL_ID3 = 2;
const float DXL_PROTOCOL_VERSION = 2.0;
const float DXL_PROTOCOL_VERSION1 = 1.0;
void setup() {
// Use Serial to debug.
DEBUG_SERIAL.begin(115200);
// initialize the pushbutton pin as an input:
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
dxl.begin(57600); // Set Port baudrate to 57600bps. This has to match with DYNAMIXEL baudrate.
dxl.setPortProtocolVersion(DXL_PROTOCOL_VERSION); // Set Port Protocol Version. This has to match with DYNAMIXEL protocol version.
dxl.ping(DXL_ID); // Get DYNAMIXEL information
dxl.writeControlTableItem(TORQUE_ENABLE, DXL_ID, 0); // Turn off torque
dxl.setOperatingMode(DXL_ID, OP_CURRENT_BASED_POSITION); // Operating Mode
dxl.writeControlTableItem(CURRENT_LIMIT, DXL_ID, 500); // for Mx(2.0)
dxl.writeControlTableItem(TORQUE_ENABLE, DXL_ID, 1); // Turn on torque
dxl.writeControlTableItem(GOAL_CURRENT, DXL_ID, Torque_ID); // Goal Torque for Mx(2.0)
dxl.writeControlTableItem(PROFILE_VELOCITY, DXL_ID, Velocity_ID); // for Mx(2.0)
dxl3.begin(57600);
dxl3.setPortProtocolVersion(DXL_PROTOCOL_VERSION1);
dxl3.ping(DXL_ID3);
dxl3.writeControlTableItem(TORQUE_ENABLE, DXL_ID3, 0);
dxl3.setOperatingMode(DXL_ID3, OP_EXTENDED_POSITION);
dxl3.writeControlTableItem(MAX_TORQUE, DXL_ID3, 500); // for Mx(1.0)
dxl3.writeControlTableItem(TORQUE_ENABLE, DXL_ID3, 1);
dxl3.writeControlTableItem(TORQUE_LIMIT, DXL_ID3, Torque_ID3); // for Mx(1.0)
dxl3.writeControlTableItem(MOVING_SPEED, DXL_ID3, Velocity_ID3); // for Mx-28T(1.0)
}
void loop() {
// read the state of the pushbutton value:
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);
buttonState4 = digitalRead(buttonPin4);
//Get present position of DXL
a=dxl.getPresentPosition(DXL_ID);
a2=dxl3.getPresentPosition(DXL_ID3);
if (buttonState1 == 0 && buttonState2 == 1) { // First button
a=a+100;
dxl.setGoalPosition(DXL_ID, a);}
else if (buttonState1 == 1 && buttonState2 == 0) { // Second button
a=a-100;
dxl.setGoalPosition(DXL_ID, a); }
if (buttonState3 == 0 && buttonState4 == 1) { // First button
a2=a2+50;
dxl3.setGoalPosition(DXL_ID3, a2);}
else if (buttonState3 == 1 && buttonState4 == 0) { // Second button
a2=a2-50;
dxl3.setGoalPosition(DXL_ID3, a2);}
}
The hardware Figure can be seen here
I am really not sure where the actual problem is… as the code seems fine and moreover it is working. The problem is only that sometimes DYNAMIXEL stops for just Milliseconds and I couldn’t figure out why this is happening. Any suggestions would be appreciated.
Thanks a lot.