View Single Post
  #4   Spotlight this post!  
Unread 04-03-2009, 13:40
Analog's Avatar
Analog Analog is offline
Registered User
AKA: Bob Most
FRC #2619 (The Charge)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Midland, Michigan
Posts: 53
Analog will become famous soon enoughAnalog will become famous soon enough
Re: team update #9 "Autonomous - Disabled" - what?

Quote:
Originally Posted by oddjob View Post
Our robot has a six position switch on a DriverStation analog input, configured to read out 0V, 1V, 2V, 3V, 4V or 5V. I think this will work, can't test it until the regional:

Code:
static int auto_v = 0;
static int autonomousmode = 0;

void DisabledPeriodic(void) {
int auto_v_now;

  auto_v_now = ((int)((m_ds->GetAnalogIn(1))+0.5)) + 1;
  if(auto_v_now == auto_v)
  {
    autonomousmode = auto_v;  // only shift when equal (stable voltage)
  }
  auto_v = auto_v_now;  // always update current state
}
I know that GetAnalogIn() does not return a "float" voltage like GetVoltage() does, so auto_v_now will need scaling. The robot will use autonomousmode to select one of six modes during the autonomous period.
This should work, you're using the 6 position switch as an indicator what the start position is on the field, correct?
Reply With Quote