How do you extract the time of how long a sensor was in the 0 state and the 1 state?


+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2007
    Location
    Philippines
    Posts
    9

    Question How do you extract the time of how long a sensor was in the 0 state and the 1 state?

    Utilizing a laser and a photo transistor and a PIC16F628A with an onboard 4mhz oscillator, I would like to extract (as a variable of data) the time of how long the beam is cut and how long it is uncut. How do you do it? I have no clue.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,581

    Post

    Quote Originally Posted by Humbleworker View Post
    Utilizing a laser and a photo transistor and a PIC16F628A with an onboard 4mhz oscillator, I would like to extract (as a variable of data) the time of how long the beam is cut and how long it is uncut. How do you do it? I have no clue.
    Hi,

    You can measure the High state duration and after, the low state ...

    The PULSIN command looks pretty cool for that.

    Now, as the PULSIN command can't measure the Low state just following the High state ... it will only measure the "second" Low state !

    Here you can try a PULSIN, Pin,1, resultH... for High state,immediatly followed by a RCTime Pin,0,resultL for Low State ... and then have the result for 1 only "period" ...

    ...

    Want to measure speed of light ???

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    You have asked this already.

    http://www.picbasic.co.uk/forum/show...5187#post35187

    Why re-post the same question?

    You could go with the example SAYZER gave you and while in the loop count to a variable every 100 ms ... Read the variable or take a look at the PULSIN command, might be easier.
    Dave
    Always wear safety glasses while programming.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts