Go to Post At FIRST, our only colors are red or blue. And we are only those for two minutes! - tenfour [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-13-2008, 01:58 PM
7-11number1 7-11number1 is offline
ROAR.
FRC #1711 (RAPTORS)
 
Join Date: Sep 2007
Rookie Year: 2006
Location: Traverse City, Michigan
Posts: 46
7-11number1 will become famous soon enough
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   Spotlight this post!  
Unread 01-13-2008, 02:13 PM
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is online now
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,570
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
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.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #3   Spotlight this post!  
Unread 01-13-2008, 04:06 PM
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: Tracking Elapsed Time

Quote:
Originally Posted by Kevin Sevcik View Post
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.
We've found using loop counters to be very inaccurate in the past. Writing a hardware timer isn't difficult. We've done it several ways, ranging from using someone else's pre-package code, to writing our own routines last year.

See http://www.chiefdelphi.com/forums/sh...ad.php?t=54948 for a previous discussion on the topic.
  #4   Spotlight this post!  
Unread 01-13-2008, 04:09 PM
cobrawanabe1699's Avatar
cobrawanabe1699 cobrawanabe1699 is offline
That kid with the TIG welder
AKA: Matt, or to those in the northeast, THE BOBCAT!!!
FRC #1699 (ROBOCATS)
Team Role: Leadership
 
Join Date: Nov 2007
Rookie Year: 2007
Location: Colchester, CT
Posts: 107
cobrawanabe1699 is a jewel in the roughcobrawanabe1699 is a jewel in the roughcobrawanabe1699 is a jewel in the rough
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
__________________
BOBCAT OWNS
I done welded me a robot!
TECHNICAL JUDGE:
FLL Bash @ The Beach 2007 Regional Competition
FLL State Championship, CCSU 2007
FLL Bash @ The Beach 2008 Regional Competition
ATTENDING IN 2009:
FIRST Kickoff in NH
FIRST Regional Competition: Washington DC
FIRST World Championships: Atlanta, Georgia

"If it ain't broke, fix it 'till it is."
  #5   Spotlight this post!  
Unread 01-13-2008, 04:16 PM
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,547
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Tracking Elapsed Time

Quote:
Originally Posted by kaszeta View Post
We've found using loop counters to be very inaccurate in the past.
We've found that loop counters are accurate enough for almost all applications. One way to make them better is to account for lost radio packets.

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;
}
note: code not guaranteed to compile, done off the top of my head.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT -5. The time now is 10:38 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi