View Single Post
  #1   Spotlight this post!  
Unread 14-10-2004, 19:40
colt527 colt527 is offline
Registered User
AKA: Ken Colton
FRC #0527
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Long Island
Posts: 123
colt527 is a splendid one to beholdcolt527 is a splendid one to beholdcolt527 is a splendid one to beholdcolt527 is a splendid one to beholdcolt527 is a splendid one to beholdcolt527 is a splendid one to beholdcolt527 is a splendid one to behold
Send a message via AIM to colt527
No Signal From Gyro

First, thanks in advance for taking the time to read this. Here is our problem. For the past week we have been trying to use a gyro to help our robot go strait in autonomous control. We have 2 Gyros and we wrote the code for the EDU bot for initial testing and have 2 working gyro control codes. So we thought it was time to impliment them into our competition bot from last year. Basically we just copied the code from the EDU bot into the User_Autonomous function in user_routine_fast.c on our competion. Here is 1 version of the code we put in that worked perfectly on the EDU bot:

Code:
//CODE OMMITTED FOR POSTING PURPOSES

//Gyro Variables Located at top of user_routines_fast.c

long int gyro_input;
long int gyro_error = 0;
unsigned int left_speed = 175;
unsigned int right_speed = 175;

#define LEFT_START_SPEED 175
#define RIGHT_START_SPEED 175
#define ACCEPT_ERROR 70
#define TURN_SPEED 1

//CODE OMMITTED FOR POSTING PURPOSES

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! */

        /* Add your own autonomous code here. */
		
		//START GYRO CODE
                         

		gyro_input = Get_Analog_Value(rc_ana_in01);//Get the value


		if((gyro_input<505) || (gyro_input>520))//Cusion
		{
			gyro_error += ((int)gyro_input - (int)523);
		}

		if(gyro_error < -ACCEPT_ERROR)//Too far left
		{
			if(left_speed <= 250)
				left_speed += TURN_SPEED;
		}
		else if(gyro_error > ACCEPT_ERROR)//Too far right
		{
			if (right_speed <= 250)
				right_speed += TURN_SPEED;
		}
		else if((gyro_error < ACCEPT_ERROR) && (gyro_error > -ACCEPT_ERROR))//Going back on course
		{
			left_speed = LEFT_START_SPEED;
			right_speed = RIGHT_START_SPEED;
		}


		pwm13 = left_speed;//pwm13 goes to left motor
		pwm15 = right_speed;//pwm15 goes to right motor

		printf("Gyro: %5u Error: %5u PWM13: %5u PWM15 %5u \n",(int)gyro_input,(int)gyro_error,(int)pwm13,(int)pwm15);

        Generate_Pwms(pwm13,pwm14,pwm15,pwm16);

        Putdata(&txdata);   /* DO NOT DELETE, or you will get no PWM outputs! */
    }
  }
}
Thats everything i modified in the default code for the FRC. The problem comes at Get_Analog_Value(). It is not getting an analog value, it is just coming up 0 in the printf (which printed fine on the EDU bot). We have really tried everything and it never gets a signal, we tried it on both gyros we have, we tried many different rc_ana_in ports, we even tried plugging the gyro in backwards and into the digital ports =P. Nothing makes it display a value. Is there some place where you have to initialize something to let you use rc_ana_in01 like in the EDU code. We are really stummped and very frustrated and ready to throw out using the gyros.

Thanks again for your time.
__________________
Mentor, Team 527 -- Plainedge Red Dragons
FIRST Volunteer
SUNY Stony Brook Computer Science 2010
kcolton@gmail.com