Go to Post If you want to grow the program such that every student on the planet has the chance to participate, you have to start THINKING with a world-centric mindset. - Racer26 [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 04-01-2005, 13:52
Max Lobovsky's Avatar
Max Lobovsky Max Lobovsky is offline
Fold em oval!
FRC #1257 (Parallel Universe)
Team Role: College Student
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Scotch Plains, NJ
Posts: 1,026
Max Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant futureMax Lobovsky has a brilliant future
Send a message via AIM to Max Lobovsky
Rewriting main loop

I want to rewrite the main loop so that the program enters one of the two possible 26.2ms loop functions (User_Autonomous_Code() and Process_Data_From_Master_uP()) from the same place in the code. As it is, when the code enters autonomous mode, it stays in User_Autonomous_Code() until autonomous mode is unset. The main reason I'd like to change this is so that I can have a single counter counting 26.2ms cycles, rather than one in each function. Secondly, its much more logical to do it this way.

I tried to implement my method, but I get some inexplicable problem where User_Initialization() (which should be called prior to any of my changes) is not getting called, and consequently, the rest of the program cannot run. Does the master processor detect my changes and decide they are illegal or something? Why is the code written like this in the first place?

The changes I made:

in main.c replace

Code:
    while (1)   /* This loop will repeat indefinitely. */
    {
  #ifdef _SIMULATOR
  	statusflag.NEW_SPI_DATA = 1;
  #endif
  
  	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) */
  }  /* END of Main */
with

Code:
     while (1)   /* This loop will repeat indefinitely. */
     {
   #ifdef _SIMULATOR
   	statusflag.NEW_SPI_DATA = 1;
   #endif
   
   	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. */
   		/* You edit this in user_routines.c */
   
   	  if (autonomous_mode)		    /* DO NOT CHANGE! */
   	  {
 	 User_Autonomous_Code();		/* You edit this in user_routines_fast.c */
   	  }
   	  else
   	  {
   		Process_Data_From_Master_uP();
   	  }
   /*counter++; can go here*/
   	}
   	Process_Data_From_Local_IO();	 /* You edit this in user_routines_fast.c */
 									 /* I'm fast! I execute during every loop.*/
     } /* while (1) */
   }  /* END of Main */
In user_routines_fast.c replace

Code:
  while (autonomous_mode)   /* DO NOT CHANGE! */
     {
   	if (statusflag.NEW_SPI_DATA)	  /* 26.2ms loop area */
   	{
   	    Getdata(&rxdata);   /* DO NOT DELETE, or you will be stuck here forever! */
   
   		/* Add your own autonomous code here. */
   
   
   
   		Generate_Pwms(pwm13,pwm14,pwm15,pwm16);
   
   	    Putdata(&txdata);   /* DO NOT DELETE, or you will get no PWM outputs! */
   	}
     }
with

Code:
   	    Getdata(&rxdata);   /* DO NOT DELETE, or you will be stuck here forever! */
   	    Putdata(&txdata);   /* DO NOT DELETE, or you will get no PWM outputs! */
__________________
Learn, edit, inspire: The FIRSTwiki.
Team 1257


2005 NYC Regional - 2nd seed, Xerox Creativity Award, Autodesk Visualization Award
2005 Chesapeake Regional - Engineering Inspiration Award
2004 Chesapeake Regional - Rookie Inspiration award
2004 NJ Regional - Team Spirit Award

Last edited by Max Lobovsky : 04-01-2005 at 13:55.
 


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
Rules for hanging, using a loop over the end of the bar caffel Rules/Strategy 10 04-06-2004 15:04
What is going to be your team's main strategy? Matt Attallah Chit-Chat 5 06-04-2004 22:34
Actual execution time measurement Dan Technical Discussion 5 24-03-2003 11:36
NEED HELP with Delay loop for compressor relay switch archiver 2001 10 24-06-2002 02:11
main driver Kaitlin Palmer Off-Season Events 0 09-04-2002 21:26


All times are GMT -5. The time now is 18:15.

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