Go to Post I bet a lot of us (mentors and students) got into this line of work first because we wondered how things work, and stayed in it because we thought "I can make that work better". Thus starts a life-long battle between perfection and time. So far, time is ahead. - petek [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Spotlight this post!  
Unread 19-02-2007, 20:21
SuperBK's Avatar
SuperBK SuperBK is offline
Registered User
AKA: BrianK
FRC #1225 (Amperage Robotics)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Henersonville, NC
Posts: 358
SuperBK is just really niceSuperBK is just really niceSuperBK is just really niceSuperBK is just really nice
Thumbs up Re: Programming "sleep" function

Use a counter. Its 26.2 ms for each time User_Autonomous_Code() is called.

Code:
#define STAGE_1 0   
#define STAGE_2 1
#define STAGE_3 2

inside User_Autonomous_Code()

static stage;
int counter;

state = STAGE_1;


  while (autonomous_mode)   /* DO NOT CHANGE! */
  {
switch (stage) { case STAGE_1: // turn motor on here counter = 0; stage = STAGE_2; break; case STAGE_2: ++counter; if (counter = 38) // 1 second { // turn motor off here stage = STAGE_3 } break; }
}
__________________
Brian K
Team 1225 Robotics Mentor
 


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
MOEmentum: FYI - Post-ship "So, May I Sleep Now?" Mr MOE General Forum 1 22-02-2006 00:54
"call of function without prototype" railerobotics Programming 7 21-01-2006 19:59
New NEMO White Papers! "Creating a Killer Packet" and "25 Ways to Sponsor" Jessica Boucher Team Organization 0 10-08-2005 10:55
I'm having difficulties locating the programming code "gift" Flynn Programming 3 09-01-2005 22:01
"Thunderbirds" Vs. "Team America" Which one will rule the box office? Elgin Clock Chit-Chat 3 07-09-2004 19:53


All times are GMT -5. The time now is 00:22.

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