Mechanical spring simulated via Dynamixel motor

ROBOTIS Software

Dynamixel Wizard 2.0 and dynamixel SDK using Python 3

Control Environment

DYNAMIXEL XM540-W270-T connected via U2D2 (and power hub connected to a 12V 7.5A power supply) to Windows 11.

Software Description

I want to use the motor to create a force feel unit for the pedals of a flight simulator. In the specific, I want to simulate a mechanical spring with the motor and, adjusting the damping of the movement.
To create this function, I plan to use Python 3 with the Dynamixel SDK library, but before I’m conducting various test with the program Dynamixel Wizard 2.0 to understand the operating modes of the motor.

Issue Description

To reach my goal I tried two operating mode but both with pros and cons:

Current control mode: I wrote a small script in Python that based on a given position it compares the actual position of the motor horn, and It output a proportional current to come back to the given position. The program simulate a spring quite well but when I move the motor horn slowly the response of the motor is given in “steps”, see in attachment the plot of the commanded current/used current and the position/commanded position. The response should be linear and with no steps (like a real spring).

Position control mode: For this operating mode, I reach the same result using the dynamixel wizard program and in python. First I commanded a position that the motor should hold (goal position) and then I set the feedforward gains and the I,D gains to 0 to control the motor only via the P gain. By doing so, I realise that the value of “profile acceleration” and “profile velocity” do not influence the response of the motor when I try to turn it (with a small P-Gain (circa 120)). Another thing that I realise is that if I put all the gains to 0 and enable the torque, turning the motor horn result be difficult (movement really damped) and when the load is released the horn stay still, from the block diagram of this operating mode this should not happen, if I correctly understand the motor should move freely when all gains are set to 0 because the controller do not have any possibility to generate a current to counteract the user movement (but apparently this is wrong).
With this operating mode I don’t have a “step” response, but the response is not linear for the first part and when I release the pedals (depending on the P-Gain that I set, for example 120) the horn return very slow to the goal position (and with a steady state error, probably due to the lack of the I-Gain, the problem with the I-Gain is that if I hold the motor horn in a position that is not the goal position the force to hold that position will increase over time and that is not what I wanted (not like a real spring).
In attachment I upload also two screenshot for this operating mode.

I think that this damping effect affect also the motion in current control mode, what is/are the cause? How can I control this damping effect (are there any parameters that can I change?)/remove completely?

Another problem that I found out (more in current control mode) is that when I move manually very quick the motor horn for a small period of time the motor generate a back current and a back voltage that put my power supply in safety mode blocking the flow of current. How can I minimise this behaviour ?

To conclude, for my application with operating mode work the best, and how should I approach it?
I hope that I was enough clear, thanks for the support!

Additional Information/Attachments

read/write of motor parameters from python to the motor are made as quick as possible (every 3-4ms).

  1. Current Control Mode is almost certainly your best option for implementing this without having to develop a complex application to handle the feedback curve.
  2. The “stepped” response curve is always present, as DYNAMIXELs operate with digital logic, rather than the analog response curve of a mechanical spring. You may be able to reduce the perception of these steps by creating a compliance curve through the adjustment of goal current with respect to the difference between goal position and actual position.
  3. The DYNAMIXEL PID controller has some additional parameters that are not adjustable by the user that affect the final motion outputs. The PID controller can be bypassed entirely by using PWM mode, but implementing this type of control using PWM mode would require the creation of your own PID controller.
  4. Voltage generation is an unavoidable consequence of backdriving. You can prevent the shutdown of your power supply by adding protective capacitors between your servos and the power supply.

Hi Jonathon, thank you very much for the explanations!
I tried to use the PWM mode to have full control and I build a P control in python. Now the movement of the motor are smooth when I push (still a bit of “steps” much better that before). If I hold the position, the force stay constant (as expected). Yet, the problem is when I release a bit the load on the motor,
I would expect a bit less force, but the force is substantially lower than expected (see attachment).

How can I solve this problem?