View Single Post
  #3   Spotlight this post!  
Unread 15-02-2005, 18:32
Travis Hoffman's Avatar Unsung FIRST Hero
Travis Hoffman Travis Hoffman is offline
O-H
FRC #0048 (Delphi E.L.I.T.E.)
Team Role: Engineer
 
Join Date: Sep 2001
Rookie Year: 2001
Location: Warren, Ohio USA
Posts: 4,047
Travis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond reputeTravis Hoffman has a reputation beyond repute
Re: Receiving info from OI to select autonomous mode

Code:
void SelectAutonomousProgram(void)
{
 
if (autonomous_mode) 	//AUTONOMOUS MODE IS ACTIVE
{
	if (automode_LED == 0) 
	{
		automode_LED = 1; //Turn on the autonomous LED when autonomous mode first starts
 
		DriveNeutral(); //Stop the drive motors.
 
		//Do other initial autonomous initialization stuff.
 
	}
}
else		//MANUAL MODE IS ACTIVE
{			
	 if (automode_LED == 1)
	 {
		 automode_LED = 0; //Turn off the autonomous LED
 
		 DriveNeutral();	 //Stop the motors
	 }
 
	//Store the status of the LR side select switch
	sideselect = LRsideselect_sw;
 
	//Store the status of the Auto Drive Disable switch
 
	autodriveselect = smartdrivedisable_sw;
	//Calculate the autonomous program number set by the BCD switch on the button box --> positions 0-7 are valid. 8-9 are not
 
	autocode = (autoselect0 * 1) + (autoselect1 * 2) + (autoselect2 * 4);
 
} 
 
} //End SelectAutonomousProgram

See the above code for reference - it's what I used last year. I call the SelectAutonomousProgram routine from Process_Data_From_Master_uP. To store any OI switch-driven settings I want to make available to the program once the match starts, I create variables (i.e. sideselect, autodriveselect, autocode) and write the status of the OI switches to them while the robot is in human control mode (which it is when it's powered on and disabled before match start). When autonomous mode starts, these variables are still available to the autonomous code while the OI switches, joysticks, etc. are being ignored. This routine also sets initial robot behavior when the bot first comes out of autonomous mode.

This year, we're using a 3-position toggle switch (wired to an analog input with the help of 22k and 47k resistors) and a BCD thumbwheel switch (8 distinct program options that consume three digital inputs) to yield 24 different autonomous program possibilities. The likelihood of me having the time to program our robot to do 24 different things in autonomous is almost nil, but that's beside the point.
__________________

Travis Hoffman, Enginerd, FRC Team 48 Delphi E.L.I.T.E.
Encouraging Learning in Technology and Engineering - www.delphielite.com
NEOFRA - Northeast Ohio FIRST Robotics Alliance - www.neofra.com
NEOFRA / Delphi E.L.I.T.E. FLL Regional Partner