View Single Post
  #6   Spotlight this post!  
Unread 03-04-2011, 11:22
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
Re: Reading Driver Station Input to select Autonomous Routine

Quote:
Originally Posted by Hjelstrom View Post
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.

int seq = 0;
bool Dec1 = !ds->GetDigitalIn(1);
bool Dec2 = !ds->GetDigitalIn(3);
bool Dec4 = !ds->GetDigitalIn(5);
bool Dec8 = !ds->GetDigitalIn(7);
You are inverting all the switches when you get them (bool Dec1 = !ds->GetDigitalIn(1) so it makes sense that the the seq goes to 15 in auto. So in auto all the GetDigitalIn() calls return false then they are inverted to true and stored in Dec1-8. I am not sure exactly how your rotary is wired that you needed to invert the inputs (I imagine it is grounding one input at a time). In the past (we dont use the Cypress this year) we have used a rotary switch and soldered resistors between adjacent positions to make a variable voltage divider then read it in as an analog value check to see if it is in different ranges.

Wrapping an IsDisabled() around this function as suggested before would work (stop AutoSeq being set to 15). You can also check that (seq != 15) before setting AutoSeq.

Also a CD posting tip for the future: there are code tag that you can wrap around posted code to preserve the indentation and make it easier to read. You just need to press the # icon on top of the post box to put code tags in your post. Code tags also work well for tab spaced tables (like one you might copy from Excel)

Quote:
Originally Posted by Hjelstrom View Post
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! :-)
Auto going well, that is an understatement. Great job on that consistent 2 uber tube auto! Are you checking the lines at times for alignment? It is truly unique set up for 2 tube with you starting at the Y and going across the other robot to get the tube at the other line.

I watched the impressive LV archive you guys set up. Congrats on your first 2 regional win season!
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"
Reply With Quote