I am experimenting with a servo tester to gain some experience with pic programming. Especially reading a pot, and a switch to control the servo output. The pic is a 16f683 and I can get it working and I can read the switch, but I have so far failed to get anything but 0 from the pot.
The pot input is pin 6, AN1 and I have verified that it varies the voltage from 0 to +5.
Here is the relavent portion of code:
--------------------------------------------------------------------------
DEFINE ADC_BITS 8
DEFINE ADC_CLOCK 3
DEFINE ADC SAMPLES 50
TRISIO = %11111110 ' set porta.0 output and all other to inputs
ANSEL = %00000010 ' porta.1 to analog, others to digital
ADCON0 = %10001001 ' analog input on porta.1, Right justify result
CMCON0 = %00000111 ' Turn of the comparators
PORTA = %00000000 ' set porta to all 0's
pulse_width var word
adcin porta.1, pulse_width
--------------------------------------------------------------------------
Any help would be appreciated.
Thanks,
Mike
Bookmarks