Hello Vasile,

Thank you for your input.
About Vref it should be set to VCC (5V) and GND. It's the default anyways 
(by the Datasheet info).
Have, however, noticed that the ADC initial configuration constants don't 
match with the needed ones.
EX: ANSEL_ADCS, ADCON0_VCFG, ANSEL_ANS0, etc.. aren't used in ADC lib or 
even in PIC(18F2523) lib.

About convertion time and MAX_TAD, have already tested longer time values 
with no sucess...
Any more ideas?
Thanks anyways.

Cheers,
Filipe Santos.

On Wednesday, September 14, 2022 at 12:57:26 PM UTC+1 vasile wrote:

> 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 <fsfo...@gmail.com> 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 jallib+un...@googlegroups.com.
>> 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 jallib+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/02e80c7d-9c0e-4b39-ae35-9ace88a28afen%40googlegroups.com.

Reply via email to