Bicyle Speedometer Project
luong45
Posts: 8
I'm working on a senior design project building a bicycle speedometer. I'm using a Reed switch to produce the input signal.· How would i go about processing this signal to the BS2-BOE·and measuring the time between pulses? Would i need an oscillator or a clock before the signal is being input into the BS2-BOE? Thanks in advance.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
Electronic Systems Technologies
Southern Illinois University Carbondale
Personal Links - ·Lot of BASIC Stamp info
and
SelmaWare Solutions
StampPlot Pro Version 3 Release 4
Graphical Data Acquisition for your Micro and Imagination!
Now allows additional controls to be added, or developed.
·
4 8bit latchingdrivers and a 2-to-4 decoder should do the trick
You might want a Shcmitt trigger or something on the input signal (a 74HC14 worked OK for me when I built something similar)
The problem with building something like this is that you need a reliable timebase.
(I built mine with an old PDA where I could be certain about when exactly one second had passed)
You may want to look up chips that can be used for timing. Watchdog-timers, counters and such.
You can see my project here:
http://home.c2i.net/trygveh/english/download/org2/t2bike.html
It also includes the complete sourcecode, and while it's not in PBasic, it might help show how it can be done.
Note, in my version I send the input signal into an 8bit counter and just checks that once every second so my computer could use the time to do all kinds of nifty things (like a 'last minute average speed' and so on)
My 2-cents.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
Electronic Systems Technologies
Southern Illinois University Carbondale
Personal Links - ·Lot of BASIC Stamp info
and
SelmaWare Solutions
StampPlot Pro Version 3 Release 4
Graphical Data Acquisition for your Micro and Imagination!
Now allows additional controls to be added, or developed.
·
note: i'm designating pin 0 as the input and pin 1 as the LED output
Main:
IF (PIN 0 LOW) THEN
HIGH 1
ELSE
LOW 1
ENDIF
GOTO Main
END
Jim
valued resistors.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe - Mask Designer III
National Semiconductor Corporation
(Communication Interface Division)
500 Pinnacle Court, Suite 525
Mail Stop GA1
Norcross,GA 30071
Would there be a way of doing it that expanded the range? 2.06 - 1.6 leaves only 0.46vdc between a high and perceived low. It wouldn't take much in the way of noise to create false readings. What about using a comparator like proposed by KenM in the thread http://forums.parallax.com/showthread.php?p=528895. You could reverse the +/- connections to generate the desired logic.
Jim
drop of about .6V. That way you would have close to 0v and 2V.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe - Mask Designer III
National Semiconductor Corporation
(Communication Interface Division)
500 Pinnacle Court, Suite 525
Mail Stop GA1
Norcross,GA 30071
Mike
Mike, this would be fine, but luong45's current setup for whatever reason goes form 3V to 5V....not 0V to 5V.
I did not question the 3V and 5V output, but perhaps we should ask luong45 why 3V is being generated in a LOW
condition rather than 0V. It does seem a little odd now that you mention it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe - Mask Designer III
National Semiconductor Corporation
(Communication Interface Division)
500 Pinnacle Court, Suite 525
Mail Stop GA1
Norcross,GA 30071
1) An LED at the switch to indicate switch status.· Stamp not used.
2) An LED at the Stamp, where the Stamp reads the switch status and lights the LED.
3) Both.
There is no voltage drop across the switch so he should only have 0V and 5V conditions.
-Mike
counts VAR Word
RPM VAR Word
counts = 0
DO
COUNT 0,1000,counts
RPM = counts * 60
MPH = RPM * 88 * 60 / 63360
DEBUG DEC? RPM
DEBUG DEC? MPH
LOOP
note: 88 = circumference of the wheel in inches
60 = mins per hour
63360 = inches per mile
we think it might be a syntax error but we're not sure.
Thanks in advance, i appreciate all the help and suggestions
This expression: (RPM * 88 * 60) / 63360
is the same thing as this: RPM / 12
-Mike
I decided to still use the count function however, with the use of an external oscillator, and a T-flip flop, it will count the number of pulses from the oscillator. The number of pulses counted will then correspond to a certain speed. also, i orderd a serial lcd and that will be used for the output.
I have a question about how i would program a subroutine to calculate total miles. since there is that limitation on integer math only, i'm not sure how i would go about writing this portion of hte program? I'm thinking of using a counter (not COUNT function) to increment everytime a magnet passes through the Reed switch. Since it would take awhile before you would reach a whole integer, say 1 mile or 2 mile and so forth, what about inbetween? i was hoping to display .2 or .3 of a mile. Thanks in advance.
counts VAR Word
tenthmile VAR Word
countremain VAR Word
RPM VAR Word
counts = 0
countremain = 0
tenthmile = 0
DO
COUNT 0,1000,counts
countremain = countremain + counts
tenthmile = tenthmile + (countremain/72)
countremain = countremain // 72
RPM = counts * 60
MPH = RPM /12
DEBUG DEC? RPM
DEBUG DEC? MPH
LOOP
WRT to your MPH issue, the equation for MPH given your wheel is 5/s where s is the time between pulses in seconds. This is gotten from calculating a bycicle going 1 mile/hour would have 720 pulses/hour or .2 pulses/second or 5 seconds between pulses.
The problem with using count with a 1 sec timeframe, any speed less than 5 mi/hr possible could show 0 mi/hr since a pulse may not have been captured, and speeds higher than that will have a large amount of error since 10 mi/hr means 2 pulses/timeframe,·3 pulses/timeframe is 15 mi/hr, there is no way with your code to measure speeds between 11 and 14 mi/hr, they'll all read as 10 mi/hr. To get more accurate results you should measure the time between pulse and calculate the value using the above equation, you can get away with multiplying a fraction by using the multiply middle operator */. But PULSIN cannot measure that long of a period, however you can subdivide the time period by running consecutive PULSIN commands until a value other than 0 is returned, the equation for time between pulses in microseconds is
(PULSIN overflows)*13,107 + (Last PULSIN*2)
you can keep a counts variable by incrementing it each time a pulse is received.
Post Edited (Paul Baker) : 5/4/2005 3:57:14 AM GMT
bugg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Boe-bot: $229
Toddler: $249
Learning Google is your friend: priceless
·· That's not a good example circuit, since when the reed switch closes, it will effectively SHORT the Vdd and Vss rails.· You would need a resistor inline between the Vdd and the input pin, since currently the input is always going to read high, and when the switch closes the Stamp will most likely reset due to brownout.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Unless you need to do some "background processing" of data on the stamp, using an external circuit is not nescessary, using the PULSIN method I described you can aquire extremely precise data to use. Your measuring time between pulses that at thier shortest are maybe 1/8 a second apart (40 mph) in microseconds! Thats roughly 5 significant figures of precision. Thats knowing your speed down to 1/1000th of a mph (and mileage down to the inch, though thats updated in 88 inch increments).
If there's something I know, it's that not all wheels are created equal.
I use 26" rims on my bicycle, but I can assure you that the circumference of the 1.75" tires I use in the summer is not the same as the 2.1" tires I use in the winter.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://ca.geocities.com/steve.brady@rogers.com/index.html
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
bugg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Boe-bot: $229
Toddler: $249
Learning Google is your friend: priceless
What is the purpose of the 4024 into the AND gate?
Have you thought of how to perform the COUNT to make sure you have captured the pulses of a single wheel rotation without bleeding into the next train over the entire range of speeds? For a bicycle traveling 1 mph, the wheel rotates once every 5 seconds, meaning the pulse train is 5 seconds long followed by 5 seconds of deadtime. To accurately measure this speed, your count duration needs to be at least 5 seconds and less than 10 seconds. For a bicycle traveling 40 mph (likely traveling downhill) the pulse train lasts for 1/8th of a second, if you used the same 5 second duration to count the wheel, you would be capturing 40 wheel rotations or 20 pulse trains, if you tried to calculate this using the number of pulses counted over the 5 seconds you would calculate a speed of 2 mph since the number of pulses generated by 2.5 seconds on, 2.5 seconds off is the same as the number of pulses generated by 20 pulse trains lasting for 1/8th a second each.
To accurately measure the speed, you would need to have different windows of count times to measure the speed, the stamp documents do not state if this parameter of COUNT can be a variable or not.
Post Edited (Paul Baker) : 5/6/2005 9:55:09 PM GMT