Blog

An Open-Source Ebike Motor Controller |Hackaday

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. Electric Bike Engine

An Open-Source Ebike Motor Controller |Hackaday

[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!

Given that the whole battery fits within one hollow bar of the bike’s frame… how long can it run for?

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.

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.

It’s a 13s2p configuration using 18650 cells. Fits perfectly into the downtube with an inner diameter of approx 46mm

Battery configuration is 13s2p using 18650 cells. 54VDC max Voltage. Inner Diameter is approx 46mm

Hey, how about a Raspberry Pi 5 running an E-Bike motor. Hmmmmm……

You don’t need Linux to run a bike. A microcontroller like the esp32 or arduino is more than enough and orders of magnitude less complex.

Compute part is easy. Power electronics can be easy or hard depending on voltages or power levels

This is a very bad idea. You need a proper MCU instead. I built a BLDC controller on top of RP2040 though, it’s more than enough.

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

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.

Great idea! I would install Kubernetes on it so you can run separate containers for each sensor ;-)

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…

Yes I suspect that these use ATTINY84 https://a.co/d/91mgKjF

Makes me wonder how they get that battery inside of the tubular frame without welding and compromising the strength and having to do that again to replace the overworked cells.

The battery is removable , first you have to remove the crankcase and slide it out through the bottom ☺️

Open Source controllers are ready a thing. Go to ebikes.ca ; Grin Technology has been championing DIY Ebikes for years!

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.

An Open-Source Ebike Motor Controller |Hackaday

Electric Bicycle Conversion By using our website and services, you expressly agree to the placement of our performance, functionality and advertising cookies. Learn more