Thread: RC Refresh Rate
View Single Post
  #7   Spotlight this post!  
Unread 01-08-2008, 18:32
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,673
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: RC Refresh Rate

Quote:
Originally Posted by whitetiger0990 View Post
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.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter