Motor.velocity_limit changes ignored in motor.controller = MotionControlType::torque;

I’m using a motor with
motor.controller = MotionControlType::torque;
and (when the motor is mechanically unloaded) trying to limit the free-running speed of the motor with changes to motor.velocity_limit inside loop.

This seems to make no difference. Is there a different approach that I should be taking ?


Hi @jarkman , welcome to SimpleFOC!

Sorry for the late answer, somehow I missed this thread…

velocity_limit is for velocity mode, you can use motor.voltage_limit to set a limit in torque voltage mode…

Hi - thanks - but what I want to do is have the thing in torque mode, but put a limit on the maximum speed it will reach. Is there a way to do that ? Won’t voltage_limit just limit the torque ?

Hey, yes, you are right, voltage_limit will just limit the voltage, and therefore the torque.

But in the torque-voltage mode, this is all that is being controlled. There is no PID controller and no concept of velocity in the control. The sensor is used for closed loop, but only for the FOC level, to determine the current position in the electrical cycle.

But for an unloaded motor, in this control mode voltage is also proportional to velocity, within the physical limits of the motor.

To achieve what you want you need a more complicated control mode. In velocity mode, you can control the velocity while limiting the torque (by limiting the voltage) or in position mode you can set positions while limiting both velocity and torque.

Thanks! I’ll go to velocity mode, as you suggest.