An Open-Source Ebike Motor Controller

DIY e-bikes are often easy to spot. If they’re not built out of something insane like an old washing machine motor, the more subtle kits that are generally used still stand out when compared to a non-assisted bike. The motors tend to be hub- or mid-drive systems with visible wires leading to a bulky battery, all of which stand out when you know what to look for. To get a stealthy ebike that looks basically the same as a standard bicycle is only possible with proprietary name-brand solutions that don’t lend themselves to owner repair or modification, but this one has at least been adapted for use with an open source motor controller.

The bike in use here is a model called the Curt from Estonian ebike builder Ampler, which is notable in that it looks indistinguishable from a regular bicycle with the exception of the small 36-volt, 350-watt hub motor somewhat hidden in the rear wheel. [BB8] decided based on no reason in particular to replace the proprietary motor controller with one based on VESC, an open-source electric motor controller for all kinds of motors even beyond ebikes. Installed on a tiny Arduino, it fits inside the bike’s downtube to keep the stealthy look and can get the bike comfortably up to around 35 kph. It’s also been programmed to turn on the bike’s lights if the pedals are spun backwards, and this method is also used to change the pedal assist level, meaning less buttons and other user-interface devices on the handlebars.

[BB8] has been working on this for a while, and although the bulk of a working ebike controller is there, it still doesn’t support the torque sensing pedals included with this bike. We’re presuming that this is still a work-in-progress as the Arduino and associated code easily interfaces with all the other sensors available on this bike. Hopefully this open-source motor controller finds its way into other proprietary systems as well, since a lot of these ebikes can turn into massive paperweights if the companies who originally built them go out of business or simply decide to stop supporting older models. Of course, you can avoid this issue entirely by building your own ebike from spare parts.

Thanks to [Arnoud] for the tip!

18 thoughts on “An Open-Source Ebike Motor Controller

    1. Original specs say 48 V, 336 Wh and 50-100 km. The range is plausible for the energy, but I wonder how they’ve managed to fit it in such a small space.

      The specs sound like 12S 2P of 3.5Ah 18650 cells, but that doesn’t seem like it would fit a typical downtube that is maybe 70 cm long and 4 cm diameter.

      1. I agree. 336Wh in that small space just seems crazy. I modeled a similar thing in cad not too long ago with 18650s and without having a 6cm ish downtube, I couldn’t figure out where to stuff all those cells to make it work.

      1. rp2040 is the sweet spot for this. If you want anything able to do more, you can network the rp2040 esc board with something like a rpi 5, and do higher level things there, but yeah, esc itself should use something like an rp2040 or stm32 or Arduino

        1. My reasons to chose RP2040 were primarily that it’s dual-core (and the price, of course). I previously built BLDC FoC controllers on STM32 single-core MCUs (originally deriving the first design from ODrive), and the main issue was maintaining real-time communication and real-time control at the same time. It’s doable, of course, but hard and have severe limitations on communication timing, so a much cheaper and much less powerful (even no FPU) RP2040 turned out to be more suitable, allowing to dedicate one core to FoC, and the other solely to communication (10mbps RS485, multiple motors on a single bus, so precise timing is essential).

          Had to rewrite the FoC in fixed point though. Emulated FP worked well, but not for the control frequency I wanted for this particular use case.

  1. You could probably do it with an ATTiny84, even a 44 maybe. Pin count of an 85 is probably too low though, not enough to both send logic for each line of a BLDC, and monitor analogue voltages on current shunts, and monitor an encoder…

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.