|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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)
{
int temp_gyro_rate;
// fresh ADC data available?
if(Get_ADC_Result(GYRO_CHANNEL))
{
// should the completed sample set be used to calculate the gyro bias?
if(calc_gyro_bias == 1)
{
// put the ADC reading on the circular queue
Gyro_Queue[Gyro_Queue_Index] = Get_ADC_Result(GYRO_CHANNEL);
// increment the write pointer
Gyro_Queue_Index++;
// is the circular queue now full?
if(Gyro_Queue_Index == GYRO_QUEUE_SIZE-1)
{
// update the gyro bias status
Gyro_Bias_Status = GYRO_BIAS_BUFFER_FULL;
}
// If the index pointer overflowed, cut-off the high-order bit. Doing this
// every time is quicker than checking for overflow every time with an if()
// statement and only then occasionally setting it back to zero. For this
// to work, the queue size must be a power of 2 (e.g., 16,32,64,128).
Gyro_Queue_Index &= GYRO_QUEUE_INDEX_MASK;
}
else
{
// get the latest measured gyro rate
temp_gyro_rate = (int)Get_ADC_Result(GYRO_CHANNEL) - gyro_bias;
// update reported gyro rate and angle only if
// measured gyro rate lies outside the deadband
if(temp_gyro_rate < -GYRO_DEADBAND || temp_gyro_rate > GYRO_DEADBAND)
{
// update the gyro rate
gyro_rate = temp_gyro_rate;
// integrate the gyro rate to derive the heading
gyro_angle += (long)temp_gyro_rate;
}
else
{
gyro_rate = 0;
}
}
Reset_ADC_Result_Count();
}
else
{
printf("NO NEW ADC DATA.\n\r");
}
}
As well, I've tried replacing that hard-timed loop with this: Code:
while (Get_Gyro_Bias_Status() != GYRO_BIAS_BUFFER_FULL)
{
printf("Calculating gyro bias.\n\r");
}
|
|
#2
|
||||||
|
||||||
|
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. |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
||||
|
||||
|
Re: 2008 Gyro Code
Quote:
-Kevin |
|
#5
|
|||
|
|||
|
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.
|
|
#6
|
||||
|
||||
|
Re: 2008 Gyro Code
Quote:
-Kevin Last edited by Kevin Watson : 09-02-2008 at 16:00. Reason: Spelling gaff |
|
#7
|
|||
|
|||
|
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?
|
|
#8
|
|||||
|
|||||
|
Re: 2008 Gyro Code
Quote:
|
|
#9
|
|||
|
|||
|
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?
|
|
#10
|
||||
|
||||
|
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?
Last edited by heavymetal : 11-02-2008 at 16:52. |
|
#11
|
|||
|
|||
|
Re: 2008 Gyro Code
So, does anyone know how to fix this?
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Gyro code problem | AMIRAM | Programming | 10 | 23-01-2006 04:26 |
| problems using gyro/adc code with camera default code | tanstaafl | Programming | 7 | 22-01-2006 23:09 |
| gyro code | odin892 | Programming | 2 | 08-04-2003 14:50 |
| Gyro Chip Code | archiver | 2001 | 4 | 24-06-2002 00:57 |