This project is a bicycle computer that includes velocity monitoring, calorie computation, an audio/visual alarm, and a wireless remote.
Bicycles are great for transportation as well as exercise. Unfortunately, many bicycles across campus and around the world are stolen everyday. We designed a computer that would deter someone from stealing the bicycle while also providing information useful for exercise and transportation. Our computer provides information to the user that includes elapsed time, current velocity, and calories burned. The bicycle has a wireless remote which allows the user to lock and unlock the bicycle (you can also use the computers terminal on the handle bars to lock the bicycle). In the event someone attempts to sit on or move the locked bicycle an LED will flash and an alarm will sound, bringing attention to the event and allowing anyone in the area to intervene.
High Level Design
Rationale and Source of Project Idea
Bicycles are used around the world for transportation, leisure and exercise. Bicycle computers can help aid the desired use by giving additional information to the user while they are biking. Bikes are also stolen all the time, much to the dismay of the owner. We decided to create a computer that would give useful information to the user while they are riding, and also protect itself in some way from theft when it is left unattended. The wireless communication device was added out of curiosity and as the ultimate addition to any nerds set of wheels.
The mathematically intensive part of this project is the portion that calculates the velocity, distance and the calories burned.
To calculate the velocity of the user, a magnetic sensor was placed near the axis of the rear wheel. Attached to the wheel itself (and thus free-moving) is a magnet that, as the wheel spins, will pass directly alongside the magnetic sensor.
The circumference of the bicycle wheel we used was found to be approximately 81.75 inches, which is equivalent to 2.07645 meters. Calculating the average velocity is then found by counting the number of times the magnetic sensor sees the magnet, which gives a pulse to the microcontroller. The number of revolutions is multiplied by the circumference, and it is only a matter of converting into miles per hour. The velocity is also calculated in meters per second for calculating the number of calories burned.
This scheme was very inaccurate, so a different method was used to calculate the velocity, where the pulse to pulse length is determined to calculate the velocity. By doing so, the velocity can be calculated by dividing the circumference by the time length of the pulse. Using this methodology, the formula is
where C is the circumference of the wheel in miles and t is the time length of the pulse in hours. With all the conversion factors in place, the equation would be
where t is in milliseconds and C is in inches.
The distance traveled is calculated simply by adding the circumference C every time the magnet is detected by the sensor.
The number of kilocalories burned is determined by the basic kinetic energy equation:
where EK is given in joules, m is in kilograms, and v is in meters per second. In order to calculate the number of Calories (i.e. kilocalories) burned, the user must enter his or her weight in pounds. The microcontroller then converts this weight into mass in kilograms via the conversion factor 1 kilogram per 2.2 pounds. As the velocity is continuously updated, the number of Calories burned is also updated by using the equation above and the conversion factor 0.239 kilocalories per kilojoule. The final equation turns out to be
where w is weight in pounds, C is the circumference of the wheel in inches, and t is the pulse length in milliseconds.
The program has two different state machines: a small debouncer state machine, which determines when a button is actually being pressed or not, and a global state machine, which determines what is currently being shown on the LCD display. There are eight different states, defined in the enumeration state.
The state machine is fairly circular, with transitions in the outer loop based on the user decision to press the left button or the right button. The transitions from any state to the LOCKED state can be done by pressing the remote control. The transition from LOCK to LOCKED can also be done by pressing the OK button. After the system is �unlocked�, that is, when it leaves the LOCKED state, it always enters the DISPLAY TIME state.
With this, the update function is called continuously (once every 100 milliseconds), and if the proper buttons are pressed, then the function updateState is called to perform the state transition.
Another state machine is implemented in the debouncer function, which performs debouncing of the buttons to ensure that there is minimal noise with button presses and releases. The code for this portion of the project is credited to Professor Land. Slight modifications were implemented to make the debouncing inputs easier to change by using a #define call.
Hardware and software tradeoffs
In implementing the wireless transmitter and receiver, instead of using another microcontroller to transmit data, an encoder circuit was used. This served to reduce the budget by allowing us not to buy another microcontroller unit and coding a protocol for encoding into it. The decoding of the signal was also done in hardware instead of software, to facilitate use of the microcontroller resources and perform tasks that were extremely difficult to implement using pure hardware. Using the decoder circuit allowed the signal from the encoder to reach the microcontroller as a digital high signal instead of a stream of data.
Similarity to Other Designs
We found bike computers online from about $15 to $85. They offered many different options including current velocity, average velocity, max velocity, odometer, timer, altimeter, and a compare with the average to see if you are keeping pace with yourself. We also found a bike alarm called bike guard that comes with a wireless remote and has a siren that goes off if the bike is disturbed. We werent able to find any products that included everything compiled into one product.
The software was fairly simple to write. Our major problems were encountered when the hardware (i.e. the STK500s in lab) did not work as intended. The first instinct was to check the software thoroughly before figuring out that the hardware was giving us grief.
A nice little trick in the software is blinking the digit that is currently being edited. This is done when the user enters in the password to unlock the bicycle.
A tricky part to write was the portion that determines the pulse to pulse length of the magnetic sensor. It was important to realize that not setting a finite timer to deem no pulse would result in overflow. The original idea was to continue counting until another pulse appears, and use that time length in calculation, but the bicycle could be stopped, so that another pulse could be indefinite.
Another tricky part to write was the portion that causes the piezoelectric transducer to emit a sound. Timer2 was set up for the general frequency, and it would flip a bit if a flag was set. To implement beeps, another task had to be written that would turn the flag on or off depending on how long the beep is and how long the pause between beeps would be. This task is run continuously, and beeping would occur if a special global variable called numBeepToggles is set to a value. The number of actual beeps is approximately half of this value.
The bicycle is just a basic male bicycle with 26 tires and 21 gears. The bike also had a seat cushion which we used to hide the contact sensor.
|Transmitter RCT-433 Pin 1||$4.00|
|Misc. Passive Components||$1.00|
For more detail: GoConn Bicycle Computer Using Atmega 32