View Single Post
  #2   Spotlight this post!  
Unread 13-12-2004, 22:22
colt527 colt527 is offline
Registered User
AKA: Ken Colton
FRC #0527
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Long Island
Posts: 123
colt527 is a splendid one to beholdcolt527 is a splendid one to beholdcolt527 is a splendid one to beholdcolt527 is a splendid one to beholdcolt527 is a splendid one to beholdcolt527 is a splendid one to beholdcolt527 is a splendid one to behold
Send a message via AIM to colt527
Re: Don't Laugh - Remember I'm New ... Robovation Kit

Yes, this is actually quite easy, and no it was not a dumb question.

The best I can explain it would be through code:

Code:
unsigned long int timer = 0;//Global variable declared right under the includes

...Code ommited for posting purposes...

//This function gets called every 17ms, therefore you just use a global variable that increments everytime this function is called to keep track of the time that is going by.
void Process_Data_From_Master_uP(void)
{
  Getdata(&rxdata);   /* Get fresh data from the master microprocessor. */

  Default_Routine();  /* Optional.  See below. */

  /* Add your own code here. */

  if(timer <= 85)//Both pwms full forward for first 5 seconds (17 * 5= 85)
  {
    pwm07 = 255;
    pwm08 = 255;
  }
  else if(timer > 85 && timer <= 119)//For next 2 seconds turn
  {
    pwm07 = 0;
    pwm08 = 255;
  }
  else //else sit there
  {
    pwm07 = 127;
    pwm08 = 127;
  }

  timer++;//Increment the variable

  printf("PWM OUT 7 = %d, PWM OUT 8 = %d\n",(int)pwm07,(int)pwm08);  /* printf EXAMPLE */

  Putdata(&txdata);             /* DO NOT CHANGE! */
}
and there you go. You just have to edit the Process_Data_From_Master_uP function in user_routines.c. Hope I helped . Basically you just use this function to simulate autonomous, but if you need something to update faster then 17ms you need to place it in a different spot.
__________________
Mentor, Team 527 -- Plainedge Red Dragons
FIRST Volunteer
SUNY Stony Brook Computer Science 2010
kcolton@gmail.com