|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Tracking Elapsed Time
Our team is getting better at programming using MPLAB and I had a question:
1. What is the best way to track elapsed time? For example, the the main loop running on the RC is fast enough to loop (3) times each time the IR board receives an input then sends out a pulse. We would like to create a timer and ignore any other pulses from the IR board for a 500ms window to prevent processing the same signal (3) times. I wasn't sure if the RC had an internal clock which could be read and stored into a variable. Good Luck! TEAM #1711 Traverse City, MI |
|
#2
|
|||||
|
|||||
|
Re: Tracking Elapsed Time
The PIC has several onboard hardware timers you could use for this, but I think just counting passes through the main loop would be much simpler for this application.
If you really want to use a hardware timer for this, look at this IFI whitepaper. A polled timer should be good enough for your purposes, so you'd setup the timer in your initialization, then you'd start it and pre-load the correct values when you saw a pulse. as long as the interrupt flag is 0, it hasn't timed out and you should ignore pulses. |
|
#3
|
||||
|
||||
|
Re: Tracking Elapsed Time
Quote:
See http://www.chiefdelphi.com/forums/sh...ad.php?t=54948 for a previous discussion on the topic. |
|
#4
|
||||
|
||||
|
Re: Tracking Elapsed Time
Use the same tpe of system the NHRA uses for ETs. they can handle a 26-foot car at 330 MPH right down to thousanths of a second
|
|
#5
|
||||||
|
||||||
|
Re: Tracking Elapsed Time
Quote:
Code:
unsigned int loop_counter;
void timer(void) {
static unsigned char prev_packet;
unsigned char packets;
if (rxdata.packet_num > prev_packet)
{
packets = rxdata.packet_num - prev_packet;
}
else
{
packets = 256 - prev_packet + rxdata.packet_num;
}
loop_counter += packets;
}
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Camera locked in "tracking", but not tracking | geeknerd99 | Programming | 1 | 02-18-2007 10:47 PM |
| Tracking | Ghosty | Programming | 4 | 01-16-2007 10:53 AM |
| Time tracking software | scitobor 617 | Programming | 19 | 08-26-2005 09:21 PM |
| It's that time of year again!! (No, not The Championship event) Tax Time!! | Elgin Clock | Chit-Chat | 4 | 04-10-2005 10:59 AM |
| IR tracking | nzj1 | General Forum | 3 | 01-26-2004 10:46 PM |