Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Gyro not working in Autonomous? (http://www.chiefdelphi.com/forums/showthread.php?t=43732)

kaszeta 10-02-2006 22:09

Gyro not working in Autonomous?
 
The students and I have been banging our head on this one:

Our gyro is working fine during regular operation, but during autonmous mode Get_Gyro_Angle() always returns 0. I've even managed to reduce this down to the fairly minimal code below:

Code:

void User_Autonomous_Code(void)
{
  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); 

        Camera_Handler();
        Servo_Track();

        printf("%d ",(int)Get_Gyro_Angle());

        Generate_Pwms(pwm13,pwm14,pwm15,pwm16);

        Putdata(&txdata); 
    }
  }
}

Any ideas on this one? Our current bot really needs the gyro for feedback in auto mode. The camera is working fine.

Jared Russell 10-02-2006 22:23

Re: Gyro not working in Autonomous?
 
Have you called BOTH Start_Gyro_Bias_Calc() and Stop_Gyro_Bias_Calc() before autonomous executes?

kaszeta 10-02-2006 22:30

Re: Gyro not working in Autonomous?
 
Quote:

Originally Posted by Abwehr
Have you called BOTH Start_Gyro_Bias_Calc() and Stop_Gyro_Bias_Calc() before autonomous executes?

No, I don't, but that's because I know the bias already. I do call

Code:

Initialize_Gyro();
Initialize_ADC();
Set_Gyro_Bias(1092); //1092 for kit gyro, 1003 for ADXSR300

in my User_Initialization () function, which is called before autonomous mode triggers. And the gyro is working perfectly in user mode (indeed, if I flip back and forth from autonomous mode to user mode the gyro always works in user mode)

jaustin 10-02-2006 22:49

Re: Gyro not working in Autonomous?
 
We are having the same problem, see our symptoms in the gyro code sticky thread. I've also posted the code we are trying to use.

devicenull 10-02-2006 23:00

Re: Gyro not working in Autonomous?
 
It's a simple problem to fix:
The call to update the gyro is preformed in Process_Data_From_Local_IO, which is not called during autonomous mode. If you copy the code for it to the User_Autonomous_Code loop, everything will work.

To be specific, this code needs to be in your autonomous loop:
Code:

if(Get_ADC_Result_Count())
  {
            Process_Gyro_Data();
       
            Reset_ADC_Result_Count();
  }

Took me a little while to figure that out :)

jaustin 10-02-2006 23:31

Re: Gyro not working in Autonomous?
 
Devicenull,
YOU ARE AWESOME!

I was just getting ready to type a note asking why the Process_data... function might not be running in my code and there was your note! It is very confusing since I've been working with the EDU all summer and it appears to run that function during autonomous.

You're a life saver!

kaszeta 11-02-2006 00:04

Re: Gyro not working in Autonomous?
 
Quote:

Originally Posted by devicenull
It's a simple problem to fix:
The call to update the gyro is preformed in Process_Data_From_Local_IO, which is not called during autonomous mode. If you copy the code for it to the User_Autonomous_Code loop, everything will work.

You da man! I was just trying to piece together the ADC event loop and had done some code to make sure Timer 2 was getting called, and got this message. Thanks for saving us some significant debug time.

Kevin Watson 11-02-2006 01:28

Re: Gyro not working in Autonomous?
 
I've updated the gyro documentation to make it clear that Process_Gyro_Data( ) needs to be called from User_Autonomous_Code( ). For grins, I also updated the code in frc_gyro.zip.

-Kevin


All times are GMT -5. The time now is 09:59.

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