Go to Post Chain stretch debigulates drive train performance. - Richard Wallace [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-12-2007, 07:02
neutrino15's Avatar
neutrino15 neutrino15 is offline
plɹoʍ ollǝɥ
AKA: Jordan Perr
FRC #0694 (Stuypulse)
 
Join Date: Feb 2007
Rookie Year: 2007
Location: New York City
Posts: 162
neutrino15 is just really niceneutrino15 is just really niceneutrino15 is just really niceneutrino15 is just really nice
user_routines_fast

I was just wondering, why the autonomous loop is in user_routines_fast if it waits for new rxdata anyway? Doesn't this make it execute just as slow as the regular user_routines file? Also, exactly how fast is user_routines_fast?

Note: I am working with kevin watson's code.
  #2   Spotlight this post!  
Unread 16-12-2007, 09:01
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: user_routines_fast

The user_autonomous_code function is indeed fast:
Code:
void User_Autonomous_Code(void)
{
  // ... stuff deleted for clarity
  while (autonomous_mode)   /* DO NOT CHANGE! */
  {
    // this part here happens over and over very very quickly
    if (statusflag.NEW_SPI_DATA)      /* 26.2ms loop area */
    {		
        // ... stuff deleted for clarity
        // this code is only executed once every 26.2ms
    }
    // back to really really fast code here
  }
}
When you're waiting the RC to indicate that there is new data, you're just doing a busy loop spinning around the while(autonomous_mode) loop. This will happen as fast as the RC can do it, which is entirely dependant on how much code is there.

If you wanted to know how fast that is without any code to execute, you could do this (note that lots of default code here is omitted for clarity):
Code:
void User_Autonomous_Code(void)
{
  int cExecutions;
  
  while (autonomous_mode)   /* DO NOT CHANGE! */
  {    
    if (statusflag.NEW_SPI_DATA)      /* 26.2ms loop area */
    {  
        // I don't remember the exact printf syntax, it has been awhile
        printf("%d\r\n cycles in 26.2ms means %d per second",cExecutions,(10000*cExecutions)/262)); 
        cExecutions = 0;
    }
    cExecutions++;
    // back to really really fast code here
  }
}
So cExecutions will increment on every fast loop, then once you get into the 26.2ms code, you print it out and reset it to zero. This way, you can tell how many fast loops occurred per slow loop, and thus derive how many fast loops you get per second. But keep in mind, the fast loops per second count will change dramatically as you add new code to the fast-loop portion.

Last edited by Bongle : 16-12-2007 at 12:50.
  #3   Spotlight this post!  
Unread 16-12-2007, 13:02
neutrino15's Avatar
neutrino15 neutrino15 is offline
plɹoʍ ollǝɥ
AKA: Jordan Perr
FRC #0694 (Stuypulse)
 
Join Date: Feb 2007
Rookie Year: 2007
Location: New York City
Posts: 162
neutrino15 is just really niceneutrino15 is just really niceneutrino15 is just really niceneutrino15 is just really nice
Re: user_routines_fast

Ahh, I understand.. So it would be completely necessary to use interrupt hardware timers here then! Also, what is the point of putting auton code in a fast loop? I mean, if you only get data every 26ms, what would you do in between that? (besides run some really smooth PID, i guess)
Thanks for clarifying that though!
  #4   Spotlight this post!  
Unread 16-12-2007, 23:43
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: user_routines_fast

Quote:
Originally Posted by neutrino15 View Post
...what is the point of putting auton code in a fast loop? I mean, if you only get data every 26ms,...
While in autonomous mode, the "data" you get is irrelevant. It is forced by the system to indicate all joysticks at neutral, and all switches open.

The point is so you can do whatever you want, however quickly you want, without being restricted to a 38 Hz cadence.
  #5   Spotlight this post!  
Unread 17-12-2007, 10:15
neutrino15's Avatar
neutrino15 neutrino15 is offline
plɹoʍ ollǝɥ
AKA: Jordan Perr
FRC #0694 (Stuypulse)
 
Join Date: Feb 2007
Rookie Year: 2007
Location: New York City
Posts: 162
neutrino15 is just really niceneutrino15 is just really niceneutrino15 is just really niceneutrino15 is just really nice
Re: user_routines_fast

Oh, wait.. which function processes the local data?
Process_Data_From_Local_OI()
would make sense.. Ok, so you HAVE sensor data during the fast loop, just not input from the operator interface. That makes more sense!

Thanks!
  #6   Spotlight this post!  
Unread 17-12-2007, 10:43
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,745
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: user_routines_fast

Erm. To the point in the original question: autonomous mode is in User_Routines_Fast mostly just because that's how IFI has structured it. You could put it elsewhere and it would work just fine. But since any fast loop functions you might be calling would probably be defined in User_Routines_Fast, and since you'd probably need those in the fast part of your autonomous loop, it's easiest to put it there.

The basic flow of execution means that whenever the autonomous mode bit is set, you get kicked out of the tele-op loop and shunted into a very very similar autonomous mode loop. Really, you should think of the autonomous code as being exactly the same as your normal code, except you're not getting any valid input from the OI. But note that this does NOT mean that you don't need to wait for new rxdata. rxdata and txdata come from the master processor. Yes, the rxdata has the joystick data from the OI bundled up in it, but it has some other stuff from the master processor besides. Like the disable/enable bit and the autonomous/tele-op bit. More importantly, you HAVE to send the txdata back to the master processor shortly after it sends you an rxdata, or else the watchdog timer will time out and you'll get the dreaded red code light of death. Plus, txdata contains the PWM output values for the 12 PWMs that the user processor doesn't control, so not sending it would mean those 12 PWMs wouldn't do anything.

So, in summary, the autonomous loop is where it is for convenience, and waiting for rxdata is vital in ANY loop you might be in on an IFI controller.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
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
timers in user_routines_fast stephenthe1 Programming 2 17-02-2006 12:35
what is user_routines_fast.c? sjung9442 Programming 2 26-01-2006 21:13
Speed of user_routines_fast.c JoeFryman Programming 2 20-02-2005 01:09
Autonomous weirdness in user_routines_fast.c Roland Programming 6 30-03-2004 11:36
Where is user_routines_fast()? SeanCassidy Programming 3 25-01-2004 16:14


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

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