View Single Post
  #5   Spotlight this post!  
Unread 20-02-2004, 16:27
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: programs and timeing.

Quote:
Originally Posted by Phil_Lutz
Why do you need to pause the program?
For testing purposes?

If so, you can code a switch, when closed allows the code to execute, when released if stops.

Code:
if ((autonomous_mode = 0) || (AUTON_SWITCH = 1))
{
  execute auton code 
}
Or something like that. (I don't have my code in front of me.
AUTO_SWITCH - is an alias to one of the O/I joystick triggers for testing only. Make sure to remove it before comp.
First of all, that's a logical OR. You want AND (&&).

How about this? In main.c:
Code:
  while (1)   /* This loop will repeat indefinitely. */
  {
#ifdef _SIMULATOR
    statusflag.NEW_SPI_DATA = 1;
#endif
if (!PAUSE_SWITCH)
{
    if (statusflag.NEW_SPI_DATA)      /* 26.2ms loop area */
    {                                 /* I'm slow!  I only execute every 26.2ms because */
                                      /* that's how fast the Master uP gives me data. */
      Process_Data_From_Master_uP();  /* You edit this in user_routines.c */

      if (autonomous_mode)            /* DO NOT CHANGE! */
      {
        User_Autonomous_Code();        /* You edit this in user_routines_fast.c */
      }
    }
    Process_Data_From_Local_IO();     /* You edit this in user_routines_fast.c */
                                      /* I'm fast!  I execute during every loop.*/
}
  } /* while (1) */
Basically, if you flip the switch, the robot will finish, and then go into a really fast loop: it does nothing until you turn it off. Be sure to but something similar in the auto.mode code: it has its own loop.