If your Vref + is +5V and Vref- is GND, full scale means 4095 at 5V.
One issue might appear if acquisition time is too short or you have messed
something with references.
|Vref+| - |Vref-| >=3V

On Tue, Sep 13, 2022 at 4:54 PM flyway38 <[email protected]> wrote:

> Hello all,
>
> New question.
> My PIC is reading ok ADC values if below 2.5V (1/2 of range VCC/GND).
> It seems like 11bit ADC behaviour.
>
> My code:
> -- ok, now let's configure ADC
> -- Step 1: ADC analog input pin setup
> const byte ADC_CHANNEL = 0                       -- port 0 is analog input
> (default)
> pin_AN0_direction = input
> const byte ANSEL_ANS0 = TRUE                     -- potmeter connected to
> pin_AN0
> -- Step 2: Set VDD and VSS as Vref
> const byte ADCON0_VCFG = FALSE
> -- Step 3: Use Frc as ADC clock
> const byte ANSEL_ADCS = 0b110
> --
> const ADC_RSOURCE = 500                          -- Input Resistance
> const ADC_TEMP = 20                              -- PIC Temperature
> -- We want the fastest possible ADC timing, so we specify here the
> --const ADC_MIN_TAD = 1
> const ADC_MAX_TAD = 10
> -- Now we can include the library
> include adc
> -- And initialize the whole with our parameters
> adc_init()
>
> Inside Forever Loop:
>    iVal = 0 -- Its a DWord
>    --
>    for AdcReadings loop
>       AdcData = adc_read_high_res(AdcChnn)
>       iVal = iVal + dword(AdcData)
>    end loop
>    --
>    mVal = word(iVal / dword(AdcReadings))
>
> Any help would be great.
> Thank you very much.
>
> Kind regrads,
> Filipe Santos
>
> --
> You received this message because you are subscribed to the Google Groups
> "jallib" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jallib/5c020fb1-f8fa-4684-9284-1dc3a1793ca4n%40googlegroups.com
> <https://groups.google.com/d/msgid/jallib/5c020fb1-f8fa-4684-9284-1dc3a1793ca4n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/CAM%2Bj4qsF_eamLFEKX07BT32tjCFNWkkVptnjmDnijcQRmnhHKg%40mail.gmail.com.

Reply via email to