Go to Post More later, if anyone's interested and I still have homework to avoid. - Chris is me [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 17-01-2008, 18:38
jasonpeinko jasonpeinko is offline
Registered User
FRC #1087
 
Join Date: Jan 2008
Location: Salem Oregon
Posts: 22
jasonpeinko is an unknown quantity at this point
Delay

is there a code for a delay command for c?
  #2   Spotlight this post!  
Unread 17-01-2008, 18:41
i_am_samus's Avatar
i_am_samus i_am_samus is offline
Why? Why not.
AKA: Rida
FRC #2590 (Nemesis)
Team Role: Alumni
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Robbisnville, NJ
Posts: 93
i_am_samus has a spectacular aura abouti_am_samus has a spectacular aura abouti_am_samus has a spectacular aura about
Re: Delay

You could start up a counter and use the counter to tell the robot to do certain things at a certain time (remember the code loops every 26. something milliseconds).

Unfortunately, as far as I know, there is no delay function.
  #3   Spotlight this post!  
Unread 17-01-2008, 21:59
whitetiger0990's Avatar
whitetiger0990 whitetiger0990 is offline
Registered User
no team
Team Role: Programmer
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Earth
Posts: 157
whitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of light
Re: Delay

There are timer interrupts (which, sorry, I'm unsure how to use). But for most applications you rarely need any more resolution than 26.2ms. It's pretty much constant from loop to loop.
__________________
print$q=chr(ord($q)+$1)while("7443-0201-8465130105-12-03135-82482113-06-7672-070208-0613-70"=~/(-?\d\d)/g);
  #4   Spotlight this post!  
Unread 18-01-2008, 01:06
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: Delay

Wait(x);

x being the number of milliseconds. Thus, if you want the code to pause for 3 seconds, you type "Wait(3000);"
  #5   Spotlight this post!  
Unread 18-01-2008, 06:17
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Re: Delay

Where did you find reference to the "Wait" command? Did you find it in a manual. I'm trying to find a reference to all these kinds of functions?
  #6   Spotlight this post!  
Unread 18-01-2008, 07:49
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 685
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: Delay

I believe Wait(n) is in EasyC, not in mplab. The two operate much differently in this respect.

In mplab you don't want a command like wait 3 seconds inside your code. The code needs to do it's own paperwork every loop. You can use a counter variable like i_am_samus suggests. Here's my note to myself in the code:
Code:
//  timer notes:
//
//  The autonomous code functions are called by the controller 
//  every 26.2 mS (milliseconds), or 38.17 times each second.
//  For calculations we will use 38 times per second.
//  The total length of Autonomous Mode is 15 seconds, 
//  or  570 counts total (or exactly 572.55 counts).
(I'm willing to be corrected if this isn't right.)

As I recall from other places here at CD, the counter variable method isn't exact but is close enough.
  #7   Spotlight this post!  
Unread 18-01-2008, 11:48
ay2b's Avatar
ay2b ay2b is offline
Registered User
AKA: Andy
FRC #2928
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 1994
Location: Seattle, WA
Posts: 211
ay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant future
Re: Delay

If you're using MPLAB and last year's code, you should have a "delay.h" file (partially copied here). If you're using this year's code, some of these functions appear to be
called, but from an unused code block, and the file "delay.h" is gone. Perhaps Kevin can shed more light on this?

Code:
/* PIC 17Cxxx and 18Cxxx cycle-count delay routines.
 *
 *   Functions:
 *               Delay1TCY()
 *               Delay10TCY()  // 17Cxx only
 *               Delay10TCYx()
 *               Delay100TCYx()
 *               Delay1KTCYx()
 *               Delay10KTCYx()
 */
__________________

2011 - SD Quarterfinalists (980), LA Quarterfinalists (980)
2010 - LA (2404) Finalists (980), AZ Motorola Quality (980)
2009 - LA Semifinalists (980); Las Vegas Quarterfinalists (980); SD (2404); IRI #1 Seed, Finalist (980)
2008 - SD Quarterfinalists (980), LA Champions (980), LA Rookie Inspiration Award (2404); CalGames Finalists
2007 - So.Cal Finalists (980), SD Quarterfinalists (980); CalGames Finalists
2006 - So.Cal Regional Champion (4), Toronto Judge's Award Day 1 (4)
2005 - SVR Champions, Delphi "Driving Tomorrow's Technology" (980); AZ Xerox Creativity (980); So.Cal Finalists, RadioShack Innovation in Control (980); Championship Archimedes Division Semifinalists; IRI Finalists (980)
2004 - So.Cal Regional Champions, Leadership in Controls (980); AZ GM Industrial Design (980); Championship Galileo Division #2 Seed; IRI Champions
2003 - PNW Semi-finalists (488)
2002 - PNW Finalists (488)
2000 - X-bot / 488 - Mentor / Founder
1994 - Sunny Delight - Driver - champion
  #8   Spotlight this post!  
Unread 18-01-2008, 15:11
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: Delay

You can setup one of the timers and increment an integer in the interrupt routine (more accurate and adjustable period) or increment a counter variable in the default functions (fixed period but easier to implement and only works when OI is talking to the robot). Spinning a loop to get a delay is a bad idea in this application. The "paperwork" referred to in this post is the processing of messages to and from the operator interface controller. If you start missing those messages or not replying in a timely manner, the master game controller will disable your robot for the duration of the match.

Update: A simple spin to create usec type delays is OK but don't spin for a long time relative to the cycle of the main loop (~23ms).

Last edited by wireties : 18-01-2008 at 15:14.
  #9   Spotlight this post!  
Unread 18-01-2008, 15:56
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Delay

Quote:
Originally Posted by jasonpeinko View Post
is there a code for a delay command for c?
There are several ways to implement delays in software for FRC robots. The best advice for how to do it in your case will depend on why you want a delay. What do you intend to use it for? The more specific you can be, the more helpful an answer you will get.
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
pwm signal delay 3dude_2231 Programming 14 05-10-2007 20:08
Delay Function Slick Programming 6 01-03-2007 22:56
Delay Help! waiakea2024 Programming 7 21-02-2007 12:41
NERDS Delay... Andy Grady General Forum 21 14-03-2006 21:52
Delay Gal Longin Programming 1 09-12-2004 10:37


All times are GMT -5. The time now is 15:13.

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