Hello, I’m from team 2230, and we use potentiometers to check axis. Last year we used one potentiometer, this year we use two of them… But when we connect them both to analog inputs 1 and 2, for example, the rc only reads one of them, the one on analog input 1. We tried switching them, moving them to other pins, no use.
We have another problem, which may be connected… When we write the following piece of code:
temp = Get_Analog_Value(rc_ana_in01);
We get the following error:
M:\FRC2008\Programming\potentiometer eleop.c:185:Error [1105] symbol ‘ADC_CH0’ has not been defined
To the best of my knowledge, ADC_CH0 is defined… Can someone help?
ADC_CH0 is defined in adc.h, which should be located in the compiler’s directory. mcc18v2 in my case. rc_ana_in01 is defined in ifi_aliases.h which includes adc.h.
If the compiler can’t find these .h files I would think that it should have given you an error saying it can’t find the .h file.
From teleop.c double check that you have all the .h files included. Look at adc.h to see if there is any problems with it, and that you see ADC_CH0 is defined there.
The only other thing I can think of is check to see if you have selected the correct device. We are using the PIC18F8722. To see if you have it right, select Configure|Select Device… and you should have PIC18F8722.
Actually, it appears that you are using Kevin Watson’s code as your base. His code was recently updated if you want to use the old method of Get_Analog_Value, which does an analog-to-digital conversion when it is called.
Kevin’s code comes with replacement code for the analog-to-digital conversion that should reduce computation and has many other benefits. If you read the readme or adc_readme file included in the zip file of the code, you should be able to set up the system and use the Get_Analog_Result function.
Sorry about the confusion I’ve created. The Get_Analog_Value() function has been replaced with a version that has the same functionality, but doesn’t have any dependancies on external libraries or header files (other than ifi_frc.h). You can get the code here: http://kevin.org/frc/quick_adc.zip.
To address the defining of ADC_CH0, which my team has been struggling to solve for the past 24 hours, you must put #include <adc.h> into the header file of ifi_frc.h. Be sure to use the <> instead of “” because that <> will call the adc.h file from the compiler, which defines ADC_CH0. The adc.h file in Kevin’s code does not, and the “” will call that file instead.