Hi Everyone,
I am trying to read a 10K
(linear) potentiometer using the ADC of a PIC12F1572
(http://ww1.microchip.com/downloads/en/DeviceDoc/40001723D.pdf). The pot-meter is connected directly to the ADC of the PIC using the same VCC and GND that is supplied to the PIC. But for some reason I am getting weird results when I read low voltages.
Reading 'high' voltage (~5V) works great; I get 1023 as expected
(using the 'ADC1_GetConversion()' function that was generated by MPlab). And when rotating the pot-meter the ADC result changes accordingly as far as I can see. But when I turn the pot completely down, I only get 44 from the ADC while the voltage on the ADC pin is around 0.1mV according to my
(cheap) multimeter. Directly connecting the ADC pin to GND or using a different PIC12F1572 did not make a difference; the ADC still did not go lower as 44.
I've gone through the datasheet and the Code Configurator settings but sofar I have not been able to find anything that would explain this. Is there some additional setting needed when measuring low voltages on a PIC? Or do I need to add something to my test-circuit since it contains only a bare pot-meter at the moment.
ADC settings used:
Clock: FOSC/16 (sampling freq. 86.9565 kHz, conversiontime 11.5us)
Alignment: right
Positive reference: VDD
(No triggers or interrupts)
Code (that was generated) to retrieve ADC value:
adc_result_t ADC1_GetConversion(adc_channel_t channel)
{
ADCON0bits.CHS = channel; // select the A/D channel
ADCON0bits.ADON = 1; // Turn on the ADC module
__delay_us(ACQ_US_DELAY); // Acquisition time delay
ADCON0bits.GO_nDONE = 1; // Start the conversion
while (ADCON0bits.GO_nDONE) // Wait for the conversion to finish
{
}
return ((ADRESH << 8) + ADRESL); // Conversion finished, return the result
}
Edit: changed subject to better reflect question