Shop OBEX P1 Docs P2 Docs Learn Events
How to use BS2P measure time like this — Parallax Forums

How to use BS2P measure time like this

DukeDuke Posts: 21
edited 2005-06-22 15:37 in BASIC Stamp
Hello,

I have a problem about measuring time from a Photo Interruper Device.
The pulse looks like this attached picture.

When pulse start running, I what to ignore first 2.5 ms (masking time)
Then measure the down edge of first pulse (High state)·that comes out after masking time.

Please help give me a idea how to write program detect this kind of pulse

Thank you

Duke..

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-22 14:51
    Duke,

    ·· There really isn't enough information here to write sample code...What is the state of the signal prior to the pulses coming in?· Is it always one high-pulse prior to the pulse you want to measure?· If so you can simply do a PULSIN twice and ignore the first one.· I'm not sure what you're saying about "down-edge" but if you're measuring the HIGH time, the use the same PULSIN command.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • DukeDuke Posts: 21
    edited 2005-06-22 14:58
    Thank you,

    The first pulse is always High but it doesn't have raising edge.
    When start measure the signal was already High, In this case how can I use pulsin ?

    I wonder if there are some commands like stop watch this I can keep lap time.
    Do you have more suggestion for me
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-22 15:00
    Duke,

    ·· If the signal starts HIGH, then just sit in a tight loop checking for the pin to go LOW.· When it does, do your PULSIN.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • DukeDuke Posts: 21
    edited 2005-06-22 15:05
    Like this ?
    Loop:
    PULSE1
    If PIN1 = O then Jump
    goto loop

    Jump:
    ...
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-22 15:37
    Duke,

    ·· More like:

    Main:
    DO
    LOOP WHILE IN1 = 0
    PULSEIN 1, 1, PulseVal
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.