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.
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
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.
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.
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
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.
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.
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.