View Single Post
  #1   Spotlight this post!  
Unread 15-02-2005, 13:19
farmer farmer is offline
Tired Mentor
AKA: Matt
#1108 (Panther Robotics)
Team Role: Engineer
 
Join Date: Jan 2005
Location: Kansas
Posts: 8
farmer is an unknown quantity at this point
Help with auton switching code

Late night coding isn't working. We hooked up a binary switch to 4 digital inputs(tied to ground). And added the following code as a test;




void User_Autonomous_Code(void)
{
static unsigned int mode = 0;


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


mode = ((8*!digital_io_04) + (4*!digital_io_03) + (2*!digital_io_02) + (!digital_io_01));


/* mode = 2; */

switch ( mode )
{
case 0: /* Do nothing */
break;

case 1:
time++;
if (time < 114) {
pwm04 = 150;
}
else if (time < 152)
{
pwm04 = 127;
relay4_rev = 0;
}
else if (time < 570)
{
pwm01 = 127;
pwm03 = 127;
}
break;



If we set "mode" equal to 2 or any other number the switch code works fine. But apparently the binary to digital conversion setting "mode" is not because the robot doesn't move. Thanks for any help.