EBike / EScooter motor controller, easy to DIY build and repair, with room for custom electronics board

That’s a nice project you can solder at home with components from Mouser, Amazon or Aliexpress. Very interesting. Also I like the solder bar buildup on the back.

Regarding regen braking. Im not sure the lib. has integrared a regen algorithm yet. If the controller uses 6pin pwm commutation, then it should be possible. Se the link I posted here: NXP MCU - High Currents during align - #16 by runger

Basically you use the motor and controller to create a boost circuit.

In my opinion it will need a voltage “sensor” voltage devider to ensure stable boost voltage.

Naturally if the controller communicates with the BMS, then the BMS could also tell about actual charging voltage. There might be a voltage drop on the cables.

Edit: Usually a BMS will have a current sensor, at least it should have IMO, so communicating with the BMS could be usefull. Other factors like State of Charge (SOC), battery temperature and the likes would also be useful for a rugged system.

Regarding the regen, yes, it does regen. This board / firmware were tested on a M365 EScooter and there is regen braking when you apply the brake. The motor can rotate to both sides, if the user sets the motor iq_current positive the motor will rotate forward and if suddenly put a iq_current negative, the motor will brake until 0 speed and then will move backwards.

@casainho That´s really cool. Do you think its possible to migrate the regen algorithm to SimpleFoc?

I am not the motor firmware developer, I am mainly being helping on the EScooter M365 firmware, that includes the motor firmware as a module. So, I can not help on the question you ask. I only can share the source code of the motor firmware, in the hope it can help SimpleFOC developers: GitHub - EBiCS/EBiCS_motor_FOC: Motor control firmware implementing FOC for STM32F103

1 Like

Here are the images of fully assembled last version (v0.5_2022-03-19). Well, is missing / yet to be assembled, the battery wires as also the BIG capacitor on the battery wires.

The board needs to be a slightly larger to have more room for the hall sensor connectors / red capacitors and that 3 big capacitors.

The board was not yet tested, I will test it probably on next days:


What is the ide program use, I tried yours but no success.

Hi, this looks to be an awesome project ! I plan to prototype a kind of over board using 2 M365 wheels. Your extensible design would allow me to add a custom “shield” with the accelerometer on top of the STM32. I have a couple of questions:

  • You mentioned that you were going to test this last version. Did it work as expected ?
  • For my prototype I would need an accurate control of the wheels, torque and slow motion. Do you foresee any issue with your ESC ?
  • The “bluepill” STM32F103 looks to reach its end of life, and replaced by the “blackpill” STM32F402. The pins location is not exactly the same. Do you plan a “blackpill” version of your ESC ?