Quote:
Originally Posted by whitetiger0990
Code:
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 */
}
}
Stuff in Process_Data_From_Master_uP() will be run every 26.2ms. Same with User_Autonomous_Code() (when the robot is in autonomous).
It doesn't vary much to matter, if you have code that makes it take longer than 26.2ms to run it, it will explode.
|
Just to head off any programming headaches, the User_Autonomous_Code() function is, in fact, only run once per autonomous mode. It doesn't even loop. It instead has a while loop in it that the execution stays in until autonomous mode ends. There's a section in this other while loop that has the same update rate, but it's technically incorrect to say that User_Autonomous_Code itself is run every 26.2ms.
Also, the new controller could still be running tasks in fixed time loops. At least, it's easily possible to do so on a Labview RT controller, though there are certainly other control methods they could be using. But for measuring elapsed time, it'd certainly be easier to start a timer and watch the elapsed time value instead of trying to count loops.