Hi,

I am fairly new to this whole pic chip thing, and loving it !
I'm building a small (hopefully autonomous) robot and slowly I'm getting close to my goal.
Using a set of Ewave radios and the melabs bootloader, I am able to wirelessly program my pic16f877-04/p, which is pretty cool. All motor control is accomplished using two moded rc servos and an L293D motor driver. Anti-collision will be done using a few Sharp GP2d12 IR range finders. Having the RF modems of course is good for more than just programming. My plan is to be able to tx live onboard telemetry from the robot to my PC or to an RF terminal/user controller and display on a serial LCD.
Should be easy enough, ya right !!! I'm now on day 3 with no luck.
So in order to have any telemetry I first must convert my analog reading to digital, which IS my problem.
I would like to read 0-5v on channels A0,1,2,3 and then serially display on portb.5.
I'm using a 4x20 serial LCD for now hooked up to the PIC, not using wireless until the ADC starts working. In my program below, I'm just looking at two inputs as an experiment, and they do display some value, but nothing correct. I have really tried to get the ADCON settings right, but to no avail. Also, which is better or easier to use, 8 or 10 bit ?

' 10-bit A/D conversion


' Define ADCIN parameters
' Set number of bits in result

define loader_used 1

pause 20

DEFINE ADC_BITS 10
' Set clock source (3=rc)
DEFINE ADC_CLOCK 3
' Set sampling time in microseconds
DEFINE ADC_SAMPLEUS 10

X VAR WORD

A0 VAR WORD ' Create variable to store result
A1 VAR WORD
A3 VAR WORD
' Set PORTA to all input
TRISA = %11111111

ADCON1=4 'SETS PORTA 0,1,3 TO A/D INPUTS

serout portb.5,2,[12] 'clears LCD


Pause 500 ' Wait .5 second

main:

ADCIN 0, A0 ' Read channel 0
PAUSE 100
ADCIN 1, A1 ' " " 1
PAUSE 100
' do something with A0-A2 here



SEROUT portb.5,2,[128,17,22,"BUSS VOLTAGE : ",#a0,145,"vDC"]
SEROUT portb.5,2,[148,"IR DISTANCE : ",#a1,164," cm"]
SEROUT portb.5,2,[168,"TRANCEIVER : "]
SEROUT portb.5,2,[188,"TEMPERATURE : "]
Pause 200 ' Wait .2 secondS
GoTo main
' Do it forever
alarm:
serout portb.5,2,[12,128,"-------ALARM--------"]
serout portb.5,2,[168,"LOW VOLTAGE..: ",#A0/175,185,"vDC"]
PAUSE 200

GOTO MAIN

any help is much appreciated,

JK