PDA

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



Humbleworker
- 27th March 2007, 11:58
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.

Acetronics2
- 27th March 2007, 12:38
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

mackrackit
- 27th March 2007, 12:48
You have asked this already.

http://www.picbasic.co.uk/forum/showthread.php?p=35187#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.