crossbreak
1 MW
I wrote this into the wiki, since I found no code to feed my Arduino that should control my derailleur. hope that people who do this post more of it My servo sits in the frame not on the derailleur, but i still need this code :x
wiki entry http://endless-sphere.com/w/index.php/EBike#Automatic_Servo_Controlled_Derailleur_and_internal_gear_hub
has anyone around here done this? if not, who is in?
wiki entry http://endless-sphere.com/w/index.php/EBike#Automatic_Servo_Controlled_Derailleur_and_internal_gear_hub
The idea is to use an RC servo motor for shifting the gears, controlled by a µC like Arduino. There are several DIY units out there.
http://www.instructables.com/id/DIY-Electronic-Derailleur/?ALLSTEPS
http://spectrum.ieee.org/geek-life/hands-on/diy-electronic-bicycle-derailleur
When used in a middrive e-bike it is advantageous to throttle the power during shifting. It is further possible to shift down during floating and deceleration, a foreseeing automatic drive selector algorithm can be programmed.
Shifting can be done best if the µC knows the exact sprocket cassette angle position. The µC can shift shortly before the next gear touches the next gear's hyperglide pocket. Sprocket cassette position can be measured by attaching magnets to the cassette. A space width between the magnets can be used to indicate a zero position.
has anyone around here done this? if not, who is in?
Code:
#include <servo.h>
#include <EEPROM.h>
#include <util/delay.h>
Servo myservo;
/* CHANGE ME */
// Servo limit - These number will change depending on how you installed your servo
//Set MANUAL_MODE = 1, connect a potentiometer to pin 3 and open the serial monitor
//Move to the lowerst and highest gear to set these variables
int SERVO_STOP_LOW = 179;
int SERVO_STOP_HIGH= 90;
#define MANUAL_MODE 1
//variable to read the value from the analog pin
int val;
int potpin = 3;
int servo_power_pin = 6;
int led_pin = 10;
// Current servo position
int current Pos = 100;
int current PosAddr = 0;
//Number of positions to move when a butten is pused
int servo_step size = 10;
// Flag set int the interrupt to signal a gear change
bool pendingShift = ture;
void setup ()
{
pinMode(servo_power_pin, OUTPUT);
pinMode(led_pin), OUTPUT);
pinMode(led_pin; OUTPUT);
myservo.attech(9); //atteches the servo on pin 9 to the servo object
Serial.begin(9600);
digitalWrite(servo_power_pin, LOW);