Vous êtes sur la page 1sur 11

EE333

Bike Speedometer

Jose Candelario

Mitch Conrad

1
Introduction
For the final project of the year, we decided to go with the bike speedometer option that
was given to us for project ideas. We liked the fact that it was something that we could actually
use once the class was done. The bike speedometer should be able to tell the speed of the
bike at current time, but also the total distance it goes. Then it should be able to reset once the
user wants to start another bike ride.

Circuit Design
The first decision that was made was to pick a microcontroller. We chose to go Atmega
328 chip because the fact that we could use a basic Arduino kit to program it. Also, it was very
similar to C code, which we had a familiarity with.

Atmega 328 chip

We are also using four AA batteries as our power source. Due to the fact that the project would
allow the user to have manual inputs as well as inputs coming from the bike, several circuit
designs were made to allow each input to work correctly. The first input was the bike
speed. The best way to measure the bike speed would be to find the amount of times the bikes
wheel went around per second. We also need to know the circumference of the wheel to find
the speed.
Rotations/sec x Distance/rotation (circumference of wheel) = distance/second

The magnet would be place on a spoke of the bike near the wheel, where it would be easily accessible

2
The idea to find the rotations per second was to use a sensor that would pulse every time it
passed a certain part of the wheel. A reed switch is a sensor that acts like a switch when it gets
near an electric field. Normally it acts as a closed circuit. But as the magnet on the bike rung
passes by, it acts like an open circuit, giving a band gap square pulse.

Normally there would be 4.9 V at the input due to the addition of a voltage divider. But
as the circuit is opened for that split second, there would be no voltage at the input. This is the
sense of the pulse that we are creating. The atMega would take this pulse and use it to find the
speed and the distance.
The next two parts of the circuit are the two manual inputs that a user can use to help
customize the use of his or her bike speedometer. This comes in the form of two push
buttons. Each is set up the exact same way as the reed switch, except the fact that the normal
states are switched. When the push buttons are pressed, the voltage divider is closed, allowing
there to be 4.9 V at the corresponding inputs. These buttons will be used for allowing the user
to manually choose their wheel size, and reset the distance to 0.

Software Design
The chip was coded through the Arduino software.

3
The above is all of the initializations required at the beginning of the code. They are used to
keep track of numbers and counts. The LiquidCrystal header file is included here to be able to
use the lcd display. Pins 12, 11, 5, 4, 3, 2 where specifically left out for the lcd. The last two are
used to calculate distance.

In the part above we set up the inputs as well as the outputs and LCD. We had troubles getting
the LCD to work. We added the delay(1000) in order to give the LCD enough time to initiate
everything. We used pins 8, 6, and 7 for the inputs. This part also prints a friendly hello to the

4
user right away when it turns on. It also initiates the start time for measuring the speed at which
the bike is going.

Within the void loop the first thing it does every iteration is read in the values of the three inputs.
The first is read in from digital input 8 which is connected to the reed switch on the wheel. Every
time this gives us a low voltage it means that the wheel has made another full turn. The second
is input from a button. This button is used to pick the size of the wheel being used. The last
button is used to reset the total distance traveled.

The code above is used to loop around the switch statement that will be lower in the code.
Every time the button is pressed the count goes up by one hence choosing the next value. It
also manages to loop back around by going back to one if the count goes over the last switch
statement option which is 6.

The code above is plain and simple. If the second button is pressed the count of how many
revolutions the tire has taken is brought back to zero. distCount is really just counting how many
times the wheel takes a turn.

5
The code above is used to choose the proper wheel length. Every time the user presses the first
button the above code goes down to the next case and sets a new wheel size as well as print
out the chosen size unto the screen. As you saw from code before this one it continuously loops
around until the user finds the correct wheel size he/she desires.

6
This part of the code is activated every time the wheel makes a full turn. The first thing it does
within this if statement is increment the number of turns the wheel has taken. The next line
takes in the current time in order to calculate the speed of the bike. The constant is actually a
number we calculated to convert all of the units into m/h since without it and the 1000 it would
actually give us feet per millisecond. Distance is given below it by finding total amount of feet
traveled and dividing it by how many feet there are in a mile. This gives us the total amount of
miles traveled.

The last part of this if statement actually prints out the speed and the distance traveled by the
bike. It does it in both the top and bottom line of the LCD display. It also restarts the time
counter in order to measure the how long the next full wheel rotation takes.

PCB Board Design


This part of our lab is very similar to the second project. The circuit design was
recreated in MultiSim, using terminal pins for our power sources due to the fact that our power
sources were not going to be solder onto our PCB. The push button was represented by a four-
hole terminal, where both the front would be connected to the source, and the other two on the
open side of the circuit. The reed switch was designed to be a two pin terminal, where like we
said above, it would act like a switch.

7
In the picture above, the 1k ohm resistors on the side hooked up to the ground are
actually 4.7k ohm. The package was the same size so we left it the way it was. The MultiSim
was then transferred over to the Ultiboard, where the PCB board design was laid out, and the
copper lines were drawn.

The design was then converted to Gerber Files and sent to be manufactured.

8
Soldering

Designed PCB board without components

PCB board after parts had been soldered on

Soldering the components onto the PCB board was pretty straightforward. However, we
ran into some issues after we realized that we had not only designed the female pin placement
for the atmega chip to be too wide, but ran the inputs to the wrong places for the LCD pin
holder. We had to rewire the pin placement to a breadboard, where the atmega chip would be
placed. For the pin placement for the atmega chip and digital 16x2 LCD, we referred to the
corresponding data sheets for the parts.

9
Testing
Our original plan was to test out the design using the LCD screen. Unfortunately, we
had some issues actually getting the LCD screen to output anything other than a black line
across the top. We found out this was the result of bad wires that were messing with the read
write bit of the LCD. Once we did get the LCD working we did end up testing it via the output
sent to the LCD. We simulated the speed values by adding delay functions that acted as if the
wheel took longer or less to make a full turn. This allowed us to check if the math made sense
for the calculations of speed. It also allowed us to check if the reed switch actually worked.

Conclusion
Overall, our group gained good experience with this design project. We took an idea
that we had no experience in and were able to come up with a solid design concept. We
experienced some struggles, especially with the LCD screen, and there were some falls along

10
the way, but we were able to increase our knowledge of the design process. This class was
something unique at Iowa State due to the fact that what we learned is applicable to potential
designs that we could be working in the future.

Parts List
2- 1X2 female to male pins
2- buttons
1- 28 pin socket
HD44780 LCD screen
1- reed switch
1- Atmega 328 chip
3- 1k resistors
3- 4.7k resistors
4- batteries

11

Vous aimerez peut-être aussi