Shop OBEX P1 Docs P2 Docs Learn Events
Need to detect pulses, too long for PULSIN — Parallax Forums

Need to detect pulses, too long for PULSIN

Insert_Name_HereInsert_Name_Here Posts: 3
edited 2004-08-28 21:42 in BASIC Stamp
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

Comments

  • cabojoecabojoe Posts: 72
    edited 2004-08-28 08:03
    Couldn't you use the count function? Check it out in syntax guide.
  • GadgetmanGadgetman Posts: 2,436
    edited 2004-08-28 13:21
    I assume that you can't just check on the input level of a pin as the pulse is too short for it to be reliable?

    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 SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2004-08-28 14:15
    Everyone else already addressed the obvious answers, so I will add this...If you really want to use PULSIN, could you add more magnets to the wheel, so that when it's slower, there's not as much time between pulses?· You don't want to add too many, since at high speed, the pulses may be too frequent.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    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
    ·
  • KenMKenM Posts: 657
    edited 2004-08-28 16:58
    Gadgetman's idea of an external counter is by far the best solution because the user wants to "multitask". When the stamp is using PULSIN or COUNT it is doing nothing else correct?

    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
    Gadgetman said...
    I assume that you can't just check on the input level of a pin as the pulse is too short for it to be reliable?

    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
  • Insert_Name_HereInsert_Name_Here Posts: 3
    edited 2004-08-28 20:59
    The external counter idea seems like it would work rather well, and after posting my problem, i did look in to COUNT, and i think if i were to re-arrange the formula below, and count pulses for half a second, that it wold work rather well. A half second lag doesnt seem like it would be too bad to deal with.

    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
  • K de JongK de Jong Posts: 154
    edited 2004-08-28 21:14
    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
  • KenMKenM Posts: 657
    edited 2004-08-28 21:42
    Dr. Tracey Allen at http://www.emesystems.com/ is the stamp math guru.

    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.
    Insert_Name_Here said...

    The external counter idea seems like it would work rather well, and after posting my problem, i did look in to COUNT, and i think if i were to re-arrange the formula below, and count pulses for half a second, that it wold work rather well. A half second lag doesnt seem like it would be too bad to deal with.

    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

Sign In or Register to comment.