Lets then suppose you have the analog input at AN0.
Code:
ADCON0=%00000001 ' Channel 0, ADC on
ADCON1=%00001110 ' AN0 as analog,rest as digital
ADCON2=%10010101 ' Right justify result and Fosc/16
analog_res_array VAR WORD[40]
counter VAR BYTE
start_array VAR BYTE ' first element of the array to store samples
stop_array VAR BYTE ' last element of the array to store samples
start_array=0:stop_array=19 ' first group of 20 samples
gosub adc_routine
start_array=20:stop_array=39 ' second group of 20 samples
gosub adc_routine
......
adc_routine:
for counter=start_array to stop_array
high adcon0.1
while adcon0.1:wend
analog_res_array[counter]=adresh*256+adresl
next counter
return
Now in the array you have 40 samples (two groups of 20) and you can compare them.
Note that code is untested, but you get the idea.
Ioannis
Bookmarks