E-Bike Throttle Control

Recently I converted my carbon frame road bike into an electric bicycle with a motorised front hub.  A significant challenge was to devise a method of ensuring that the carbon forks are strong enough to handle the motor torque forces.  However that’s another story. 

Apart from that, the setup is relatively simple with no special sensors other than speed sensing via the hub motor. So I decided to implement very simple controls, essentially a momentary motor on/off switch (more than one) on the handlebars, with low, medium, high speed control, set using a rotary switch. So when the on/off switch is depressed the motor is run at whatever speed is set on the rotary switch.

This setup worked pretty well but it was annoying to have to keep one of the two on/off buttons depressed to keep the motor running. So I decided to modify the control unit to latch the motor on when the on/off button was pressed for more than a few seconds, switching the motor off by a further brief button press.  The little control unit to achieve that is described here.

Essentially this is a small PCB with a Microchip Attiny85 implementing the logic. This is connected to the bike’s brushless motor control unit throttle control. The throttle control provides 3 wires, positive supply (around 4.4 volts), ground and control voltage in.  The motor speed increases as the control voltage is increased from around 2 to 4 volts.

The Attiny85 is configured to output the control voltage via a pulse width modulated pin. A resistor and capacitor is used to turn the pulse output into an (approximately) DC voltage, whose level is set by the width of the pulses.  A rotary switch is used to pull one of three different pins of the Attiny85 low, which is used to select the pulse width hence control voltage output, to achieve a low, medium, or high motor speed.

The zip file contains Autodesk Eagle schematic and board files for the small, double sided PCB as well as the Attiny85 firmware as an Arduino sketch. 


The Attiny85 needs to be running at 8MHz