View Single Post
  #5   Spotlight this post!  
Unread 03-04-2011, 10:00
Hjelstrom's Avatar
Hjelstrom Hjelstrom is offline
Mentor
FRC #0987 (High Rollers)
Team Role: Mentor
 
Join Date: Mar 2008
Rookie Year: 2005
Location: Las Vegas
Posts: 147
Hjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond repute
Re: Reading Driver Station Input to select Autonomous Routine

We're using a rotary switch which is just like 4 dip switches. Using 4 bits you get a number from 0-15. We normally call this in "Disabled()". In 'practice' mode it works, we can run different auto sequences at will but we always switch the robot to 'Disabled', then line it up, then 'Enable' again.

Here is the code to read the switch. I do see a logic/comment flaw in that if the inputs were really all zero, then the seq number would be 15 not zero. So maybe in auto the inputs are all pulled high? I recall in previous years, if you ran code like this during auto, you'd always get zero back as the desired sequence.

We're using 'SimpleRobot' and this function is called from 'Disabled()'

Code:
	void Read_Auto_Switch(void)
	{
		// Check the auto sequence number only in disabled mode!  During auto, all
		// DS inputs are zeroed.
		int seq = 0;
		bool Dec1 = !ds->GetDigitalIn(1); 
		bool Dec2 = !ds->GetDigitalIn(3);
		bool Dec4 = !ds->GetDigitalIn(5);
		bool Dec8 = !ds->GetDigitalIn(7);
		
		if (Dec1 == true)
		{
			seq += 1;
		}
		if (Dec2 == true)
		{
			seq += 2;
		}
		if (Dec4 == true)
		{
			seq += 4;
		}
		if (Dec8 == true)
		{
			seq += 8;
		}
		if (seq != 0) AutoSeq = seq;
	}
In our constructor, we have "ds = DriverStation::GetInstance();"

With a little experimentation, I think we could have sorted out what was going on yesterday but the auto is working so well we decided not to touch anything! :-)

Last edited by Hjelstrom : 03-04-2011 at 16:24.
Reply With Quote