View Single Post
  #11   Spotlight this post!  
Unread 19-02-2004, 12:11
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Programming Help

Quote:
Originally Posted by shsdragon
{
static long timeCounter = 0; //this will count the number of 26.2ms ticks that have passed

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! */

if(timeCounter <= 115) //3 seconds / 26.2ms = 114.5
{
pwm13 = pwm15 = 30;
}
else if(timeCounter <= 134) //we'll give the relays about .5 seconds to switch
{
pwm13 = pwm15 = 0;
relay1_fwd = relay2_fwd = 1;
}
else
{
//put stuff to do after the other things here
//you can also add more else-if statements to time other things
}

Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
timeCounter++; //add one to the tick count
}
}
}

this should work fine - hope it helps!


mmy motoors don't move
shs, i already sent you a PM answering that question that you PMed me before you posted it here - check your PMs. but in the name of simplicity...

you need to add a call to Generate_Pwms() after the Putdata() line, like this:
Code:
void User_Autonomous_Code(void)
{
  static long timeCounter = 0; //this will count the number of 26.2ms ticks that have passed

  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! */

        if(timeCounter <= 115) //3 seconds / 26.2ms = 114.5
        {
             pwm13 = pwm15 = 30;
        }
        else if(timeCounter <= 134) //we'll give the relays about .5 seconds to switch
        {
             pwm13 = pwm15 = 0;
             relay1_fwd = relay2_fwd = 1;
        }
        else
        {
             //put stuff to do after the other things here
             //you can also add more else-if statements to time other things
        }

        Putdata(&txdata);   /* DO NOT DELETE, or you will get no PWM outputs! */
        Generate_Pwms(pwm13,pwm14,pwm15,pwm16);
        timeCounter++; //add one to the tick count
    }
  }
}
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)