Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Despite what IFI says, you can configure autonomous from OI... (http://www.chiefdelphi.com/forums/showthread.php?t=27358)

TedP 31-03-2004 02:18

Re: Despite what IFI says, you can configure autonomous from OI...
 
This probably should be a separate thread, but...

Quote:

Originally Posted by 10intheCrunch
In ifi_aliases.h, we #define'd the input bits coming in to something a little more readable, in this case, autoProgSide, autoProgBit0, autoProgBit1, autoProgBit2.

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.

It seemed like a pretty clean way to do things. Made it very nice to have all of our user aliases in one place where it was clear which one was supposed to be which.

10intheCrunch 31-03-2004 02:22

Re: Despite what IFI says, you can configure autonomous from OI...
 
Whichever way works for you =). The only aliases we *changed* were those in from the OI, though, not any pwm/relay values (for those, we redefined them somewhere else, so the compiler traces back the defines to what the variable actually is).

TedP 31-03-2004 02:27

Re: Despite what IFI says, you can configure autonomous from OI...
 
Quote:

Originally Posted by 10intheCrunch
Whichever way works for you =). The only aliases we *changed* were those in from the OI, though, not any pwm/relay values (for those, we redefined them somewhere else, so the compiler traces back the defines to what the variable actually is).

When I said "traces back," I was referring to us when we had to remember on the seat of our pants... "So which relay is this supposed to be controlling?" "Which light should turn on here?" "This is referring to which digital input?"

It basically documented our wiring for us by doing it that way.

But again, I don't mean to start a separate sub-thread just for something silly like this. Just something I wanted to mention: don't be afraid to add your own files to the project.

Jay Lundy 31-03-2004 03:10

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.

DKolberg 31-03-2004 10:09

Re: Despite what IFI says, you can configure autonomous from OI...
 
We used the OI to program our autonomous mode and stored the mode in eeprom to ensure that it is available at all times. We only allow the mode to be changed while not in competition mode. We also used the leds on the OI to indicate the mode selected. We used the Switch LEDs to indicate 1 of 8 modes for autonomous and the Relay2 to indicate either left or right operation. This allowed quick verification / changes before the match began and could be programmed at any time prior to the match. Storing the mode in eeprom allows the mode to be maintained while power is off until the next time the mode is programmed.

if(compeition_mode !=0)
{
if (grabButton == 1 & freeButton == 1)
{
autonLR = autonMode & 0x8;
autonMode = ((armCmdInput-8) >> 5) & 0x7;
if (upButton == 1) {autonLR = 8;}
if (statButton == 1) {autonLR = 0;}
autonMode = autonMode + autonLR;
}
else
{
if (autonMode != autonEEP) //Update eeprom as necessary
{
writeEE (1,autonMode);
autonEEP = autonMode;
}
}
}

...

if(compeition_mode !=0)
{
Switch1_LED = (autonMode&0x4)>>2;
Switch2_LED = (autonMode&0x2)>>1;
Switch3_LED = (autonMode&0x1);
Relay2_green = (autonMode < 8);
Relay2_red = (autonMode > 7);
}


Dave
SBotz


All times are GMT -5. The time now is 00:11.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi