Thread: 2008 Gyro Code
View Single Post
  #3   Spotlight this post!  
Unread 09-02-2008, 10:53
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,567
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: 2008 Gyro Code

Process_Gyro_Data() should be called in a spin function, as it needs to process the data after each interrupt and the telop function isn't fast enough.

Code:
		Start_Gyro_Bias_Calc();
		
		
		while (t2 < 76)
		{
			printf("Calculating gyro bias. State: %d.\n\r", Get_Gyro_Bias_Status());
			//Start_Gyro_Bias_Calc();
			t2++;
		}
		

		Stop_Gyro_Bias_Calc();
The bias calc should last for several seconds. This starts the gyro bias calc, runs the while loop very quickly, and then stops the gyro bias calc too soon.

You should start the bias calc when t2=0, change your while loop to an if statement (so it gets called once each time through telop()) and stop it when t2=76 (or higher, since longer is better). You might also want to consider a delay so that the bias calc doesn't start right away, for everything to stabilize.

Kevin has an example of all this in the ifi_frc_sensor project.