Matlab code for Current-based position control of Dynamixel servo

Hi all,

I am using XL330-M288-T servo. The Dynamixel website has sample MATLAB codes (suitable for different servos) for controlling its position (read_write.m). Is there any sample code available to control the servo in current-based position control mode, allowing adjustment of the position P, I, and D gains (either by Robotis or anyone)?

Also, please let me know if there is any matlab code which can be used to control the servo in all modes including current-based position control mode.

Regards,

Muhammed Sadique

Hello Muhammed,

We don’t have any available MATLAB example programs showcasing current-based position mode in specific.

The example program should actually work as-is with the actuator set to current-based position mode as well.

In order to edit any servo settings, or operate the servo in any of the supported control modes you just need to use the provided read/write functions to access the control table register governing the setting you want to interact with.

1 Like

Hello Jonathan,

Thank you for your reply.

Now I am able to use MATLAB code to operate the servo in current-based position mode. Could you please tell me how I can correlate the goal current with stiffness (torque/rad) of the servo? Does changing the goal current change the stiffness? Or is it related to torque/time?

If I need to control the stiffness, which data should I change?

Regards,

Muhammed Sadique

The goal current is used to control the output torque/current during movements and is most likely the register you’ll want to be using. However, the PWM Limit can also be used to add an absolute limit to output force, and might be useful to you if you only need to set an upper limit, but not to adjust the force during opration.

1 Like

Thank you for your reply.

The current goal is to control the torque required to return the shaft back to its initial position after being rotated by means of an external force. The higher the goal current/torque, the faster it returns to its initial position.

This is what I understand. Please correct me if I am wrong.

Could you please let me know if there is any way we can control/change the external force/torque required to rotate the shaft/horn to a specific position in current-based position mode or in any other control mode (should return the shaft to initial position by means of goal current after rotating it by external force)?

You are correct that the goal current does set the force used to rotate the horn back into position if it’s moved out of it’s goal position. In addition to this it does also define the force used to move the servo to the goal position.

1 Like

Thank you.
Could you please let me know how I can use the motor in impedance control mode?
Like in this video : https://www.youtube.com/watch?v=JnAA2EnShH8
It has spring only operational mode, which I am interested in.

DYNAMIXEL servos don’t feature a built in impedance control mode, but you could likely implement something like that using an external control solution paired with the PWM operating mode.

1 Like

Thank you.

I have one more question regarding the control of output torque by manipulating the goal current. Could you please inform me where I can find the relationship between the goal current and the output torque? The range for the goal current value is 0 to 1750. How does this range correspond to the output torque?

It was relatively straightforward to predict the angle (ranging from 0 to 360 degrees) corresponding to the position decimal value range (0 to 4096). Similarly, I would like to establish a similar relationship between the goal current and the output torque.

Thank you very much.