View Single Post
  #11   Spotlight this post!  
Unread 09-03-2008, 09:14
EricS-Team180's Avatar
EricS-Team180 EricS-Team180 is offline
SPAM, the lunchmeat of superheroes!
AKA: Eric Schreffler
FRC #0180 (SPAM)
Team Role: Engineer
 
Join Date: Apr 2002
Rookie Year: 2001
Location: Stuart, Florida
Posts: 561
EricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond repute
Re: Using Analog Inputs as Digital (on the OI)

Just like Al and Travis's teams, we've been using "AiDi"s through the various analog input ports for some years now. Like WildStang (heck we probably got the idea from you guys Al ) we use a rotating 6 to 10 position switch with resistors in series. And, like Travis pointed out, we leave plenty of "room" for selecting which position we want. Here's a sample of how we do it.

Code:
const uint8 AUTONOMOUS_ANALOGS[7] = {6, 140, 160, 190, 210, 235, 255};

uint8 AnalogToDigital(uint8 value, uint8 analogs[])
{
  uint8 loop;
  for (loop = 1; loop <= analogs[0]; loop++)
    if (value <= analogs[loop])
      return ( analogs[0] - loop ) ;
  return 255;
}
The values in the array are the max loop counter, followed the boundaries between which the actual inputs will lie.

Eric
__________________

Don't PANIC!
S. P. A. M.