endlessly_ending
10 W
- Joined
- Apr 27, 2013
- Messages
- 82
With this thread its my intent to trigger a DIY solution for electronic gear shifting of hub gears like the Rohloff, Alfine, Nexus or others.
To my surprise such a thing is still not available as a DIY kit / solution, though technically a rather simple thing methinks
.
So I'd like to share here my slow steps of developing hardware and software in the frame of a new e-bike build of mine, that will be composed of a stripped down gear hub motor driving a Rohloff gear hub. Pedals and motor will have their own dedicated chains, directly driving the Rohloff for both to take advantage of the gear hub. I will cover my build in a separate thread. My mechanically solutions for the electronic gear shifter will therefore concentrate on interfacing with the Rohloff Speedgear.
That's just to give some background here.

As can be seen, the Arduino code will allow for easy editing of
- gear count of what ever gear hub one wants to use
- adapting for different servo motors
- electronically fine adjusting gear one end position
- electronically fine adjusting to compensate play in the shift gear mechanics
- make use of standard RC or robot servos of any kind that can be controlled by PWM signals
As for now, my testing is limited by the restrictions of a 270° angel range of the otherwise nice Miuzei DS3218 servo
https://www.amazon.com/Digital-Waterproof-Mechanical-Fittings-Control/dp/B07NJ6SQKB/ref=sr_1_1_sspa?__mk_de_DE=%C3%85M%C3%85%C5%BD%C3%95%C3%91&keywords=miuzei+DS3218&qid=1567237901&s=gateway&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEzMFJPRkVDV0EyOEtKJmVuY3J5cHRlZElkPUEwNDEyNTgzMkNYWVUwSzdVSVNFQiZlbmNyeXB0ZWRBZElkPUEwMjAxMDU3MUo0ODg2UDM4N0MyJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==
Its not easy to find a widely available servo of moderate price, that combines a angle range of +360°, quick response with strong force and is more or less waterproof.
Nevertheless I have a Kingmax sail winch servo in the pipe, that possibly could do the trick.
To my surprise such a thing is still not available as a DIY kit / solution, though technically a rather simple thing methinks
So I'd like to share here my slow steps of developing hardware and software in the frame of a new e-bike build of mine, that will be composed of a stripped down gear hub motor driving a Rohloff gear hub. Pedals and motor will have their own dedicated chains, directly driving the Rohloff for both to take advantage of the gear hub. I will cover my build in a separate thread. My mechanically solutions for the electronic gear shifter will therefore concentrate on interfacing with the Rohloff Speedgear.
That's just to give some background here.
Code:
/*
Electronic gear shift for Rohloff Speedhub and others gear hubs
Arduino Nano V3 ATmega328 (old bootloader)
Testversion for 270° Miuzei 20kg Servo
500-2500usec => 270°
Rohloff Speedhub axle on external gear box needs a full turn of 360°
to shift from gear 1 to gear 14
360° => 27,6923° eg 27,4074usec>/° each gear => 2000usec => 500 - 2500usec
//
to shift 10 gears on Rohloff Speedhub
=> 249,231° => 27,6923° eg 27,4074usec>/° each gear => 1384,62usec => 807,69 - 2192,31usec
real calculated usec range for 10 gears on Rohloff:
808 - 2191usec due to finite INT calculation accuracy
Rohloff speedhub electronic gear shift by Arduino servo
2019 written by "endlessly_ending" at endless-sphere
*/
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include <Servo.h>
Servo motor;
//--------------------------------------------
int ButtonUp = 8; // button for up-shift connected to Arduino port 8
int ButtonDown = 7; // button for down-shift connected to Arduino port 7
int count = 1; // gear index
int LastCount; // last gear index
// int MaxGear = 14; // gear count for Rohloff Speedhub
int MaxGear = 10; // TEST setup for <270° servo => 10 gears at maximum possible
int MinGear = 1; // first gear
int GearStepUsec10; // 10x gear step usec to improve calculation accuracy
int StartGear = (MaxGear - 2); // start out at two gears down
int Motor_Stop_LED = 13; // LED indicator when motor is on halt, LED and relays connected to Arduino port 13
int AngleUsec; // index angle in usec
int AngleUsecMax; // max index angle in usec
int AngleUsecMin; // min index angle in usec
int FirstGearIndexTrim = A3; // trimmer for adjusting first gear index connected to Arduino port A3
int PlayComp = A2; // trimmer for compensating shift gear play connected to Arduino port A2
int FGIT; // variable to store the value read of FirstGearIndexTrim
int PC; // variable to store the value read of PlayComp
//--------------------------------------------
void setup()
{
Serial.begin(9600); // TEST use the serial port to print the number
digitalWrite(Motor_Stop_LED,HIGH);
lcd.begin(16, 2);
lcd.print(" initialize ");
lcd.setCursor(0, 1);
lcd.print("motor on halt");
pinMode(ButtonUp,INPUT);
pinMode(ButtonDown,INPUT);
digitalWrite(ButtonUp,HIGH);
digitalWrite(ButtonDown,HIGH);
pinMode(Motor_Stop_LED,OUTPUT);
count = StartGear;
motor.attach(9);
pinMode(A2, INPUT_PULLUP);
pinMode(A3, INPUT_PULLUP);
delay(1000);
digitalWrite(Motor_Stop_LED,LOW);
}
//--------------------------------------------
void loop()
{
// set start conditions and read status of up shift and down shift button

As can be seen, the Arduino code will allow for easy editing of
- gear count of what ever gear hub one wants to use
- adapting for different servo motors
- electronically fine adjusting gear one end position
- electronically fine adjusting to compensate play in the shift gear mechanics
- make use of standard RC or robot servos of any kind that can be controlled by PWM signals
As for now, my testing is limited by the restrictions of a 270° angel range of the otherwise nice Miuzei DS3218 servo
https://www.amazon.com/Digital-Waterproof-Mechanical-Fittings-Control/dp/B07NJ6SQKB/ref=sr_1_1_sspa?__mk_de_DE=%C3%85M%C3%85%C5%BD%C3%95%C3%91&keywords=miuzei+DS3218&qid=1567237901&s=gateway&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEzMFJPRkVDV0EyOEtKJmVuY3J5cHRlZElkPUEwNDEyNTgzMkNYWVUwSzdVSVNFQiZlbmNyeXB0ZWRBZElkPUEwMjAxMDU3MUo0ODg2UDM4N0MyJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==
Its not easy to find a widely available servo of moderate price, that combines a angle range of +360°, quick response with strong force and is more or less waterproof.
Nevertheless I have a Kingmax sail winch servo in the pipe, that possibly could do the trick.