Sunny
15-01-2008, 16:38
Hello I am a new programmer to FRC and having problems getting Autonomous mode to work. This is the code.
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 */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */
/* Add your own autonomous code here. */
if(digital_io_01==1)
{
if(pwm01==127) //Full Forward
{
pwm01=254;
pwm02=254;
}
}
if(digital_io_02==1)//Full Left
{
if(pwm01==127)
{
pwm01=0;
pwm02=254;
}
}
if(digital_io_03==1)
{
if(pwm01==127) // Full Right
{
pwm01=254;
pwm02=0;
}
}
Generate_Pwms(pwm13,pwm14,pwm15,pwm16);
Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
}
}
}
I think it should work but when we push the buttons on the remote only the ir board leds goes on and no pwm outputs. Also i tried just setting pwm01 and pwm02 to 254 without any ir inputs and the motors did nothing. The pwm cables are all plugged in properly and they work in RC mode. Any suggestions
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 */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */
/* Add your own autonomous code here. */
if(digital_io_01==1)
{
if(pwm01==127) //Full Forward
{
pwm01=254;
pwm02=254;
}
}
if(digital_io_02==1)//Full Left
{
if(pwm01==127)
{
pwm01=0;
pwm02=254;
}
}
if(digital_io_03==1)
{
if(pwm01==127) // Full Right
{
pwm01=254;
pwm02=0;
}
}
Generate_Pwms(pwm13,pwm14,pwm15,pwm16);
Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
}
}
}
I think it should work but when we push the buttons on the remote only the ir board leds goes on and no pwm outputs. Also i tried just setting pwm01 and pwm02 to 254 without any ir inputs and the motors did nothing. The pwm cables are all plugged in properly and they work in RC mode. Any suggestions