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
}
}
}