multiple autonomous modes using easyc

Does anybody know where to put code to detect a switch on our operator console that would select one of our multiple autonomous modes? We are programming in EasyC.

Thanks for any help.

You would need to wire the switch(s) to the joystick inputs on the OI. The OI uses standard analog PC game ports so you should be able to find what pin to connect to.

Once you have the switch connected you would read to value from it the same way you would read the joystick switches.

In autonomous you would just need an if-else if for each switch.
This code assumes you have switches wired to OI port 3 Trigger and Thumb/Top.


if(GetOIDInput(3,1))
{
  //first autonomous mode
}
else if(GetOIDInput(3,2)
{
  //second autonomous mode
}
....

If you are short on input, or need more than eight autonomous modes you could convert the switches to a binary number so you could get 4 options out of 2 switches or 16 from 4.

Check this thread out (for one). If you search EasyC automonous you will find other threads as well.http://www.chiefdelphi.com/forums/showthread.php?t=51172&highlight=easyc+autonomous

To do what you want you need to put a loop in the Initialize function block that takes user input while the robot is disabled BEFORE autonomous starts. The autonomous block isn’t called until the field is enabled in autonomous, at which point user input is disabled (not to mention illegal).

Our programmer last year wrote a code using easyC to select multiple autonoumous modes. What you need to do is start by making a Auto_Select Fuction Block and putting it under Initialize. In it start with a while loop using a GetOIDInput command (While GetOIDInput(1,1) == 0). Inside the loop add a GetOIDInput of that same digital input. Outside the loop start a timer followed by a while command of that same Digital Input as the statement (While GetOIDInput == 1).

Inside that loop add a Get Timer Command and have it changed to one of your variables (in the bottom of the window that opens up.) Add an If statement that reads when that timer reaches 200 milliseconds go into the If statement. Then add another if statement reading that if a digitial input does not equal 0 (If GetOIDInput ==! 0) add 1 to a variable that you create. Then the timer needs to be set back to 0.

You also need to define a Max Autonomous Select so that you do not go over the number of autonomous modes you have. Outside of the last If statement you created make another If statement the reads that if your variable was incrimented and your max value was not exceded that your auto select max. Add an else statement with a user code that will set your value to 0 if you max value is exceded.

I’m sorry that it seems so unorginized in this post but the code I have is at school which won’t be open until monday. If you can wait that long PM me and I’ll try to send it to you. (I Probably forgot some of the code too sorry about that). Hope I can help.:yikes: