Can this firmware be used to control an ebike motor?

I want to control a BLDC motor on an ebike.
Is this possible with this open source firmware?
I saw on the simple FOC website that this project is aimed at low power motors, but I was wondering if the software still works with high power systems?
Speed I am looking for is 1500 rpm with a 23 pole pair motor on an ESP32.
I saw that torque control and hall sensor input is available so that is a good start.


Welcome to the forum.



I’m new to this myself. I’ve been reading the docs and running the software in ESP32, RP2040 and even the Arduino Uno. The software is more than up to this task and is just maybe a bit more sonicated than you find on most commercial ebikes.

The harder part will be the hardware. Finding driver hardware that will handle the load will not be easy, and you might have to make your own. Also, FOC requires sensors. I assume an ebike motor is run in torque mode because it is “pedal sassist” where the motor ads torque that is proportional to the torque applied to the pedals.

SimpleFOC can handle the motor control but an ebike controller also has to look at the pedal torque and the assist ratio setting and by law has to stop proving toque boost after 20 MPH

So even if SimpleFOC works perfectly there is more to making an eBike. Both hardware and more software are needed.

This is the same for my robot project, SimpleFOC seems to be working well and is easy to use (given some experience with embedded software) but there is a LOT more to a robot than motor control, likewise with an eBike.

That said, what I don’t see SimpleFOC doing is regenerative braking. Even for my robot, I’like to do something with the back EMF

Hardware is the bottleneck right now, parts availability is frustrating.

Thanks for your answer!

Indeed I am planning on making my own power stage.
I am also aware of that I need to add phase current sensors and connect the hall sensors to the processor.

Yes I want to use it like this, with a torque sensor in the pedals. I can code a bit so it should not be a problem to add the inputs, if the software can make the motor turn.

Hmm that is a feature that I have on my current bike and it is quite nice to save on brake pads. (I live in a flat area and don’t really see any range improvement with regenerative braking.)
In principle regenerative braking is not that hard to add to the software. In my other ebike it works by reducing the dutycycle to the H-bridges in the power stage. (Instead of increasing it when accelerating to keep the power draw on target.)
However, I don’t know if it is as simple as that in this software. I suspect there would be more involved.