Quote:
|
Originally Posted by Astronouth7303
First of all, that's a logical OR. You want AND (&&).
|
Code:
if ((autonomous_mode = 0) || (AUTON_SWITCH = 1))
{
execute auton code
}
Well, I believe the idea is so that the auto code executes if the team's AUTON_SWITCH is activated OR if the IFI controller inidicates via the competition port that the robot is in autonomous mode. However, you want to be careful that you use the equivalene test, not the assignment operator--it probably was a copying error, but for those who might use it, make sure you put
== not
=. Also, why the 0? Do you mean 1? (Hrm, or do you mean 0, in which case you would need AND, no?) Also, see below.
Quote:
|
Originally Posted by Astronouth7303
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.
|
Well, if you're going to all the trouble of creating a disable switch, why add extra code when you can just use the competition port to create a disable button as the program is? And while you're there, you can create your auton switch too, and won't need extra code. It will simulate the competition.
competition pin-out guide [pdf file].
I'd carefully analyze why you want to pause. But there are several ways to go about it -- you have a timer interrupt, so you can program a pause function easily enough to pause for a given amount of time. A quick solution, if that's all you need it for, is just to have an empty for loop that executes some pre-determined amount. e.g.,
Code:
for (waste_time = 0; waste_time < TIME_TO_WASTE; waste_time++) ;
// remember: declare waste_time elsewhere, and define TIME_TO_WASTE