View Single Post
  #5   Spotlight this post!  
Unread 25-10-2006, 02:42
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Help needed timing a pulse (2004 Robovation)

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.