View Single Post
  #1   Spotlight this post!  
Unread 12-02-2005, 15:38
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Exclamation Using gyro.c with other analog sensors no go

I'm going through the interupt routine in gyro.c to figure it out, and I believe I found a major issue with it. Kevin: Please check!

In the interupt routine, it does the following things (in order):
  1. Initialize i and accum if calculating bias
  2. Set old_calc_gyro_bias to calc_gyro_bias
  3. Reads ADC value
  4. Adds it to the accumulator
  5. Begins another ADC conversion
  6. Adds to accumulator.
  7. Does biasing code

The problem with this is if you try to read an analog channel (and clear the ADC) outside of the interupt. For this to work correctly, the gyro must be the only sensor connected to your analog inputs.

The Details:
The ADC converter works asyncronously from the controller. To use it, you have to:
  1. Set the channel or open it and wait for it to settle
  2. Tell it to begin a conversion
  3. Wait until it finishes
  4. Read the value
  5. Close it (?)
If anything is changed during a conversion, you have to start over from #2. The interrupt assumes that the conversion finnished successfully, and that the value in the registers is the one from the gyro. If you read a value, it will likely read the value from the last sensor you used.

Is there any fix to this? This seems to be a large blocker, since the gyro code is dependent on it.

And yes, I did update my code.