View Single Post
  #11   Spotlight this post!  
Unread 25-03-2006, 18:05
cdennisxlx2's Avatar
cdennisxlx2 cdennisxlx2 is offline
Team San Diego Web Liaison
AKA: Cameron Dennis
FRC #1266 (The Devil Duckies)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: San Diego
Posts: 188
cdennisxlx2 is a splendid one to beholdcdennisxlx2 is a splendid one to beholdcdennisxlx2 is a splendid one to beholdcdennisxlx2 is a splendid one to beholdcdennisxlx2 is a splendid one to beholdcdennisxlx2 is a splendid one to beholdcdennisxlx2 is a splendid one to behold
Re: Got it working now theres another problem!

Quote:
Originally Posted by X-Istence
Remember, when something is plugged into rc_dig_in[1-16] it is on, when the switch is actually off:

switch off == 1 in code
switch on == 0 in code

This caught me by surprise.

My team used rc_dig_in[1-3] to create 7 different modes:

000 = off
001 = 1
010 = 2
011 = 3
100 = 4
101 = 5
110 = 6
111 = 7

Code is below for what you can use to do this. Stick it in user_routines_fast.c to make use of it, make sure to change it to what you need to use it for .

Code:
unsigned int Auton = 0;

unsigned char flip (unsigned char input) {
	if (input == 1)
		return 0;
	if (input == 0)
		return 1;
}


void User_Autonomous_Code(void)
{
  /* Initialize all PWMs and Relays when entering Autonomous mode, or else it
     will be stuck with the last values mapped from the joysticks.  Remember, 
     even when Disabled it is reading inputs from the Operator Interface. 
  */
  pwm01 = pwm02 = pwm03 = pwm04 = pwm05 = pwm06 = pwm07 = pwm08 = 127;
  pwm09 = pwm10 = pwm11 = pwm12 = pwm13 = pwm14 = pwm15 = pwm16 = 127;
  relay1_fwd = relay1_rev = relay2_fwd = relay2_rev = 0;
  relay3_fwd = relay3_rev = relay4_fwd = relay4_rev = 0;
  relay5_fwd = relay5_rev = relay6_fwd = relay6_rev = 0;
  relay7_fwd = relay7_rev = relay8_fwd = relay8_rev = 0;

  while (autonomous_mode)   /* DO NOT CHANGE! */
  {
    if (statusflag.NEW_SPI_DATA)      /* 26.2ms loop area */
    {
        Getdata(&rxdata);   /* DO NOT DELETE, or you will be stuck here forever! */
		// We have to shift the second and the third bits
		
		Auton = flip(rc_dig_in01) | flip(rc_dig_in02) << 1 | flip(rc_dig_in03) << 2;
		
		if (Auton == 0) {
			// do absolutely nothing
		}
		else {
			if (Auton == 1) {
				// see 7
			}
			if (Auton == 2) {
				// See 7
			}
					
				
			if (Auton == 7) {
			    // Do stuff when in binary added up together it is 7
			}
		}
        Putdata(&txdata);   /* DO NOT DELETE, or you will get no PWM outputs! */
    }
  }
}

what type of switch did u use?
__________________
Team San Diego Robotics Web Liaison
Webmaster and Technical Advisor for the San Diego Regional Planning Committee.
Official Score Keeper for the San Diego Regional
www.sandiegoregional.com
www.frc1266.com