Quote:
|
Originally Posted by Josh Siegel
how I can convert the values into a usable time (mS, uS) that may be accessed like a variable.
How does Kevin Watson do this in his infrared receiver code? It looked like he might have some usable way of measuring a pulse width.
|
That's exactly what I would look at. Kevin Watson's IR receiver code. Specifically the routines for identifying which of the two beacons is being detected. They each produced a different pulse width signal.
In a nutshell:
Set up a timer to increment at whatever resolution you need measure your pulse width at.
Start timer.
Interrupt on each falling edge (or rising, or both depending on what you want).
Service the interrupt by checking your timer variable, and reset your timer variable to 0.
Lather, Rinse, Repeat...
For interrupts, this is a pretty good first project. Just be sure to disable your interrupts temporarily when you modify variables that are modified by other interrupt service routines. In the above example, you'll want to disable interrupts whenever you increment or reset your timer variable, then re-enable them right after.