View Single Post
  #14   Spotlight this post!  
Unread 31-03-2004, 03:10
Jay Lundy Jay Lundy is offline
Programmer/Driver 2001-2004
FRC #0254 (The Cheesy Poofs)
Team Role: Alumni
 
Join Date: Jun 2001
Rookie Year: 2001
Location: Berkeley, CA
Posts: 320
Jay Lundy is a name known to allJay Lundy is a name known to allJay Lundy is a name known to allJay Lundy is a name known to allJay Lundy is a name known to allJay Lundy is a name known to all
Re: Despite what IFI says, you can configure autonomous from OI...

Quote:
Originally Posted by TedP
Rather than changing what was in ifi_aliases.h, we just added a user_aliases.h and added that to the project. Then we #defined our user alias names to names that were setup in ifi_aliases.h.

The advantage to this is that it was really easy to back track to find out that pumpPnuFWD is relay1_fwd and so on. It also prevented changing a bunch of other FIRST code that initialized the ifi_aliases to certain things.
We did the same thing. For example our motors are #define LEFT_MOTORS pwm01.

We handled our relays slightly differently. Since there are several different ways of controlling solenoids using a relay (2 singles on 1 relay -- M+ to GND and M- to GND, 1 single on 1 relay -- M- to M+, 1 double on 1 relay M+ to GND and M- to GND) we made a function to hide the implementation.

Our relays are #defined as just numbers (1-9), we have #defines for each function, and we have a SetRelay function which handles all the setting of relays.

For example:
#define BALL_GRABBER 1

#define BALL_GRABBER_OPEN RELAY_REV
#define BALL_GRABBER_CLOSED RELAY_FWD

SetRelay(BALL_GRABBER, BALL_GRABBER_OPEN);

(Or a little more accurately)

ballGrabberState = BALL_GRABBER_OPEN;
SetRelay(BALL_GRABBER, ballGrabberState);

In this example ball grabber is a double solenoid on 1 relay. If we wanted to change it to a single solenoid all we have to do is change the #defines for the 2 ball states to RELAY_OFF and RELAY_FWD / RELAY_REV. If we wanted to move it to relay 2 all we have to do is change the BALL_GRABBER #define.

That way not only does the code document the electronics, it is also easy to update should the electronics change in some major way.

By the way Alex, I'm pretty sure we left all the original ifi aliases intact, even for the OI. The autoProg bits are just #defined on top of the other alises.