Formula for MPH for Given Time and Wheel Circumference
Mikerocontroller
Posts: 310
· Hi, I'm putting together a bike odometer/speedometer using a Malexis Hall-effect sensor and magnet.· I'm using a BS2 and sampling the sensor output in one second increments using the COUNT function.· I've determined the wheel circumference is 88 inches.· Can someone show me a formula to convert this information to MPH?· Can we do this with one word sized variable?· Accuracy of about 10% is OK.· Thank you
Comments
(x inches/sec) * (1 foot / 12 inches) * (1 mile / 5280 feet) * (60 sec / minute) * (60 minutes / hour) = 60^2/(12*5280) mph.
BTW, the accuracy rating you gave isn't much use. Since the BS2 works only with integers, your error will be in units of 1 mph.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
If you used a total of 5 magnets each pulse per second would be equal to 1 mph, then your equation is mph = counts.
You could also use only two magnets spaced 72 degrees apart. The time between the two pulses would be in milliseconds - so that mph = 1,000/count. Or if you want accuracy to the tenth use mph = 10,000/count.
If you just timed how long apart the pulses were in milliseconds (using just the one magnet) then your equation is mph = 5000/count.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
Post Edited (W9GFO) : 4/10/2010 8:00:21 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pi aren't squared, pi are round. Cornbread are squared!
Review the //, */, ** operators, take a look at all the math Tracy Allen has done for you, too.
If you just timed how long apart the pulses were in milliseconds (using just the one magnet) then your equation is mph = 5000/count.
Something like this:
DO
repeat while pulse = 1 ' do nothing while waiting for magnet to pass
repeat while pulse = zero ' start timing
count = count + 1
PAUSE 1
mph = 5000/count
count = zero
DEBUG mph
LOOP
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
mph = 5000 / trev
That is, if it takes 1/2 second for one revolution, you are going 10 mph. Here is some more tutorial on Stamp timer loops:
www.emesystems.com/BS2speed.htm#longpulse that shows how to convert the Stamp's loop timing into milliseconds that you could plug into trev. If you want to display to units of 0.1 mph, then,
mph1 = 50000 / trev ' one more digit in answer.
DEBUG DEC mph1/10, ".", DEC1 mph1, " mph",CR ' displays as xx.x mph
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
http://cgi.ebay.com/LCD-Bike-Bicycle-Computer-Odometer-Speedometer-9704_W0QQitemZ200442731209QQcmdZViewItemQQptZLH_DefaultDomain_0?hash=item2eab515ac9
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
A few years back I built a bicycle speedometer using an 8051, a reflective opto sensor, and 2 retro reflectors mounted 180 degrees apart on the rear wheel. For half of a rotation it incremented a counter, for the other half rotation it calculated and displayed speed based on the count, and recorded the speed along with several other readings. The initial calibration was done by measuring the frequency of the count loop with a meter and verified with a sports radar gun and elapsed timer.
Post Edited (Mikerocontroller) : 4/12/2010 12:38:08 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."