Go to Post there is no such thing as too many offseason competitions. - Berserker [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 26-01-2008, 16:14
Tanner's Avatar
Tanner Tanner is offline
Registered User
FRC #1261 (Roblions)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Suwanee, GA
Posts: 311
Tanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to behold
Timer Function

Hello all,

The programming team on our team is trying to get a timer function where we can run this code every x seconds or something like that.

We've searched high and low and have not been able to find a good timer code that works for us. Does anybody have any timer code that works without having a degree in nuclear physics to install and use?

Thanks
-Tanner
  #2   Spotlight this post!  
Unread 26-01-2008, 16:25
robotrobot2's Avatar
robotrobot2 robotrobot2 is offline
Computer Overlord
FRC #0151 (Tough Techs)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Nashua NH
Posts: 14
robotrobot2 is on a distinguished road
Re: Timer Function

We've got some code, but right now it seems not to be working, sorry. Here it is if you want to look, though.
Attached Files
File Type: c timelibrary.c (881 Bytes, 49 views)
__________________
Everything can always be blamed on software:

The claw can't pick up the trackball-
programmers must have messed up the claw function.

The driver crashes the robot into a wall-
the drive code must not be responsive enough.

The robot repeatedly displays "HELLO WORLD"-
that probably is software.
  #3   Spotlight this post!  
Unread 26-01-2008, 16:36
Shadow503's Avatar
Shadow503 Shadow503 is offline
printf("\r\n Moo!");
no team
Team Role: Human Player
 
Join Date: Mar 2007
Rookie Year: 1991
Location: na
Posts: 92
Shadow503 will become famous soon enoughShadow503 will become famous soon enough
Re: Timer Function

Do you have the FRC base? That should include a timers.c file.
  #4   Spotlight this post!  
Unread 26-01-2008, 22:03
jacobhurwitz jacobhurwitz is offline
Registered User
FRC #0449 (Blair Robot Project)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Maryland
Posts: 45
jacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura about
Re: Timer Function

Quote:
Originally Posted by Tanner View Post
Hello all,

The programming team on our team is trying to get a timer function where we can run this code every x seconds or something like that.

We've searched high and low and have not been able to find a good timer code that works for us. Does anybody have any timer code that works without having a degree in nuclear physics to install and use?

Thanks
-Tanner
This year, out team is using WPILib. It greatly simplifies the use of most everything, including timers. Read page 53 of the manual for details.

What I love about WPILib is it has simple code for timers, gyros, ultrasonic sensors -- just about everything. But it was also easy to switch our code to WPILib, since you don't have to use their simplified functions if you don't want to. Instead of using SetPWM(1, 127), you can still say pwm01=127 if you want. I highly recommend using WPILib.
  #5   Spotlight this post!  
Unread 27-01-2008, 15:25
Eric Finn's Avatar
Eric Finn Eric Finn is offline
Registered User
FRC #0166 (Chop Shop)
Team Role: College Student
 
Join Date: May 2006
Rookie Year: 2005
Location: Merrimack, NH
Posts: 101
Eric Finn has a spectacular aura aboutEric Finn has a spectacular aura about
Send a message via AIM to Eric Finn
Re: Timer Function

We've had timers in the past. Our code is in CHOPSHOP.C. Just search for "timer" in that file and follow the instructions in the function headers.

Here is our sourceforge project, you can download our code here:
http://sourceforge.net/projects/frst166code08
__________________
It always takes longer than you expect, even when you take into account Hofstadter's Law.
--Hofstadter's Law


Last edited by Eric Finn : 27-01-2008 at 15:27.
  #6   Spotlight this post!  
Unread 27-01-2008, 22:05
mluckham's Avatar
mluckham mluckham is offline
Registered User
FRC #0758 (Sky Robotics)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Ontario, Canada
Posts: 116
mluckham will become famous soon enoughmluckham will become famous soon enough
Re: Timer Function

You could try this code which I developed 2 years ago - it is compatible with MPLAB.

http://www.sunsys.net/frc/
  #7   Spotlight this post!  
Unread 28-01-2008, 15:23
ericand's Avatar
ericand ericand is offline
Registered User
AKA: Eric Anderson
FRC #3765 (Terrabots)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: St. Paul, MN
Posts: 148
ericand is a jewel in the roughericand is a jewel in the roughericand is a jewel in the rough
Re: Timer Function

Team 1425 has as schedular function which allows a routine to be run in some amount of time in the future, or set a routine to run every so often, or some amount of time since it last ran.

We do this by having timer 1 keep a time base for us, and a scheduler routine which keeps track of function pointers for routines that are to be run at the specific times.

Getting the function pointers to work was an interesting exercise for the students, but the system works well. It is not as generic as we would have liked due to the limits imposed by the available memory (used to store the info relating to the scheduled events).

A side benefit of this code is a general set of clock routines that allow any part of our code to tell how much time has elapsed. We return ms since the robot started as a long integer.

The timer setup is all based on the timer white paper available at the ifi site.
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
Timer Question lightning_blast Programming 15 30-03-2007 07:12
Timer questions Rick TYler Programming 3 12-02-2006 19:24
Timer 0/Serial Communications? steven114 Programming 2 13-02-2005 20:50
timer omega Programming 3 30-03-2004 18:52
Timer Preview Nate Smith General Forum 2 05-03-2003 12:25


All times are GMT -5. The time now is 19:12.

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