Need to detect pulses, too long for PULSIN
Insert_Name_Here
Posts: 3
I plan on using a BS2p24 on a mini-motorcycle to control quite a few things, however, at the moment i have one question (more are sure to ensue[noparse]:)[/noparse]
A magnet on the wheel will rotate and trigger a magnetic switch, sending a pulse to the stamp. I need a way to time the length of time between pulses, so i can calculate current speed. The pulses will range anywhere from a few seconds down to .13 seconds. maybe even a little less.
To my knowledge, this is too long for PULSIN, and becasue i need to be doing other things between pulses (updating LCD, checking pin states, etc...) i am just curious if anyone has any ideas how i can go about this.
Thanks in advance,
Chris
A magnet on the wheel will rotate and trigger a magnetic switch, sending a pulse to the stamp. I need a way to time the length of time between pulses, so i can calculate current speed. The pulses will range anywhere from a few seconds down to .13 seconds. maybe even a little less.
To my knowledge, this is too long for PULSIN, and becasue i need to be doing other things between pulses (updating LCD, checking pin states, etc...) i am just curious if anyone has any ideas how i can go about this.
Thanks in advance,
Chris
Comments
Why not use a counter chip?
That's what I used when I converted an old PDA(Psion Organiser II) into a bike computer.
A magnet on the wheel, a reed relay to detect it, a Shcmitt Trigger and then a counter chip. That allowed the program to check it only once every second to update the speed, distance and so on.
you can find the OPL sources(Organiser Programming Language, quite simpe and easy to read) and schematics here:
http://home.c2i.net/trygveh/english/download/org2/t2bike.html
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Knight Designs
324 West Main Street
P.O. Box 97
Montour Falls, NY 14865
(607) 535-6777
Business Page:·· http://www.knightdesigns.com
Personal Page:··· http://www.lightlink.com/dream/chris
·
So the external counter is very useful to get the counts which can be checked at some interval (to know speed) and still do other tasks·between checking the external counter.
The slight drawback to this is checking at regular time intervals. It is my understanding that no stamps have a "super acurate" time base, but I may be way off here.
Ken
Here's the original formula i worked out for figuring out speed fromt the time between pulses:
Circumference of wheel x (1 / time between rotations) x 60 x 60 / 12 / 5280
Circumference is in inches. Speed is in MPH.
My second question is this: DOing some sample problems, the numbers get quite large, larger than 16 bits, i believe. How can i break down the formula so the stamp can handle it? I've looked into the 32 bit Floating point co-processor, but i dont want to use it unless i *really* have to.
Thanks again for all your help!
-Chris
You could take all constants in your calculation together, that is everything except "time between rotations".
You then get the following very simple equation:
MPh=Constant/time between rotations
Succes,
Klaus
If you go to his sight and scroll down to basic stamps, there is·a link to "math"
He has routines that do 32 bit math with the stamp....and they work by the way.