View Single Post
  #9   Spotlight this post!  
Unread 15-09-2016, 12:54
RyanN's Avatar
RyanN RyanN is offline
RyanN
AKA: Ryan Nazaretian
FRC #4901 (Garnet Squadron)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Columbia, SC
Posts: 1,126
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
Re: custom button panel

Quote:
Originally Posted by adciv View Post
Option A: Use an encoder to convert a given value to binary and read the buttons as a binary input.

Option B: Use analog input on "joystick" and just break it up into ranges.

Option C: Put the control in software on the Driver Station Dashboard and the robot doesn't start auto until it receives its directions.

We typically use Option C, particularly as we had at least three different settings to configure each match (goal, position, defense).
Option B works really well. Wire GND to the left most position and 5V to the right most position. Put resistors in series between each post of the other positions. It'll make it like a potentiometer, but with low resolution.

Say you have a 6 position switch, you would wire it like:

GND-> Position 0 - 2kOhm - Position 1 - 2kOhm - Position 3 - 2kOhm - Position 4 - 2kOhm - Position 5 <- +5V

Then connect it to the joystick input. I guess it goes from -1 to 1, like shown below:
Pos 0 -> ~-1
Pos 1 -> ~-0.6
Pos 2 -> ~-0.2
Pos 3 -> ~0.2
Pos 4 -> ~0.6
Pos 5 -> ~1

You'll want to factor in some tolerance. It won't be exactly -1, -0.6, etc. In this case, you have 0.4 units between each measurement. You can test between the cases.

if ana < -0.8
pos = 0;
else if ana >= -0.8 and ana < -0.4
pos = 1;
else ifana >= -0.4 and ana < 0
pos = 2;
else ifana >= 0 and ana < 0.4
pos = 3;
else if ana >= 0.4 and ana < 0.8
pos = 4;
else // in this case, this has to be true: ana >= 0.8
pos = 5;
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian

Previous mentor and student from Team Fusion, FRC 364
Reply With Quote