Go to Post I know I exaggerated a bit, but NASA put a man on the moon with less processing than some FRC bots. Think about that for a minute. - JesseK [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 10-02-2004, 12:04
Zaramel2002 Zaramel2002 is offline
Registered User
#0963 (Tiger Techs)
 
Join Date: Feb 2004
Location: Columbus,Oh
Posts: 1
Zaramel2002 is an unknown quantity at this point
Send a message via AIM to Zaramel2002
how to add sevral steps to an encoder autonomous program

I was wondering how to make the program below count the encoder then go to another step instead of ending.

Im trying to make this code my encoder program for this years robot please help.

int encoder_count = 0;
short start_counting = 0;
short end_program = 0;

void Default_Routine(void) /* default routine */
{

if((end_program != 1) && (encoder_count < 12))
/* if program has not ended
and encoder has registered
less than 20 ticks */
{
pwm01=pwm03=169; /* turn left motors forward slowly */
pwm02=pwm04=86; /* turn right motors forward slowly */



if((end_program != 2) && (encoder_count < 30))
/* if program has not ended
and encoder has registered
less than 20 ticks */
{
pwm01=pwm03=169; /* turn left motors forward slowly */
pwm02=pwm04=86; /* turn right motors forward slowly */










if((start_counting == 1) && (rc_dig_in08 == 0))
/* if sensor has seen light and now sees dark*/
{
encoder_count++; /* increment encoder count */
start_counting = 0; /* set to 0 to prevent program
from counting wedge or spoke more than once. */
}
if(rc_dig_in08 != 0) /* if sensor sees light */
{
start_counting = 1; /* set to 1 to enable program
to count a dark wedge or spoke */
}
}
else
{
pwm01=pwm02=pwm03=pwm04=127; /* stop */
end_program = 1; /* end program */
}

printf("%d\n" , rc_dig_in08 ); /* print IR Reflective Sensor readings */

} /* END Default_Routine(); */

Last edited by Zaramel2002 : 10-02-2004 at 23:39.
  #2   Spotlight this post!  
Unread 10-02-2004, 21:45
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: how to add sevral steps to an encoder autonomous program

Quote:
Originally Posted by Zaramel2002
I was wondering if I could modify the code that is on usfirst.org to do multiple steps after the if statement .
Code:
 if (1)
  {
  step1();
  step2();
  step3();
  etc();
  }
  #3   Spotlight this post!  
Unread 11-02-2004, 07:34
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: how to add sevral steps to an encoder autonomous program

Quote:
Originally Posted by Zaramel2002
I was wondering how to make the program below count the encoder then go to another step instead of ending.

Im trying to make this code my encoder program for this years robot please help.
I use a static and a loop (in this case, Count is incremented by the sub, but is easily modifiable for ticks)

Code:
void Auto(void)
{
 static long Count = 0;
 if (Count >= 100) //Example, highest first
 {
  //Step 5
  count=0
 }
 else if (Count >= 80) //Example
 {
  //Step 4
 }
 else if (Count >= 60) //Example
 {
  //Step 3
 }
 else if (Count >= 40) //Example
 {
  //Step 2
 }
 else if (Count >= 20) //Example
 {
  //Step 1
 }
 Count = Count + 1;
} //End Auto()
  #4   Spotlight this post!  
Unread 11-02-2004, 08:35
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: how to add sevral steps to an encoder autonomous program

Quote:
Originally Posted by Astronouth7303
I use a static and a loop (in this case, Count is incremented by the sub, but is easily modifiable for ticks)

Code:
void Auto(void)
{
static long Count = 0;
if (Count >= 100) //Example, highest first
{
//Step 5
count=0
}
else if (Count >= 80) //Example
{
//Step 4
}
else if (Count >= 60) //Example
{
//Step 3
}
else if (Count >= 40) //Example
{
//Step 2
}
else if (Count >= 20) //Example
{
//Step 1
}
Count = Count + 1;
} //End Auto()
Nice example.
__________________

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
Linux: steps to program fullsize RC robot rwaliany Programming 31 14-02-2004 14:45
Aspartame shyra1353 Chit-Chat 8 20-01-2004 22:41
Anyone looking for more program space? archiver 2001 13 24-06-2002 02:20


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

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