Dynamixel MX-106T (2.0)+OpenCM9.04+Arduino IDE_Extended Position Control Mode+Current limit

Hi everyone, I am using MX-106 ((2.0) connected with OpenCM904 and Dynamixel2Arduino library to upload the code using Arduino IDE. Here I want to set/limit the current of the MX (as to control the torque) under extended position control mode but it doesn’t work. I am trying with this below code;

void setup() {
  // put your setup code here, to run once:
  DEBUG_SERIAL.begin(115200);
  dxl.setPortProtocolVersion(2.0);
  dxl.begin(57600);
  dxl.scan();

  // Turn on torque
  dxl.writeControlTableItem(TORQUE_ENABLE, DXL_ID, 0);

  /* set velocity(speed) mode */
  // MX2.0, X serise
  dxl.writeControlTableItem(OPERATING_MODE, DXL_ID, 4);
  
  // AX~MX
  //dxl.writeControlTableItem(CONTROL_MODE, DXL_ID, 4);
  
  // Turn on torque
  dxl.writeControlTableItem(TORQUE_ENABLE, DXL_ID, 1);
}
/*************************************************************/  
void loop() {
  // put your main code here, to run repeatedly:
  Serial_print();
  dynamixel();
}
/*************************************************************/  
 void Serial_print(){
 currT=millis();
  if (currT-prevT>200){
  Torque=dxl.readControlTableItem(PRESENT_CURRENT, DXL_ID);
  prevT=currT;
    torque=(Torque/2047)*100;
    Serial.print("Torque= "); Serial.print(torque);Serial.println("% ");
  }
 }
 /*************************************************************/  
 void dynamixel(){
     
  // MX2.0, X serise
  dxl.writeControlTableItem(PROFILE_VELOCITY, DXL_ID, 40); //for Mx(2.0)
  if(dxl.writeControlTableItem(CURRENT_LIMIT, DXL_ID, 200))
  {  
  dxl.setOperatingMode(DXL_ID, OP_EXTENDED_POSITION); 
  if(dxl.setGoalPosition(DXL_ID, -10000)){
     delay(5000);
  }
  }
  dxl.writeControlTableItem(PROFILE_VELOCITY, DXL_ID, 20); //for Mx(2.0)
  if(dxl.writeControlTableItem(CURRENT_LIMIT, DXL_ID, 300)){
  dxl.setOperatingMode(DXL_ID, OP_EXTENDED_POSITION);
  if(dxl.setGoalPosition(DXL_ID, 10000)){
     delay(5000);
  }
  }
 }

It would be great if anyone can suggest me or correct me. Thanks in advance to all.

It might be because your trying to change settings that are in the eeprom areas while torque is enabled.

Check the control table here MX-106T/R(2.0)

Try disabling torque then changing the settings then enabling torque or alternately using R-wizard to setup the dynamixel first then use it in your program :slight_smile:

1 Like

Yes, the Current_Limit is in the EEPROM area, and I have also tried while torque is disabled but doesn’t work. Goal_current is also not working under extended position control mode.

 void dynamixel(){
     
  // MX2.0, X serise
  dxl.torqueOff(DXL_ID);
  //dxl.writeControlTableItem(CURRENT_LIMIT, DXL_ID, 2);
   delay(10);
  dxl.setOperatingMode(DXL_ID, OP_EXTENDED_POSITION);
   dxl.torqueOn(DXL_ID); 
    dxl.setGoalCurrent(DXL_ID, 10, UNIT_PERCENT);
    dxl.writeControlTableItem(PROFILE_VELOCITY, DXL_ID, 40); //for Mx(2.0)
  if(dxl.setGoalPosition(DXL_ID, -10000)){
     delay(5000);
  }
  dxl.torqueOff(DXL_ID);
  dxl.writeControlTableItem(CURRENT_LIMIT, DXL_ID, 3);
  delay(10);
  dxl.setOperatingMode(DXL_ID, OP_EXTENDED_POSITION);
  dxl.torqueOn(DXL_ID);
  //dxl.setGoalCurrent(DXL_ID, 10, UNIT_PERCENT);
  dxl.writeControlTableItem(PROFILE_VELOCITY, DXL_ID, 20); //for Mx(2.0)
  if(dxl.setGoalPosition(DXL_ID, 10000)){
     delay(5000);
  }
  }

The servo is rotating in between these limits (10k~-10k) while velocity is controlled. However the current is maximum, I am unable to control it even after disabling the torque.

I can setup the dynamixel using Wizard, but here I am trying to control its torque (user controlled) through button in steps like 30, 50 or 80 percent torque.

Here is the same type of sketch for protocol (1.0) to control the torque using Torque_limit

// MX1.0, 
  dxl.writeControlTableItem(MOVING_SPEED, DXL_ID, 100); 
  if(dxl.writeControlTableItem(TORQUE_LIMIT, DXL_ID, 1000))
  {  
   dxl.setOperatingMode(DXL_ID, OP_EXTENDED_POSITION); /
  if(dxl.setGoalPosition(DXL_ID, 10000)){
     delay(5000);
  }

We can control the torque for protocol 1, however I am still struggling to control the torque for MX protocol 2.

Ok I have the CM-550 controller which is programmed in Micropython so I a not familiar with the ardunio fuctions. I have different servos too but have successfully changed settings in the eeprom area from software by disabling torque then setting it then re-enabling torque from my micropython code.

Things that I can suggest

disable torque

this is the line of code that isn’t working for you

dxl.writeControlTableItem(CURRENT_LIMIT, DXL_ID, 3);

current limit is at address 38 for the MX-106T/R and has a value range of 0 - 2047

It is possible the include header your using may have the wrong definition for CURRENT_LIMIT

so replace the line of code with this

dxl.writeControlTableItem(38, DXL_ID, 3);

then re-enable torqure

1 Like

Hello @RATHORE, thank you for your question and for creating this post on the Community Page. Based on what you’ve shared, I believe you may just need to change the exact setting that you are using.

If you read the description of Current Limit for MX-106 (2.0) in the e-Manual, you will see that it is only used to limit accepted values that can be written to Goal Current. To limit the current used for motions, you will most likely want to use Goal Current

Let me know if this helps with the issue you’re seeing or whether you have any questions!

2 Likes

I couldn’t make it done I will try again for this to control the current in eeprom area rather than using the GoalCurrent. In other case I will setup the dynamixel using Dynamixel Wizard.

I tried this code and it seems I have the same results as before.

dxl.torqueOff(DXL_ID);
  dxl.writeControlTableItem(38, DXL_ID, 3);
  delay(10);
  dxl.setOperatingMode(DXL_ID, OP_EXTENDED_POSITION);
  dxl.torqueOn(DXL_ID);
  dxl.writeControlTableItem(PROFILE_VELOCITY, DXL_ID, 20); //for Mx(2.0)
  if(dxl.setGoalPosition(DXL_ID, 10000)){
     delay(5000);
  }

After trying a lot, I noticed I am unable to control the Current_limit however, what I learned, I can set the GoalCurrent using operating mode (OP_CURRENT_BASED_POSITION) and this works for extended position control mode too. Furthermore, I tried Current_limit with it but failed as it didn’t work like before.

The problem is I am unable to set the Current_Limit in the eeprom area I tried many ways but failed I don’t know where I am mistaken.

Yes, I think Current_Limit can’t be used the same way like I tied Torque_limit for protocol (1.0) as;

Yes the Current_Limit only works when the GoalCurrent is used, otherwise it won’t limit the current and the torque can be find at maximum limit even after setting the Current Limit (what I experienced and I am not sure).

Yes GoalCurrent worked for me.

Yes it is working using GoalCurrent but I think we are unable to limit the current using Current_limit alone.