View Single Post
  #9   Spotlight this post!  
Unread 11-01-2008, 08:39
Mike Mahar Mike Mahar is offline
Registered User
FRC #0138
 
Join Date: Jan 2007
Location: Amherst, NH
Posts: 64
Mike Mahar will become famous soon enough
Re: New C18 3.0+ Compatible FRC Code

Quote:
Originally Posted by Nathans View Post
Our mistake here is probably very silly and obvious, but the solution eludes us nevertheless.

We're trying to get the gryo and accelerometer working, but we get a build error when we try to use the Get_Analog_Value function.

Code:
gyro = Get_Analog_Value(rc_ana_in16);
The build error we get is:

Code:
Error [1105] symbol 'ADC_CH15' has not been defined
I've gotten as far as the fact that rc_ana_in16 is aliased to ADC_CH15, but no further.
The simple answer is don't use Get_Analog_value. The new code in adc.c should replace it. Instead you should call Get_ADC_Result. Make sure you set NUM_ADC_CHANNELS to the number of analog inputs you are using and allocate them starting with first one and go up from there.

The analog inputs are not instantaneous. You have to start them, then wait a certain amount of time and then read them. The code in adc.c will do that for you and uses a timer to wait. Calls to Get_ADC_Result will simply fetch the result that the library has already captured for you.

The function Get_Analog_value does the start/wait/read operation in-place and takes longer and consumes valuable cycles that could be put to better use doing something else.