UPDATED v1.1 code (30/05/2018)
Improved the pulse conversion from the throttle
Improved the pulse replication from the pedal
So, with the kind help from Tony at Wooshbikes.co.uk I've been able to complete this little project. He supplied a thumb throttle and a replacement DH Sensor which is the 12 magnet type on these Carrera bikes. The original PAS DH sensor on my bike was faulty which is why I needed a replacement. You can just use the original if it's working.
If I were to do it again I would most likely go for a throttle grip rather than a thumb one, as it would be easier to fit. If you are going to use a thumb throttle then you can only fit one of the left side as the right you have the gears and they get in the way.
To complete this little project I used
Arudino Nano v3 (eBay etc.. )
Thumb accelerator (Wooshbikes.co.uk)
Replacement PAS - pedal assist sensor (Wooshbikes.co.uk) only require as my original one was broken
Below is the diagram for wiring it all up.
All the above does is generate a pulse which would normally come from the pedals. I've coded it so you can still use the pedals if the throttle isn't being used.
Please test before adding power from your controller... I tested mine in the Arduino serial monitor and it should output as..
No output when nothing is happening.
On low throttle you should see around 550.
On full throttle you should see around 80.
No throttle but moving pedals - see text pedal round..
If you see any other values you may need to adjust the range. This is done in the following lines....
pulseoff = (510 - (val / 1.4))+220;
This seems to output a range of 70 - 580.. 580 is when the throttle is off, anything above 560 is ignored. (works in reverse).
Any questions please ask away
Hope this comes in handy for others.
Video below was before I recieved the throttle from wooshbikes.. just a proof of concept.
3D printed Arduino Nano temp case
Steve
Improved the pulse conversion from the throttle
Improved the pulse replication from the pedal
So, with the kind help from Tony at Wooshbikes.co.uk I've been able to complete this little project. He supplied a thumb throttle and a replacement DH Sensor which is the 12 magnet type on these Carrera bikes. The original PAS DH sensor on my bike was faulty which is why I needed a replacement. You can just use the original if it's working.
If I were to do it again I would most likely go for a throttle grip rather than a thumb one, as it would be easier to fit. If you are going to use a thumb throttle then you can only fit one of the left side as the right you have the gears and they get in the way.
To complete this little project I used
Arudino Nano v3 (eBay etc.. )
Thumb accelerator (Wooshbikes.co.uk)
Replacement PAS - pedal assist sensor (Wooshbikes.co.uk) only require as my original one was broken
Below is the diagram for wiring it all up.
All the above does is generate a pulse which would normally come from the pedals. I've coded it so you can still use the pedals if the throttle isn't being used.
Please test before adding power from your controller... I tested mine in the Arduino serial monitor and it should output as..
No output when nothing is happening.
On low throttle you should see around 550.
On full throttle you should see around 80.
No throttle but moving pedals - see text pedal round..
If you see any other values you may need to adjust the range. This is done in the following lines....
pulseoff = (510 - (val / 1.4))+220;
This seems to output a range of 70 - 580.. 580 is when the throttle is off, anything above 560 is ignored. (works in reverse).
Code:
// Wrote by CdRsKuLL 30th May 2018 v.1.1
// Updated pedal code to match input when throttle not being used.
// Updated range as it was stalling the motor at to fast.
// Please have fun but always test the output before connecting it the the bike.. safety first!!
// http://diyrc.co.uk http://wooshbikes.co.uk
int throttlePin = 0;
int pulseoff = 600;
int pulseon = 0;
int val = 0;
bool pulse = false;
bool throttle = false;
int pedalin = 2;
unsigned long startMillis;
unsigned long currentMillis;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(pedalin, INPUT);
digitalWrite(LED_BUILTIN, LOW);
attachInterrupt(digitalPinToInterrupt(pedalin), pedalon, CHANGE);
startMillis = millis();
Serial.begin(9600);
}
void loop() {
currentMillis = millis();
val = analogRead(throttlePin);
pulseoff = (600 - (val / 1.7)) + 120;
pulseon = int(pulseoff / 3);
if (pulse == false) {
if (pulseoff < 550) {
if (throttle == false) { //removes the halfsecond possible delay on first start up.
digitalWrite(LED_BUILTIN, HIGH);
throttle = true;
pulse = true;
} else {
if (currentMillis > (startMillis + pulseoff)) { //send pulse
digitalWrite(LED_BUILTIN, HIGH);
Serial.println(pulseoff);
pulse = true;
startMillis = millis();
throttle = true;
}
}
} else {
throttle = false;
}
} else {
if (currentMillis > (startMillis + pulseon)) {
pulse = false;
digitalWrite(LED_BUILTIN, LOW);
}
}
}
void pedalon() //Called when pedal is moved
{
if (throttle == false) { //Only passes signal if throttle is not being used, otherwise ignored.
if (digitalRead(2) == HIGH) {
digitalWrite(LED_BUILTIN, HIGH);
} else {
digitalWrite(LED_BUILTIN, LOW);
}
Serial.println("pedal round..");
}
}
Hope this comes in handy for others.
Video below was before I recieved the throttle from wooshbikes.. just a proof of concept.
3D printed Arduino Nano temp case
Steve
Last edited: