Final Project Update 3/19/19

The automatic 21 speed bike transmission has been completed with all planned features, except one, fully implemented and integrated. The system we created in summary reads the speed of the bike rear wheel and shifts to the appropriate gear for that speed. There are 7 gears to shift from with a minimum speed of 0.0 km/h and a maximum speed setting of 40 km/h. Note that the wheel is being demonstrated and tested without load and free spinning so the upper ranges of wheel speed are more obtainable.

The peripherals used were two PWM controlled servos, one reed switch attached to GPIO, and one laser distance sensor communicating through I2C. The servos each controlled the up shift lever and down shift lever independently to allow us to mechanically interface with the bike transmission. The reed switch was attached to the rear wheel spokes and frame to read the speed via a GPIO interrupt that stopped a timer counter when the switch was activated by the spinning magnet on the wheel. The laser distance sensor checked pedal rotation by sensing the pedal arms passing in front of it to ensure correct gear engagement and user input via pedaling.

Some design challenges we faced were mechanically mounting the devices to the bike, designing for proper bike transmission action, and real time constraints. We used compression locking hardware to mount the servos, reed sensor, and laser sensor with a metal frame constructed to hold the servos next to the shift levers and hold the microcontroller board. The hardware was made sturdy to resist the forces acting on the bike during use. The transmission of the bike requires pedaling to engage the next gear after a gear shift occurred. The laser sensor was employed to sense this while the program flow was carefully designed to accommodate edge cases such as starting from stop, quick speed changes, and gear slippage. The shifting levers overlap in arc so the program had to control the servos without collisions. The real time aspect of our project made calculating timings and ranges fairly challenging as the rate our servos turned at, the speed of the sensors, and overall program performance impacted system integrity. We did our best in software to control program flow with our grand loop to maximize responsiveness as well as tune our settings for the hardware finely. The display proved too problematic and time consuming to include so we scrapped the idea of including a LCD display in our system.

The program is structured as a grand loop that uses flags to initiate actions or block other actions from occurring. Our code utilizes all four timers all with interrupts enabled. GPIO also has an interrupt which in combination with the timers posed a risk to proper system flow. We realized early on that executing our actions in the interrupts caused poor run time and responsiveness as well as undefined behavior at times. We opted to only change flags or data variables in the interrupts to minimize their performance impact and the main grand loop contained blocks of code that activated or deactivated in response to the flags. All of the code is contained in our single main file and we imported only the MCPWM library in addition to the default LPC 4088 library.

Mathematically our program takes in the rotational period of the rear wheel in milliseconds and converts that to a speed reading given the physical dimensions of the wheel. The speed is them used to select the correct corresponding gear which is compared with the current gear setting. Logic then occurs to compare the current and optimal gear to determine shift actions to take. When a shift occurs, the program has a cool-down before the next shift to accommodate for hardware and mechanical limitations. Pedaling is required for shifts so the program also checks for pedaling between shifts and at start from stop cases.

Responsibilities shifted from the originally planned jobs for our three group members. Ultimately Chris Chan implemented the mechanical and electrical integration of the components onto the bike, the reed switch GPIO interface, the PWM servo drivers, and part of the program design. Zachary Battles worked on the overall running program with Chris, implemented the UART output interface, and did the trial testing and math behind the timings. Jacob Zamora along with Zachary implemented the I2C laser sensor drivers. The lab overall took about 200 combined hours. A demonstration video will be also be included.

Update 3/10/19

We have correctly configured the reed switch to GPIO and are able to read the speed of the bike wheel. We are currently working on outputting the data to the LCD through I2C and controlling the servos with PWM. The servos have arrived and the laser distance sensor for the pedals is currently being implemented. The physics behind calculating the speed is being fine tuned and debouncing for the reed switch is also being implemented. The speedometer component of the project should be complete by the end of next week with the servos as a later goal due to mechanical complexity of the implementation method.