The ADC Library does not specifically support PICs with 12_bit ADC capability. However It can be achieved with "readad10". The trick is to ground (pulldown) the Vref PIn (Pin2 on the 18F25K80) through a low value resistor. I used a 220R. The resistor is there to protect the Pin in case it is accidentally set as an output and toggled high.
With ReadaD10 the adc value ranges from 7 to 4095 and is rock steady even on a breadboard
(using a good quality potentiometer).
Note that with the PIC18F25K80 and related chips all ReadAD or ReadAD10 readings will be erroneous if the VRef Pin is not grounded, either externally or via writing the proper ADC registers.
With 12_bit ADC capability I can now move on with a thermistor based PID temperature controller and achieve a wide-range display resolution/granularity of 1/10 degree C or F without having to use an op amp.
'/****************************************'/* 12Bit ADC Test Code for PIC18F25K80 *'/****************************************#chip 18F25K80, 16#config XINST = OFF'/ LCD Stuff#define LCD_IO 4#define LCD_NO_RW#define LCD_LAT#define LCD_DB4 LATC.2#define LCD_DB5 LATA.5#define LCD_DB6 LATA.7#define LCD_DB7 LATA.6#define LCD_RS LATA.3#DEFINE LCD_Enable LATA.2#define _LCD_DB4 PORTC.2#define _LCD_DB5 PORTA.5#define _LCD_DB6 PORTA.7#define _LCD_DB7 PORTA.6#define _LCD_RS PORTA.3#DEFINE _LCD_Enable PORTA.2#include <DHT-11A.h>#define DHT_PIN PORTB.5DIM ad_val as wordDIM sum as word'/ Take 10 readings & Averagedo 'Main Loop sum = 0 repeat 10 ad_val = Readad10(AN9) '/PiC Pin 25 sum = sum + ad_val end repeat ad_val = sum / 10 Locate 0,0 Print AD_val : Print " " '/ LCD Display wait 100 msloop
EDIT: This also works with PIC16F1788
Last edit: William Roth 2014-08-03
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The ADC Library does not specifically support PICs with 12_bit ADC capability. However It can be achieved with "readad10". The trick is to ground (pulldown) the Vref PIn (Pin2 on the 18F25K80) through a low value resistor. I used a 220R. The resistor is there to protect the Pin in case it is accidentally set as an output and toggled high.
With ReadaD10 the adc value ranges from 7 to 4095 and is rock steady even on a breadboard
(using a good quality potentiometer).
Note that with the PIC18F25K80 and related chips all ReadAD or ReadAD10 readings will be erroneous if the VRef Pin is not grounded, either externally or via writing the proper ADC registers.
With 12_bit ADC capability I can now move on with a thermistor based PID temperature controller and achieve a wide-range display resolution/granularity of 1/10 degree C or F without having to use an op amp.
EDIT: This also works with PIC16F1788
Last edit: William Roth 2014-08-03