|
Re: counting in seconds for the autonomous mode??
would this code work u think?? we're going to use a stopwatch to determine how long it actually takes us in average. the only think we are doing in autonomous mod is driving to the 10 pt ball and hopefully noking it down.
void User_Autonomous_Code(void)
{
/* Initialize all PWMs and Relays when entering Autonomous mode, or else it
will be stuck with the last values mapped from the joysticks. Remember,
even when Disabled it is reading inputs from the Operator Interface.
*/
pwm01 = pwm02 = pwm03 = pwm04 = pwm05 = pwm06 = pwm07 = pwm08 = 127;
pwm09 = pwm10 = pwm11 = pwm12 = pwm13 = pwm14 = pwm15 = pwm16 = 127;
relay1_fwd = relay1_rev = relay2_fwd = relay2_rev = 0;
relay3_fwd = relay3_rev = relay4_fwd = relay4_rev = 0;
relay5_fwd = relay5_rev = relay6_fwd = relay6_rev = 0;
relay7_fwd = relay7_rev = relay8_fwd = relay8_rev = 0;
while (autonomous_mode) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{
counter++;
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */
/* Add your own autonomous code here. */
// counter calculated as (38*12)
if ( counter < 456 ) // still less than 12 seconds have elapsed
{
if (rc_dig_in01 == 0 && rc_dig_in02 == 0)
{
pwm13 = pwm14=137;
pwm15= pwm16= 137;
}
if (rc_dig_in01 == 1 && rc_dig_in02 ==0)
{
pwm13 = pwm14= 128;
pwm15= pwm16= 132;
}
if (rc_dig_in01 ==0 && rc_dig_in02 == 1)
{
pwm13 = pwm14=132;
pwm15= pwm16=128;
}
}
Generate_Pwms(pwm13,pwm14,pwm15,pwm16);
Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
}
}
}
|