2016-05-16, 17:38
Had a lot of success with modifying the cycle computer code. It gives a very accurate reading of the time between pulses from the reed switch and the output can be scaled to whatever is required.
I then began combining the servo control with the reed switch output without any success. This turned out to be due to the servos pulse width modulation and the reed switch timer both being assigned to timer 1. I looked up some code for controlling the servo using timer 2 instead. With this perfected I tried combining all the code together and this time with great success.
I'm using the wheel rpm reed switch at the moment and the servo position is simply the output from the reed switch timer. I've scaled it so that in full overdrive the cadence is about 60rpm. Then to give a bit of adjustment I've added the pot value scaled so that it various above and below 0.
There's still a bit of fine tuning to do. The output of the reed switch timer often goes high at very slow speeds. The servo position value needs to be given limits so that the servo isn't driven beyond the limits of the cables. I'd also like to use the switch on the handlebars to change between manual and automatic modes.
A test ride soon revealed that it works amazingly well, can't really believe how well. It can keep up with the shifting and accurately despite the timer output being once a second.
Here's a short video of it working with the bicycle stationary and the wheel off the ground.
I then began combining the servo control with the reed switch output without any success. This turned out to be due to the servos pulse width modulation and the reed switch timer both being assigned to timer 1. I looked up some code for controlling the servo using timer 2 instead. With this perfected I tried combining all the code together and this time with great success.
I'm using the wheel rpm reed switch at the moment and the servo position is simply the output from the reed switch timer. I've scaled it so that in full overdrive the cadence is about 60rpm. Then to give a bit of adjustment I've added the pot value scaled so that it various above and below 0.
There's still a bit of fine tuning to do. The output of the reed switch timer often goes high at very slow speeds. The servo position value needs to be given limits so that the servo isn't driven beyond the limits of the cables. I'd also like to use the switch on the handlebars to change between manual and automatic modes.
A test ride soon revealed that it works amazingly well, can't really believe how well. It can keep up with the shifting and accurately despite the timer output being once a second.
Here's a short video of it working with the bicycle stationary and the wheel off the ground.
- Oran