[SOLVED !] Taking advantage of the internal voltage references of the 18F25k22 chip on ADC conv.


Closed Thread
Results 1 to 10 of 10
  1. #1
    Member yvesmazzon's Avatar
    Join Date
    Jul 2006
    Posts
    222
    Thumbs Up
    Received: 6
    Given: 38
    Total Downloaded
    11.59 GB

    0 Not allowed!

    Default Taking advantage of the internal voltage references of the 18F25k22 chip on ADC conv.

    Hello all,

    I like to take advantage of the fix voltage references FVREF of 18F25K22 chip for my ADC conversions. I have at the moment this declaration which uses uAmicus18_ADC.inc and "OpenADC(ADC_FOSC_16 & ADC_RIGHT_JUST & ADC_20_TAD, ADC_REF_VDD_VSS, ADC_5ANA)" which refers to VDD. How do I change my OpenADC(....) to use the internal voltage references. I supposed I have to modify the FVR BUF2 on the ADCON1 and the VREFCON0 to turn on and get the right voltage reference? Many thanks in advance for your help.

    Regards,

    Yves

  2. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Senior Member GAMBOA's Avatar
    Join Date
    Nov 2004
    Posts
    462
    Thumbs Up
    Received: 22
    Given: 0
    Total Downloaded
    216.42 MB

    0 Not allowed!

    Default Re: Taking advantage of the internal voltage references of the 18F25k22 chip on ADC c

    Hi Yves,

    I dont use Amicus18.
    I used Pic18F26K22 for a project adjusting FRV for the ADC. Basically what I do is adjust the FSR registers directly.

    Initialization of registers SFR:

    'REGISTER 21-1: VREFCON0: FIXED VOLTAGE REFERENCE CONTROL REGISTER
    'Uso la referancia interna de tensión para el convertidor ADC a 4.096V.
    VREFCON0 = 110000
    'FVREN = VREFCON0.7,: Fixed Voltage Reference Enable bit activado
    'FVRST = VREFCON0.6: Fixed Voltage Reference Ready Flag bit, ready for use
    'FVRS1 = VREFCON0.5: Fixed Voltage Reference Selection bits,
    'FVRS0 = VREFCON0.4 11 = Fixed Voltage Reference Peripheral output is 4x (4.096V)
    'La tensión de referencia de 4.096 V solo funciona correctamente para valores de alimentación por encima de
    '4.75V, se observa que con baterías por debajo de 4.5V, el valor calculado del ADC es erróneo.
    'Un ajuste manual de contraste ha de hacerse cuando la tensión de las pilas cae por debajo de 4.2V

    'REGISTER 17-1: ADCON0: A/D CONTROL REGISTER 0
    ADCON0 = 110000
    'Selecciona canal AN12, y apaga el convertidor ADC.

    'REGISTER 17-2: ADCON1: A/D CONTROL REGISTER 1
    ADCON1 = 001000
    'Selecciona la referencia de tensión positiva a FVR 4.096
    'Selecciona la referencia de tensión negativa a masa

    'REGISTER 17-3: ADCON2: A/D CONTROL REGISTER 2
    ADCON2 = 001110
    'ADFM: A/D Conversion Result Format Select bit. 1= Right justified
    'ACQT<2:0>:A/D Acquisition time select bits. 001= 2 TAD
    'ADCS<2:0>:A/D Conversion Clock Select bits. 110= FOSC/64 = 1us
    Voltage measurement routine:

    '************************************************* ************************
    '** SUBRUTINA: MedirTension
    '** Mido tensión de alimentación
    '**
    '************************************************* ************************

    MedirTension:
    ADON = 1 'Activo el convertidor ADC
    MedidaADC = 0
    GO_DONE = 1 'Arranco la medida
    WHILE GO_DONE = 1
    'Espero la conversión
    WEND
    MedidaADC.BYTE0 = ADRESL
    MedidaADC.BYTE1 = ADRESH
    ADON = 0 'apago el convertidor ADC

    RETURN

    '** FIN SUBRUTINA: MedirTension
    Regards,
    Gamboa

  4. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Member yvesmazzon's Avatar
    Join Date
    Jul 2006
    Posts
    222
    Thumbs Up
    Received: 6
    Given: 38
    Total Downloaded
    11.59 GB

    0 Not allowed!

    Default Re: Taking advantage of the internal voltage references of the 18F25k22 chip on ADC c

    Many thanks for your time Gamboa,
    I will try to adapt your code to my program and see how it goes.
    Nevertheless I had a long look at the Amicus18_ADC.inc routines Les has wrote a while ago but I couldn't find if the ADC setup "OpenADC(....)" has an option for using the fix voltage reference FVR for the 18F25k22 chip. Is any one knows?

    Regards,

    Yves

  6. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Senior Member AlbertoFS's Avatar
    Join Date
    Apr 2005
    Posts
    693
    Thumbs Up
    Received: 92
    Given: 2
    Total Downloaded
    4.62 GB

    0 Not allowed!

    Default Re: Taking advantage of the internal voltage references of the 18F25k22 chip on ADC c

    You could see this code in the wiki.
    73's de Alberto ea3agv

  8. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Member yvesmazzon's Avatar
    Join Date
    Jul 2006
    Posts
    222
    Thumbs Up
    Received: 6
    Given: 38
    Total Downloaded
    11.59 GB

    0 Not allowed!

    Default Re: Taking advantage of the internal voltage references of the 18F25k22 chip on ADC c

    Thank you Alberto,

    When I put the micro "OpenADC(ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_20_TAD, ADC_CH0, ADC_REF_VDD_FVREF, ADC_17ANA)" and compile I get an error like "ADC_CH0, ADC_REF_VDD_FVREF" not found though I have the Amicus_ADC.inc and Amicus18_25k22.inc in the include. Can you please help with this? Thank you.
    Could it be that "ADC_CH0, ADC_REF_VDD_FVREF" is not in the Amicus_ADC.inc?

    Regards
    Last edited by yvesmazzon; 4th September 2017 at 08:48. Reason: omition

  10. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Senior Member AlbertoFS's Avatar
    Join Date
    Apr 2005
    Posts
    693
    Thumbs Up
    Received: 92
    Given: 2
    Total Downloaded
    4.62 GB

    0 Not allowed!

    Default Re: Taking advantage of the internal voltage references of the 18F25k22 chip on ADC c

    Hi Yves ,

    Using "Amicus18_26K22.inc" and my library "Amicus_ADC.Inc".


    To configure the reference voltages of the ADC, you must configure the V + and V- as you know.
    You can choose an individual configuration for V + and V- (V + & V-) or choose a combination configuration. (only one config).

    My code is a correction of the original library. I have not added new combined settings for all possibilities of the ADC references.

    Then you have 2 typographical errors.

    ADC_REF_VDD_FVREF is => _ADC_REF_VDD_FVREF

    Then the correct configuration is:
    _ADC_REF_VDD_FVREF & _ADC_REF_VSS_VSS
    (111011 = A/D VREF+ connected to internal signal, FVR BUF2) And (111100 ADC voltage source VREF- = AVSS)

    It means:
    OpenADC(ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_20_TAD, ADC_CH0, _ADC_REF_VDD_FVREF & _ADC_REF_VSS_VSS, ADC_17ANA)

    The compiled code is for _ADC_REF_VDD_FVREF & _ADC_REF_VSS_VSS
    movlw (248 & 0X0F)
    movwf ADCON1

    It is the same as:
    ADCON1 = %00001000
    It seems correct.

    Regards
    Alberto
    Last edited by AlbertoFS; 4th September 2017 at 15:34.
    73's de Alberto ea3agv

  12. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Member yvesmazzon's Avatar
    Join Date
    Jul 2006
    Posts
    222
    Thumbs Up
    Received: 6
    Given: 38
    Total Downloaded
    11.59 GB

    0 Not allowed!

    Default Re: Taking advantage of the internal voltage references of the 18F25k22 chip on ADC c

    Hello Alberto,

    Many thanks for your correction, it makes good logical sense. Now I understand better the macro and will test it tonight. I suppose I have to modify the register to VREFCON0 = %10110000 to unable the REF generator and to set the FVR to 4.096 and correct the quanta factor to "Result2 = ADC_Result * 4096 / 1023".
    Yes it works like a charm. Thanks again.
    Just one more question my signal is less than maximum 800mV is anything wrong to set the FVR to its minimum of 1.024V to increase the sensitivity that should give a resolution of 1mV/bit?

    Regards,

    Yves

  14. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    Senior Member AlbertoFS's Avatar
    Join Date
    Apr 2005
    Posts
    693
    Thumbs Up
    Received: 92
    Given: 2
    Total Downloaded
    4.62 GB

    1 Not allowed!

    Default Re: Taking advantage of the internal voltage references of the 18F25k22 chip on ADC c

    Hi Yves,
    I believe there is no difficulty. I have tested with ISIS and the results seem correct. However it is advisable to check the FOSC of the ADC, see the compatibility table in the PIC datasheet. The correct setting could be "ADC_FOSC_64" or "ADC_FOSC_FRC1" if the "Declare Xtal" is equal to 64.

    Personally, when I use the internal ADC, I avoid loading the digital pins of the high current ports (<0.5mA) to reduce noise, especially when using the +VDD as a reference. It is better to use buffers or transistors to drive high load like LEDs and others. Using FVR reference is better.
    In this case the design of the PCB is of primary importance.

    I tested FVR with 1.024V with ISIS.

    I wish you much success in your project.
    Regards
    Alberto
    AmicusADC_FVR.zip
    Last edited by AlbertoFS; 4th September 2017 at 22:35.
    73's de Alberto ea3agv

  16. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #9
    Prolific Poster John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,956
    Thumbs Up
    Received: 94
    Given: 34
    Total Downloaded
    5.14 GB

    0 Not allowed!

    Default Re: Taking advantage of the internal voltage references of the 18F25k22 chip on ADC c

    Hi Yves,
    I notice in your formula for calculating the result you are dividing by 1023. Remember there are 1024 levels (0 is a level) so you should divide by 1024.
    John

  18. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  19. #10
    Member yvesmazzon's Avatar
    Join Date
    Jul 2006
    Posts
    222
    Thumbs Up
    Received: 6
    Given: 38
    Total Downloaded
    11.59 GB

    0 Not allowed!

    Default Re: Taking advantage of the internal voltage references of the 18F25k22 chip on ADC c

    Thanks John,

    Advice taken.

    Regards,

    Yves

  20. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. [SOLVED !] Speed up rate of taking ADC values
    By Dave-S in forum Proton Plus Compiler v3
    Replies: 14
    Last Post: 16th June 2015, 05:36
  2. [SOLVED !] Internal 12bit adc or external chip MCP3204
    By VaGyver in forum Analog-to-Digital Converter Module
    Replies: 0
    Last Post: 21st April 2015, 21:54
  3. Monitoring Battery voltage using internal ref - 18F14K50
    By SimonJA in forum Proton Plus Compiler v3
    Replies: 18
    Last Post: 8th January 2012, 16:35
  4. [SOLVED !] Reading Negative Voltage with adc
    By Roshan in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 31st March 2008, 05:40
  5. [SOLVED !] help - more efficient adc voltage calculation needed
    By heliaddict in forum Proton Plus Compiler v3
    Replies: 31
    Last Post: 9th November 2007, 11:08

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts