ADC with external VREF+ getting abnormal results - PIC micro 18F2321 (solved?)

Thread Starter

atferrari

Joined Jan 6, 2004
4,764
PIC micro 18F2321

For several applications with ADC conversions I selected VREF- = Vss and VREF+ = Vdd, this last being 4,91V

Voltages to convert : 3,43V and 2,90V in AN0 and AN1 respectively. Conversion results were always correct:
For 3,43V I get 714
For 2,90V I get 604

Yesterday, changed to the option VREF+ = input in AN3. The actual external input is 3,69 V

Now, conversion results make no sense:
For 3,43V I get 1023
For 2,90V I get 1023

The input in AN3, is generated as shown in the image below. Calculated initially as 3,71V it is actually 3,69V

What am I doing wrong? Completely at lost here.

RIC MCHP.png

------------------------------------------------------------
Settings prior using the ADC module (LOADREG_IN_ACC is a macro):

Code:
  LOADREG_IN_ACC  ADCON0,00000001B      ;ch.selection / enable module/ start
;                        0.......       XX
;                        .0......       XX
;                        ..0.....       channel
;                        ...0....       selection
;                        ....0...       while in
;                        .....0..       operation
;                        ......0.       don't GO yet - patience!
;                        ..... .1       ADC converter up and running

  LOADREG_IN_ACC ADCON1,00011011B       ;enabling analog channels and Vrefs
;                       0.......        XX
;                       .0......        XX
;                       ..0.....        =0 VREF- = Vss / =1 VREF- = input in AN2
;                       ...1....        =0 VREF+ = Vdd / =1 VREF+ = input in AN3
;                       ....1...        =1 enable
;                       .....0..        =0 channels
;                       ......1.        =1 0, 1, 2 & 3
;                       .......1        =1 as analog

  LOADREG_IN_ACC ADCON2,10010100B       ;format / acq time / converion clock
;                       1.......        =1 right justified
;                       .0......        XX
;                       ..0.....        =0 Tacq equal
;                       ...1....        =1 to
;                       ....0...        =0 4Tad
;                       .....1..        =1 Tad equal
;                       ......0.        =0 to
;                       .......0        =0 4 Tosc

;We set the four ADC pins as inputs

  BSF ADC_TRIS,0,A
  BSF ADC_TRIS,1,A
  BSF ADC_TRIS,2,A
  BSF ADC_TRIS,3,A
 

Thread Starter

atferrari

Joined Jan 6, 2004
4,764
hi at,
Those 1023 counts suggest that AN3 has not been set for Analog.??
E
Hola Eric,

I feel that you hit the nail with that. For every conversion using VREF+ = AN3, I've been selecting just channel 0 or 1 but not channel 3.

Pity I cannot check it now; our area is in black out for more than 24 hrs already.

Will revert with the outcome asap.

Gracias.
 
Last edited:

Thread Starter

atferrari

Joined Jan 6, 2004
4,764
Hola Eric,

I feel that you hit the nail with that. For every conversion using VREF+ = AN3, I've been selecting just channel 0 or 1 but not channel 3.

Pity I cannot check it now; our area is in black out for more than 24 hrs already.

Will revert with the outcome asap.

Gracias.
@ericgibbs

Eric, sorry but I was wrong.

This step

LOADREG_IN_ACC ADCON1,00011011B ;enabling analog channels and Vrefs

selects already the four channels A0:3 as analog

The command involving ADCON0 selects just the channel whose input should be converted next (in my case 0 or 1)

Have to keep looking for the cause of a failing conversion.

Could you brief me how to estimate / calculate the impedance of my V ref source?

Gracias.
 

click_here

Joined Sep 22, 2020
548
>Could you brief me how to estimate / calculate the impedance of my V ref source?

Measure the voltage with nothing connected to it, and then put a resistor on it and measure the voltage. From the change in voltage you can calculate the impedance

Example
Vopen=5V
Vload=4.95V
Rload=100R

4.95V/100R = 49.5mA

(5V-4.95V)/49.5mA = (approx) 1R
 

Thread Starter

atferrari

Joined Jan 6, 2004
4,764
>Could you brief me how to estimate / calculate the impedance of my V ref source?

Measure the voltage with nothing connected to it, and then put a resistor on it and measure the voltage. From the change in voltage you can calculate the impedance

Example
Vopen=5V
Vload=4.95V
Rload=100R

4.95V/100R = 49.5mA

(5V-4.95V)/49.5mA = (approx) 1R
Gracias ch
 
Top