Go to Post My crotchety old person opinion is that it should be illegal to try to win the award. Do things because you like doing them or because it helps others. Don't do things to win awards. - Madison [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #9   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: 146
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
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 17:47.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi