View Single Post
  #5   Spotlight this post!  
Unread 11-01-2008, 19:47
Nathans Nathans is offline
Registered User
AKA: Nathan
FRC #0004 (Element)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Los Angeles
Posts: 17
Nathans is an unknown quantity at this point
Send a message via AIM to Nathans
Re: New C18 3.0+ Compatible FRC Code

Quote:
Originally Posted by Mike Mahar View Post
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.
How do you allocate the analog inputs with Get_ADC_Result? I found where to set NUM_ADC_CHANNELS, but I haven't found anything about allocating specific inputs. Furthermore, what is used as the argument of Get_ADC_Result?