Pages: 1 [2]   Go Down
Author Topic: Bike Computer  (Read 1883 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can always spend the extra time optimizing, never hurt to have a more effecient code
or do you know what died? If its the 8/16u2 you can still communicate if you can get a usb to serial converter or use an rs232 port
if its the atmega328 then you need a new one
if its a part on the board itself, perhaps it can me removed and replaced/jumped out
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8472
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've done all sorts of speedo  and tacho designs over the years and never needed floating point.

_____
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nobody seems to have pointed out the obvious yet that your original maths/measurement isn't correct. You're saying it's a 26inch wheel, then dividing that by 36 spokes to get the distance between spokes. Well 26 inches refers to the DIAMETER of the wheel and you are dividing by 36, suggesting you thought it referred to the circumference. You need to be dividing the circumference of the wheel by 36, not the diameter.

I'd measure the circumference manually as it will vary depending on what tyre you have fitted, but an approximation using pi would give:
3.14*660.4 = 2075mm

So you're speed calculation is out by a factor of about 3, taking your calculation of 5mph up to around 15mph which is what you wanted. Problem solved  smiley-wink

Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 162
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Heres the math for diameter in inches (26) and transforming the count N of 1 sec worth of spokes into MPH.
So,
Diameter = 26 and
T = 1.0

miles/hour  =  (N spokes / T seconds)  *  (1 revolution / 36 spokes)  *  (Diameter * Pi   inch/ revolution)  *  (1 ft / 12 inch) * (1 mile / 5280 ft) *
                    (60 seconds / 1 minute)  *  (60 minutes / 1 hour) 

MPH = N * 0.12892

You might want to update faster than 1 sec.  Since you are counting spokes (as opposed to a magnetic, once per revolution sensor) you have that luxury.
Just multiply the above constant by the number of times per second you are updating.  Ex. twice a second makes T = 0.5, effectively multiply the constant by 2 giving:

MPH = N * 0.2578

You should probably round MPH to the nearest tenth MPH with something like:

roundedMPH = (float)((int)(MPH * 10.0 + 0.5)) / 10.0;

Say N is 57 for one interval,
then MPH = 14.6946 and you display
rounded MPH = 14.7
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can always spend the extra time optimizing, never hurt to have a more effecient code
or do you know what died? If its the 8/16u2 you can still communicate if you can get a usb to serial converter or use an rs232 port
if its the atmega328 then you need a new one
if its a part on the board itself, perhaps it can me removed and replaced/jumped out

it is an atmega328.
after having it powered off for a few days, i plugged it into usb. it stayed on, led blinked twice. i hit reset led blinded twice again.
then power led faded away, and usb device went away. and atmega328 gets hot when pluggin into ext power supply. i can upload new code
until power led fades. the sketch runs as well. it gets hot enough to burn my finger and i think its shutting down because of thermal shutdown
« Last Edit: June 29, 2012, 02:29:41 am by MegaGamerGuy » Logged

Peace, Love, Light, Infinity

Pages: 1 [2]   Go Up
Jump to: