Shop OBEX P1 Docs P2 Docs Learn Events
measuring time elasped between button presses in milliseconds — Parallax Forums

measuring time elasped between button presses in milliseconds

dufflingduffling Posts: 73
edited 2005-03-10 19:58 in BASIC Stamp
I have written a routine that does this already but im wondering if someone has a better more accurate routine

basically im working out Beats per minute with the user tapping the tempo with one button

my program enters a loop then calculates the difference between button press times to calculate the bpm

its ok .. but i need it to be more accurate ..im using the Button command to debounce the key input loop
this works well .. my way is not too elegent


i have not used the count command before .. is this a better way to do it ?

if someone can give me some tips this would be much app.


thanks!
·

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2005-03-10 18:30
    The BS2 is not too good on "absolute" time -- exact milliseconds. It's very good at "approximate" time -- delay from NOW for 10 milliseconds then continue.

    Your 'non-elegant' solution may be the best one the BS2 offers. There does exist a 'co-processor' which will give you an exact 50 millisecond square wave that you can use to measure other events.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-10 18:45
    The BUTTON command is probably overkill for what you're doing. To get an accurate time you could use the button to trigger a flip-flop and then use PULSIN to measure the flip-flop output.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • MacGeek117MacGeek117 Posts: 747
    edited 2005-03-10 19:58
    COUNT could work.
    bugg

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    But I canna change the laws of physics, Captain!
Sign In or Register to comment.