Shop OBEX P1 Docs P2 Docs Learn Events
Bicycle Speedometer & timing loops — Parallax Forums

Bicycle Speedometer & timing loops

ArchiverArchiver Posts: 46,084
edited 2000-08-04 04:55 in General Discussion
"Tyson Stephen" <tysonstephen@h...> wrote:
>this is my thought on how to get my calibration value, I have an lcd and
>what I am doing is outputing the value of x on it and every time it goes
>into the calc subroutine it adds to a tmp varaible and everytime the tmp
>variable reaches 65535 it adds 1 to tmp2 variable. I am going to ride
around
>a school track which is a known distance of 400m so apporx 200
revolutions..
>then I will take how many "loops" the entire 400m took... from that I
should
>be able to break it down into a per meter measurement... will that
work?...
>I am not looking for perfect just yet.. I will work on perfecting the
>calibration after I have a good working model then I will tweek it.... but
I
>think that will work...

That should work to calibrate the odometer. But the speedometer takes a
time measurement, too. Have someone with a stopwatch time how long it
takes you to zip once around the track. Then divide the track length by
the lap time to get your actual average velocity. Compare that to the stamp
speedometer reading. The trick there is for you to keep going at an
absolutely steady pace around the track. Keep looking at your stamp
speedometer reading as you go around and keep it constant (or "use the
force, Luke"). Say the actual average speed from the stopwatch turns out
to be 10 kmph, and the stamp speedometer reads 12 kmph, then you have to
multiply the numerator in the stamp equation by 10/12.

For comparison, I took another quick look at the two tight timing loops on
a BS2:

x var word
loop1: ' 1418 loops per second, 7.05E-4 seconds per loop
x=x+1
branch in0,[noparse][[/noparse]loop1] ' count until in0 goes high

loop2 ' 1426 loops per second, 7.013E-4 seconds per loop
x=x+1
if in0 then loop2 ' count until in0 goes low

I had thought that the BRANCH syntax would be faster, but that is not so.
The IF syntax wins by a hair (FWIW). Does anyone on this list know of a
tighter timing loop?

-- Tracy Allen
Electronically Monitored Ecosystems
http://www.emesystems.com
Sign In or Register to comment.