E-bike Project – Preventing Braking When Speed Exceeds Set Velocity

Hi everyone,

I’m working on an e-bike project using SimpleFOC. I’m currently using velocity control, and it works well in terms of reaching the desired speed. However, I noticed that when the bike wheel tries to go faster than the target velocity—such as when going downhill—the controller starts braking to maintain the set speed. This creates issues while riding downhill or pedalling.

Is there a way to prevent this behavior?

Would using Torque Control > FOC Current mode be a better approach for this case?

Alternatively, is it possible to update the main code to control the motor with just duty cycle, so it doesn’t actively brake when overspeeding?

Any suggestions or insights would be greatly appreciated!

Thanks in advance.

Sounds like torque control is what you want. If speed is >= target, don’t apply any torque. You’ll probably want some proportional control so the applied torque will fade out as it approaches target speed, so it doesn’t jolt forward every time the speed drops below target. Something like motor.move(speed >= target ? 0 : min(motor.current_limit, (target - speed) * factor));

But you may need to start braking when the speed gets above the maximum that your battery is capable of driving it to (voltage x kv). The motor acts as a generator, and could potentially overvolt the driver if it’s allowed to spin up to unlimited speed when going down a hill.