Go to Post Given how easily these things pop, is "Blow Out Pricing" really the best choice of words? - ahecht [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 14-02-2008, 18:22
stuffssguy's Avatar
stuffssguy stuffssguy is offline
Team Captain
FRC #1258 (SeaLu Robotics)
Team Role: Alumni
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Seattle, WA
Posts: 27
stuffssguy is on a distinguished road
Looking for help with creating a timer.

We want to use a timer for executing commands. (if x button is pushed than p happens and after a certain amount of time q happens) This would most likely be for controlling the solenoids on our robot so that with one button push a piston would extend before the other. We would also use it for driving functions.
__________________
  #2   Spotlight this post!  
Unread 14-02-2008, 20:06
seanl's Avatar
seanl seanl is offline
"The Everything person"
FRC #0867 (Absolute Value)
Team Role: Leadership
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Arcadia, CA
Posts: 267
seanl will become famous soon enoughseanl will become famous soon enough
Re: Looking for help with creating a timer.

you need to add a global variable at the top and if you put a counter in the while loop for autonomous you can count the iterations. this is the only way you can do it. if you put a delay in you will get the red light of death.
__________________
, Sean

TEAM 867
-electrical
-pneumatics
-programming



2008 Autodesk Visualization Grand Prize Winner
  #3   Spotlight this post!  
Unread 14-02-2008, 22:48
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,861
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Looking for help with creating a timer.

For MPLAB IFI/Watson based programming...

To use a real timer take a look at the IFI explanation in this white paper: http://www.ifirobotics.com/docs/time...004-jan-14.pdf

Kevin Watson has some examples here: http://www.kevin.org/frc/2005/
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 15-02-2008 at 10:26. Reason: What was that word?
  #4   Spotlight this post!  
Unread 15-02-2008, 00:11
taggartbg taggartbg is offline
Registered User
FRC #1712 (Dawgma)
Team Role: Electrical
 
Join Date: May 2005
Rookie Year: 2006
Location: Lower Merion, PA
Posts: 38
taggartbg will become famous soon enoughtaggartbg will become famous soon enough
Send a message via AIM to taggartbg Send a message via MSN to taggartbg Send a message via Yahoo to taggartbg
Re: Looking for help with creating a timer.

use a "wait" function in the code

if(button){
do thing one;
Wait(3000);
do thing two;
}

The value inside the "wait" function is in milliseconds, so the above code would pause for 3 seconds between thing one and thing two.
  #5   Spotlight this post!  
Unread 15-02-2008, 00:17
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,861
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Looking for help with creating a timer.

For Easy C or WPILIB based programming ...

Quote:
Originally Posted by taggartbg View Post
use a "wait" function in the code

if(button){
do thing one;
Wait(3000);
do thing two;
}

The value inside the "wait" function is in milliseconds, so the above code would pause for 3 seconds between thing one and thing two.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #6   Spotlight this post!  
Unread 15-02-2008, 00:54
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Looking for help with creating a timer.

Quote:
Originally Posted by stuffssguy View Post
We want to use a timer for executing commands. (if x button is pushed than p happens and after a certain amount of time q happens) This would most likely be for controlling the solenoids on our robot so that with one button push a piston would extend before the other. We would also use it for driving functions.
If you're using my 2008 robot controller code, I've created drop-in replacement code for timer.c and timer.h that implements a millisecond system clock using timer 2. The code is available here: http://kevin.org/frc/ifi_clock.zip.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #7   Spotlight this post!  
Unread 15-02-2008, 15:51
xrabohrok's Avatar
xrabohrok xrabohrok is offline
hunter of errors
FRC #1208 (The Metool Brigade)
Team Role: Programmer
 
Join Date: Jan 2006
Location: O'Fallon
Posts: 62
xrabohrok is an unknown quantity at this point
Re: Looking for help with creating a timer.

the program loops at 36 times a second. With this knowledge, you could create something that would measure this. I wouldn't advise letting a counter variable get into the thousands, because then the program starts running slower. something like this worked nicely for me:

Code:
//global variables
int count = 0;
int second = 0;


//somewhere in code
if (count >= 37)
{
      count = 0;
}
count++;

//you could compare things like this
switch second
{
        case 0: //what happens right off the back
                  break;
        case 1: //what happens in the first second
                  break;
        case 2: //what happens in second second (ha!)
                  break;
        default: //what should happen when out of time

}
__________________
"It's programming's fault" may be a viable excuse for just about everything, except the robot falling apart.

It will 'cause it can!

constants aren't. variables won't.
  #8   Spotlight this post!  
Unread 16-02-2008, 22:09
stuffssguy's Avatar
stuffssguy stuffssguy is offline
Team Captain
FRC #1258 (SeaLu Robotics)
Team Role: Alumni
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Seattle, WA
Posts: 27
stuffssguy is on a distinguished road
Re: Looking for help with creating a timer.

The code says we are missing IFI_FRC.h
__________________
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
looking for help on chairman award grandmother cul Chairman's Award 19 15-02-2008 09:27
Looking for help sfshilo General Forum 3 10-04-2006 18:30
Looking for a Team to Work With KevinB Finding A Team 0 21-11-2004 14:26
Looking for contact with Millenium team. Gene F General Forum 3 09-11-2003 13:18
Looking for some help with buttons and pins... Amanda Morrison General Forum 4 26-02-2003 17:32


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

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