Go to Post I wouldn't mind having this day repeat itself a few times. It would give us more time to work on our robot. - Mr.D [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 16-02-2004, 20:33
Lou Lou is offline
Registered User
#0373
 
Join Date: Feb 2004
Location: Locust Valley
Posts: 2
Lou is an unknown quantity at this point
Question inputting data for autonomous mode

so i want to put this code i got from the website
http://www.rec.ri.cmu.edu/education/...tent/index.htm
specifically the IR Reflective Sensor Program for line tracking
now in which file would i put thise code into?
although the instructiosn say to put this code into user_routines.c,
i thought you put autonomous code programming in user_routines_fast.c?
can anyone shed some light?
thanks in advance
-noob at programming

this is the code for line tracking
Code:
void Default_Routine(void)/* BEGIN Default_Routine(); */
{ 

	if(rc_dig_in06 == 0)  /* if dark is seen */
		{
		pwm01=pwm03=127; /* turn left motors off */
		pwm02=pwm04=96; /* turn right motors forward slowly */
		}
	else 
		{
		pwm01=pwm03=159; /* turn left motors forward slowly */
		pwm02=pwm04=127; /* turn right motors off */
		}

printf("%d\n", rc_dig_in06); /* print light sensor readings */

} /* END Default_Routine(); */
  #2   Spotlight this post!  
Unread 16-02-2004, 21:33
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: inputting data for autonomous mode

take the code from inside the Default_Routine() function, and put it in the User_Autonomous_Code() function (in user_routines_fast.c) instead. it should look like this:

Code:
/* in user_routines_fast.c */
 
void User_Autonomous_Code(void)
{
  while (autonomous_mode)   /* DO NOT CHANGE! */
  {
    if (statusflag.NEW_SPI_DATA)      /* 26.2ms loop area */
    {
        Getdata(&rxdata);   /* DO NOT DELETE, or you will be stuck here forever! */

        if(rc_dig_in06 == 0)  /* if dark is seen */
                {
                pwm01=pwm03=127; /* turn left motors off */
                pwm02=pwm04=96; /* turn right motors forward slowly */
                }
        else 
                {
                pwm01=pwm03=159; /* turn left motors forward slowly */
                pwm02=pwm04=127; /* turn right motors off */
                }

printf("%d\n", rc_dig_in06); /* print light sensor readings */
        Putdata(&txdata);   /* DO NOT DELETE, or you will get no PWM outputs! */
    }
  }
}
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
  #3   Spotlight this post!  
Unread 16-02-2004, 22:26
Lou Lou is offline
Registered User
#0373
 
Join Date: Feb 2004
Location: Locust Valley
Posts: 2
Lou is an unknown quantity at this point
Re: inputting data for autonomous mode

Quote:
Originally Posted by deltacoder1020
take the code from inside the Default_Routine() function, and put it in the User_Autonomous_Code() function (in user_routines_fast.c) instead. it should look like this:

Code:
/* in user_routines_fast.c */
 
void User_Autonomous_Code(void)
{
  while (autonomous_mode)   /* DO NOT CHANGE! */
  {
    if (statusflag.NEW_SPI_DATA)      /* 26.2ms loop area */
    {
        Getdata(&rxdata);   /* DO NOT DELETE, or you will be stuck here forever! */

        if(rc_dig_in06 == 0)  /* if dark is seen */
                {
                pwm01=pwm03=127; /* turn left motors off */
                pwm02=pwm04=96; /* turn right motors forward slowly */
                }
        else 
                {
                pwm01=pwm03=159; /* turn left motors forward slowly */
                pwm02=pwm04=127; /* turn right motors off */
                }

printf("%d\n", rc_dig_in06); /* print light sensor readings */
        Putdata(&txdata);   /* DO NOT DELETE, or you will get no PWM outputs! */
    }
  }
}
thanks alot for your help!
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
Help On Coding 2K1 Controller GregTheGreat Programming 9 05-12-2003 18:35
autonomous mode problem on field Chris_C Programming 17 26-03-2003 19:11
Competition Scouting pauluffel Scouting 31 09-01-2003 00:34
Robot Scouting Database archiver 2001 10 24-06-2002 03:00
Limiting PWM in pbasic archiver 2001 4 24-06-2002 00:38


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

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