|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools |
Rating:
|
Display Modes |
|
#16
|
||||
|
||||
|
Re: Gyroscope Code
Quote:
EDIT: I set up a calibration algorithm that gives an average of the first ten values it pulls from the gyro, and sets that as neutral (after 20 program loops to give it a chance to spinup) So I feel okay ignoring the temperature output. Last edited by Chriszuma : 20-01-2006 at 21:45. |
|
#17
|
|||
|
|||
|
Re: Gyroscope Code
i download the Gyro code and i think the result are not correct because when i move the gyro 90 degrees and back to 0 degrees then i not get the same values
what is the problem ?? -Naor |
|
#18
|
||||
|
||||
|
Re: Gyroscope Code
I have a few questions again..
In adc.c, I notice that you divide the accumulated readings, to once again have a value that's between 0 and 1024: Code:
for(i=0; i < num_adc_channels; i++)
{
adc_result[i] = (long)(accum[i] >> adc_result_divisor);
}
Code:
// Return the calculated gyro angle to the caller. return(((gyro_angle * GYRO_SENSITIVITY * 5L) / (ADC_RANGE * ADC_UPDATE_RATE * 2L)) * GYRO_CAL_FACTOR); I have it set right now to sample four channels at 3200Hz, and to collect 16 samples before an update. This sets ADC_RANGE to 4096 and ADC_UPDATE_RATE to 3200/(16 * 4), which is 50Hz. So the ADC_RANGE seems out of place. Is the down shift of the accumulator in adc.c not supposed to be there, or is it doing something other than what I think it is? Last edited by Joel J : 29-01-2006 at 01:23. |
|
#19
|
||||
|
||||
|
Re: Gyroscope Code
Quote:
-Kevin |
|
#20
|
||||
|
||||
|
Re: Gyroscope Code
nvm. I'll just wait for your response.
Last edited by Joel J : 29-01-2006 at 08:20. |
|
#21
|
||||
|
||||
|
Re: Gyroscope Code
Quote:
-Kevin |
|
#22
|
||||
|
||||
|
Re: Gyroscope Code
Quote:
|
|
#23
|
||||
|
||||
|
Re: Gyroscope Code
Quote:
-Kevin |
|
#24
|
||||
|
||||
|
Re: Gyroscope Code
Quote:
Thanks for all the help. The team's programming team has been very "feature aggressive" this year, so there is a lot of code I'm helping them test and keep track off, and we'd be in a much bigger mess without your help. |
|
#25
|
||||
|
||||
|
Re: Gyroscope Code
Thanks for that breakdown! Now I understand.
You actually DO get more resolution from oversampling! So, at 16 samples per update, I have a 12-bit ADC value, that is completely valid, and does not have to be divided any further. I looked at the code again, and you take 16 samples, then divide by 4, leaving 4*[0, 1023]. This is awesome. 12-bits is exactly the resolution that's required to be as accurate as I need to be in my application. Previously I had thought that oversampling gave more "resolution" due to the fact that when the samples were completely averaged together, they would just eliminate more noise. Now I think I understand better. Thanks again. |
|
#26
|
||||||
|
||||||
|
Re: Gyroscope Code
Quote:
|
|
#27
|
||||
|
||||
|
Re: Gyroscope Code
Quote:
Code:
#ifdef ADC_SAMPLES_PER_UPDATE_16 #define ADC_SAMPLES_PER_UPDATE 16 #define ADC_RANGE 4096L #define ADC_RESULT_DIVISOR 4-2 // 12-bit effective resolution #endif -Kevin |
|
#28
|
||||
|
||||
|
Re: Gyroscope Code
Quote:
-Kevin |
|
#29
|
||||
|
||||
|
Re: Gyroscope Code
I have a question about the code, how much would the accuracy suffer if I modified how long the gyroscope spends calculating the bias? Is there a graph somewhere which would explain this?
|
|
#30
|
|||
|
|||
|
Re: Gyroscope Code
Hi Kevin,
I've got the full sized RC running now and I'm trying to merge last year's pid.c/h and robot.c/h with this year's gyro.c/h, encoder.c/h and adc.c/h code. I've got the encoders working fine and adc appears to be working fine (I've hooked up a pot to analog port 2 and called Get_ADC_Result(2) and got good data). I've even called Get_ADC_Result(1) with the gyro hooked up to input 1 and got readings that varied as I moved the gyro around. But I am not getting anything out of gyro.c. The routine I created to start and stop the gyro bias calculation worked fine on the EDU controller with last year's adc and gyro codes. On this year's full size controller all I ever get is a bias of -1 and a heading of 0. When I run the gyro only code it works fine. It does not like robot.c for some reason. Any ideas? I should add that I actually started with the 2006 frc_gyro project and added the other files to it so I would not miss anything. I've also disabled the serial ports options related to rx1, tx2, & rx2. Thanks again for all your efforts! Last edited by jaustin : 10-02-2006 at 01:07. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Out of the Box Camera Code | russell | Programming | 9 | 21-10-2009 05:28 |
| Code suddenly fails to initialize | miketwalker | Programming | 11 | 19-02-2005 15:23 |
| Team THRUST - Kevin's Code and Camera Code Combine | Chris_Elston | Programming | 3 | 31-01-2005 22:28 |
| Sourceforge for Code Repository and other stuff | SilverStar | Programming | 9 | 15-01-2005 21:16 |
| heres the code. y this not working | omega | Programming | 16 | 31-03-2004 15:18 |