Go to Post Make sure you THOROUGHLY understand the rules of the game before you actually start designing the robot. - Koko Ed [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 09-03-2007, 00:31
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
Question autonomous timing

how can i program the robot to do something for a amount of time because i want to program autonomous to just go toward the rack.
so far i got this but im not sure how the while loops are going to work
while(autocounter2<=10)
{
pwm01=200;
pwm02=254;
autocounter2=autocounter2++;
}
if(autocounter2==2)
{
while(autocounter<=50)
{
pwm01=254;
pwm02=254;
autocounter=autocounter++;
}
}
  #2   Spotlight this post!  
Unread 09-03-2007, 05:17
BorisTheBlade's Avatar
BorisTheBlade BorisTheBlade is offline
lead programmer 2004
AKA: Dane
FRC #1351 (TKO)
Team Role: Mentor
 
Join Date: Oct 2005
Rookie Year: 2004
Location: San Jose, Ca
Posts: 23
BorisTheBlade has a spectacular aura aboutBorisTheBlade has a spectacular aura aboutBorisTheBlade has a spectacular aura about
Send a message via AIM to BorisTheBlade
Re: autonomous timing

I'm not sure what value you have autocounter2 initialized as but according to your code the second while loop will never occur.
at the end of your fist loop assuming autocounter2 is initialized to 0 autocounter2 will equal 11 and since 11 is not equal to 2 it skips the second loop.

I'm also assuming from looking at your motor speed values that you are turning a little then driving full speed forward. if thats the case then here is my suggestion.

take out the if statement then when the first loop finishes and autocounter2 equals 11 the second loop will start and go till autocounter2 = 51
it would look like this:
Code:
while(autocounter2<=10)
{
pwm01=200;
pwm02=254;
autocounter2++; 
}
while(autocounter<=50)
{
pwm01=254;
pwm02=254;
autocounter2++;
}
by the way use autocounter2++; instead of autocounter2=autocounter2++;
__________________
Team 1351 TKO Robotics (click for our website)
2007 sacramento regional Johnson & Johnson Sportsmanship Award winners
2007 CAL Games Finalists

Last edited by BorisTheBlade : 09-03-2007 at 05:21.
  #3   Spotlight this post!  
Unread 09-03-2007, 07:46
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,533
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: autonomous timing

Do not use while loops.

Remember, the code loops already. Simply increment the counter each loop and have an if / then statement to do whatever when it reaches the loop count that you want.

count++;
if (count <= 10)
{
pwm01=200;
pwm02=254;
}
else if ((count >=10) && (count <= 50))
{
pwm01=254;
pwm02=254;
}

Technically speaking you don't need the count >= 10 in else if because it won't make it there if the count IS less than 10 - it will do the first if then kick out. But I have the guys I work with do it that way for clarity's sake.
  #4   Spotlight this post!  
Unread 09-03-2007, 07:49
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: autonomous timing

You should also reference some loop time or the loops will happen so fast even with a fairly large loop count the robot wont have time to do anything.

I'm not sure how to refrence the clock or even use the 26ms loop time
using the default code but I'm sure someone here does.
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni
  #5   Spotlight this post!  
Unread 09-03-2007, 09:05
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,533
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: autonomous timing

Every loop in the user code is roughly 26.xx ms. It loops about 38 times a second (by design).
  #6   Spotlight this post!  
Unread 09-03-2007, 09:21
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: autonomous timing

thanks guys you were very helpful, but i still want to know if there is any way other than using while loops to count time. im so exited i cant think right now. our regional starts in 2 and 1/2 hours.
  #7   Spotlight this post!  
Unread 09-03-2007, 09:42
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: autonomous timing

There are two good ways to keep track of time. Using interrupts is precise and reliable, but it requires specific knowledge of how to do it. Counting communication packets is easy and usually good enough, and it's trivial to explain.

The middle section of User_Autonomous_Code() executes only when there's new data from the radio link. It's where the default code has the comment "/* Add your own autonomous code here. */" If you increment an integer at that point, you will have a rudimentary timer that you can read and compare against. The radio communication occurs every 26.2 milliseconds, so you can use that to figure out how long to wait.

If you add 26 to the counter each time, you can measure time in milliseconds, which might be easier for the programmer to keep track of. You'll be running a little slow, but by less than one percent -- the timer should read 14872 ms after 15 real seconds.

The one real thing to worry about is lost communication packets. The timer will fail to increment if no radio data is received. Since the robot will end up being disabled anyway if that happens too often, it probably isn't worth compensating for, but you can do so if you want by reading the packet number.
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
Timing Belt Clamp shorton Technical Discussion 10 18-07-2006 22:50
Distance timing out bludstayne Programming 5 05-03-2004 13:47
question about autonomous timing zainali Programming 6 23-02-2004 22:58
Timing Codes Ryan Cumings Programming 11 29-01-2004 22:26
Solution to Timing Loops Steven Carmain Programming 39 10-02-2003 13:33


All times are GMT -5. The time now is 02:54.

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