![]() |
2008 Gyro Code
Hi. I'm using Kevin's new 2008 code, but I can't figure out how to get the Gyro working in either autonomous mode or user mode. I believe that I set up the code right:
Code:
void Teleop_Init(void)Code:
void Teleop(void)But unfortunately, the only output I get is "Gyro Angle 0". I'm sure I've got the gyro connected right, as I get values from Get_Analog_Value (and they change), but I don't get anything from Kevin's code. Can anyone help? |
Re: 2008 Gyro Code
FireJet,
The first thing you need to do is move the Process_Gyro_Data() into the Autonomous_Spin, Disabled_Spin and Teleop_Spin functions. This will allow a Gyro data to be processed all the time, not just during that 26.2 milliseconds loop. Remember, Get_Gyro_Angle returns a long value. You need to typecast it to an int for your printf statement. Something like this. Code:
tmpangle = int Get_Gyro_Angle(); |
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();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. |
Re: 2008 Gyro Code
I tried running Process_Gyro_Data in the _Spin functions, but it still won't help. To make sure that it wasn't my code that was broken, I also added a bit of debug output to Kevin's gyro.c code, in Process_Gyro_Data, so that it now looks like this:
Code:
void Process_Gyro_Data(void)As well, I've tried replacing that hard-timed loop with this: Code:
while (Get_Gyro_Bias_Status() != GYRO_BIAS_BUFFER_FULL) |
Re: 2008 Gyro Code
Quote:
Quote:
*WPILIB/EasyC works around this by doing the communication in the background, but you have to deal with it in IFI and Kevin's code. |
Re: 2008 Gyro Code
I've read through the ADC and gyro readmes, and everything that they require should be set. I'm not sure about the timer, though... is there a readme for that?
As for the while loop, I did that because I wanted to run the gyro calculations in the initialization functions instead of the Teleop and Autonomous functions. |
Re: 2008 Gyro Code
Quote:
-Kevin |
Re: 2008 Gyro Code
Looks like I need to get the really new 2008 code. I still have the version from January that has the old readme.txt file. I'll post more if it still doesn't work.
|
Re: 2008 Gyro Code
Quote:
-Kevin |
Re: 2008 Gyro Code
Just another question while I'm at it. I used the new default code to test the gyro, and in gyro.h I set "#define TENTHS_OF_A_DEGREE", but when I get input from the gyro I'm getting numbers that range from the double/triple digits to in the thousands, even when I divide by 10. Should this be happening?
|
Re: 2008 Gyro Code
Quote:
|
Re: 2008 Gyro Code
Even after it's been divided by 10? And even after that, I shouldn't be getting values over 6000, should I?
|
Re: 2008 Gyro Code
We are getting output greater then 6000 even after it have been divided 10. Is that suppose to be like that?
|
Re: 2008 Gyro Code
So, does anyone know how to fix this?
|
| All times are GMT -5. The time now is 23:51. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi