use pic10f222 internal absolute voltage refrence












0














I want to use PIC10f222 ADC and have no prolem in it :



#include <10F222.h> 
#list
#device PIC10F222
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOMCPU //Master Clear Pull-up disabled
#FUSES NOMCLR
#FUSES IOSC4 //INTOSC speed 4 MHz
#device adc=8
#use delay(internal=4000000)
#define set_options(value){#ASM
MOVLW value
OPTION
#ENDASM}

setup_adc(true);
set_tris_b (0b111); //set as output
set_options(0xDF); // Enable pin B2 for normal i/o
set_adc_channel(0);
adc1=read_adc();


But, when when VDD changes the ADC shows different values (and that is also OK because the reference voltage is VDD).

I looked in PIC10F222 data sheet and found "absolute voltage refrence" that equals :

result = 0.6 * 256 / VDD
I thougth I can get VDD from the equation above and then get the precise adc value as follow:



adc_set_channel(2); 
adc1=read_adc();
vdd=0.6 * 256 / adc1 ;
adc_set_channel(0);
adc=read_adc();
//get the percise adc in popotion of VDD
....


But the adc1 (absolute voltage reference is not going to chane with different VDD from 4.9 to 5.2),

How can I fix this problem?










share|improve this question
























  • > But the adc1 (absolute voltage refrence is not going to chane with different VDD from 4.9 to 5.2), How can i fix this prroblem?
    – Oleg Mazurov
    Nov 9 '18 at 17:20










  • > But the adc1 (absolute voltage refrence is not going to chane with different VDD from 4.9 to 5.2), How can i fix this prroblem? Are you observing adc1 not changing while changing VDD? Or are you stating this? The latter is incorrect. In C, 'vdd=0.6 * 256 / adc1' will always result in zero, perhaps, that's why you see the behaviour you're describing.
    – Oleg Mazurov
    Nov 9 '18 at 17:31






  • 1




    Your question, as asked, cannot be answered. Over the 4.9 to 5.2 VDD voltage range the ADC result will change about 1 or 2 counts. I do not see a solution in firmware for the PIC10F222.
    – Dan1138
    Nov 10 '18 at 0:57












  • Why are you working with float values?
    – Mike
    Nov 13 '18 at 6:29
















0














I want to use PIC10f222 ADC and have no prolem in it :



#include <10F222.h> 
#list
#device PIC10F222
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOMCPU //Master Clear Pull-up disabled
#FUSES NOMCLR
#FUSES IOSC4 //INTOSC speed 4 MHz
#device adc=8
#use delay(internal=4000000)
#define set_options(value){#ASM
MOVLW value
OPTION
#ENDASM}

setup_adc(true);
set_tris_b (0b111); //set as output
set_options(0xDF); // Enable pin B2 for normal i/o
set_adc_channel(0);
adc1=read_adc();


But, when when VDD changes the ADC shows different values (and that is also OK because the reference voltage is VDD).

I looked in PIC10F222 data sheet and found "absolute voltage refrence" that equals :

result = 0.6 * 256 / VDD
I thougth I can get VDD from the equation above and then get the precise adc value as follow:



adc_set_channel(2); 
adc1=read_adc();
vdd=0.6 * 256 / adc1 ;
adc_set_channel(0);
adc=read_adc();
//get the percise adc in popotion of VDD
....


But the adc1 (absolute voltage reference is not going to chane with different VDD from 4.9 to 5.2),

How can I fix this problem?










share|improve this question
























  • > But the adc1 (absolute voltage refrence is not going to chane with different VDD from 4.9 to 5.2), How can i fix this prroblem?
    – Oleg Mazurov
    Nov 9 '18 at 17:20










  • > But the adc1 (absolute voltage refrence is not going to chane with different VDD from 4.9 to 5.2), How can i fix this prroblem? Are you observing adc1 not changing while changing VDD? Or are you stating this? The latter is incorrect. In C, 'vdd=0.6 * 256 / adc1' will always result in zero, perhaps, that's why you see the behaviour you're describing.
    – Oleg Mazurov
    Nov 9 '18 at 17:31






  • 1




    Your question, as asked, cannot be answered. Over the 4.9 to 5.2 VDD voltage range the ADC result will change about 1 or 2 counts. I do not see a solution in firmware for the PIC10F222.
    – Dan1138
    Nov 10 '18 at 0:57












  • Why are you working with float values?
    – Mike
    Nov 13 '18 at 6:29














0












0








0







I want to use PIC10f222 ADC and have no prolem in it :



#include <10F222.h> 
#list
#device PIC10F222
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOMCPU //Master Clear Pull-up disabled
#FUSES NOMCLR
#FUSES IOSC4 //INTOSC speed 4 MHz
#device adc=8
#use delay(internal=4000000)
#define set_options(value){#ASM
MOVLW value
OPTION
#ENDASM}

setup_adc(true);
set_tris_b (0b111); //set as output
set_options(0xDF); // Enable pin B2 for normal i/o
set_adc_channel(0);
adc1=read_adc();


But, when when VDD changes the ADC shows different values (and that is also OK because the reference voltage is VDD).

I looked in PIC10F222 data sheet and found "absolute voltage refrence" that equals :

result = 0.6 * 256 / VDD
I thougth I can get VDD from the equation above and then get the precise adc value as follow:



adc_set_channel(2); 
adc1=read_adc();
vdd=0.6 * 256 / adc1 ;
adc_set_channel(0);
adc=read_adc();
//get the percise adc in popotion of VDD
....


But the adc1 (absolute voltage reference is not going to chane with different VDD from 4.9 to 5.2),

How can I fix this problem?










share|improve this question















I want to use PIC10f222 ADC and have no prolem in it :



#include <10F222.h> 
#list
#device PIC10F222
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOMCPU //Master Clear Pull-up disabled
#FUSES NOMCLR
#FUSES IOSC4 //INTOSC speed 4 MHz
#device adc=8
#use delay(internal=4000000)
#define set_options(value){#ASM
MOVLW value
OPTION
#ENDASM}

setup_adc(true);
set_tris_b (0b111); //set as output
set_options(0xDF); // Enable pin B2 for normal i/o
set_adc_channel(0);
adc1=read_adc();


But, when when VDD changes the ADC shows different values (and that is also OK because the reference voltage is VDD).

I looked in PIC10F222 data sheet and found "absolute voltage refrence" that equals :

result = 0.6 * 256 / VDD
I thougth I can get VDD from the equation above and then get the precise adc value as follow:



adc_set_channel(2); 
adc1=read_adc();
vdd=0.6 * 256 / adc1 ;
adc_set_channel(0);
adc=read_adc();
//get the percise adc in popotion of VDD
....


But the adc1 (absolute voltage reference is not going to chane with different VDD from 4.9 to 5.2),

How can I fix this problem?







microcontroller pic






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 12:10









Mike

1,9931621




1,9931621










asked Nov 9 '18 at 16:43









Majid.r

3718




3718












  • > But the adc1 (absolute voltage refrence is not going to chane with different VDD from 4.9 to 5.2), How can i fix this prroblem?
    – Oleg Mazurov
    Nov 9 '18 at 17:20










  • > But the adc1 (absolute voltage refrence is not going to chane with different VDD from 4.9 to 5.2), How can i fix this prroblem? Are you observing adc1 not changing while changing VDD? Or are you stating this? The latter is incorrect. In C, 'vdd=0.6 * 256 / adc1' will always result in zero, perhaps, that's why you see the behaviour you're describing.
    – Oleg Mazurov
    Nov 9 '18 at 17:31






  • 1




    Your question, as asked, cannot be answered. Over the 4.9 to 5.2 VDD voltage range the ADC result will change about 1 or 2 counts. I do not see a solution in firmware for the PIC10F222.
    – Dan1138
    Nov 10 '18 at 0:57












  • Why are you working with float values?
    – Mike
    Nov 13 '18 at 6:29


















  • > But the adc1 (absolute voltage refrence is not going to chane with different VDD from 4.9 to 5.2), How can i fix this prroblem?
    – Oleg Mazurov
    Nov 9 '18 at 17:20










  • > But the adc1 (absolute voltage refrence is not going to chane with different VDD from 4.9 to 5.2), How can i fix this prroblem? Are you observing adc1 not changing while changing VDD? Or are you stating this? The latter is incorrect. In C, 'vdd=0.6 * 256 / adc1' will always result in zero, perhaps, that's why you see the behaviour you're describing.
    – Oleg Mazurov
    Nov 9 '18 at 17:31






  • 1




    Your question, as asked, cannot be answered. Over the 4.9 to 5.2 VDD voltage range the ADC result will change about 1 or 2 counts. I do not see a solution in firmware for the PIC10F222.
    – Dan1138
    Nov 10 '18 at 0:57












  • Why are you working with float values?
    – Mike
    Nov 13 '18 at 6:29
















> But the adc1 (absolute voltage refrence is not going to chane with different VDD from 4.9 to 5.2), How can i fix this prroblem?
– Oleg Mazurov
Nov 9 '18 at 17:20




> But the adc1 (absolute voltage refrence is not going to chane with different VDD from 4.9 to 5.2), How can i fix this prroblem?
– Oleg Mazurov
Nov 9 '18 at 17:20












> But the adc1 (absolute voltage refrence is not going to chane with different VDD from 4.9 to 5.2), How can i fix this prroblem? Are you observing adc1 not changing while changing VDD? Or are you stating this? The latter is incorrect. In C, 'vdd=0.6 * 256 / adc1' will always result in zero, perhaps, that's why you see the behaviour you're describing.
– Oleg Mazurov
Nov 9 '18 at 17:31




> But the adc1 (absolute voltage refrence is not going to chane with different VDD from 4.9 to 5.2), How can i fix this prroblem? Are you observing adc1 not changing while changing VDD? Or are you stating this? The latter is incorrect. In C, 'vdd=0.6 * 256 / adc1' will always result in zero, perhaps, that's why you see the behaviour you're describing.
– Oleg Mazurov
Nov 9 '18 at 17:31




1




1




Your question, as asked, cannot be answered. Over the 4.9 to 5.2 VDD voltage range the ADC result will change about 1 or 2 counts. I do not see a solution in firmware for the PIC10F222.
– Dan1138
Nov 10 '18 at 0:57






Your question, as asked, cannot be answered. Over the 4.9 to 5.2 VDD voltage range the ADC result will change about 1 or 2 counts. I do not see a solution in firmware for the PIC10F222.
– Dan1138
Nov 10 '18 at 0:57














Why are you working with float values?
– Mike
Nov 13 '18 at 6:29




Why are you working with float values?
– Mike
Nov 13 '18 at 6:29












1 Answer
1






active

oldest

votes


















0














To read the absolute voltage reference on the 10F2xx PIC families, which is 0.6V, then do this in the CCS C Compiler (which looks like what you are using):



set_adc_channel(2);


If you are using a different compiler, then do this:



ADCON0 = (ADCON0 & 0xF3) | 0xC;


This does not completely answer your question, as you are implying that you want to set the PIC's ADC to use this absolute voltage reference for ADC conversions of the other channels. This PIC does not support this. But you could use the ADC reading of this absolute voltage reference to determine what your VDD actually is, and then make necessary compensation of the ADC reading in software.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53229922%2fuse-pic10f222-internal-absolute-voltage-refrence%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    To read the absolute voltage reference on the 10F2xx PIC families, which is 0.6V, then do this in the CCS C Compiler (which looks like what you are using):



    set_adc_channel(2);


    If you are using a different compiler, then do this:



    ADCON0 = (ADCON0 & 0xF3) | 0xC;


    This does not completely answer your question, as you are implying that you want to set the PIC's ADC to use this absolute voltage reference for ADC conversions of the other channels. This PIC does not support this. But you could use the ADC reading of this absolute voltage reference to determine what your VDD actually is, and then make necessary compensation of the ADC reading in software.






    share|improve this answer


























      0














      To read the absolute voltage reference on the 10F2xx PIC families, which is 0.6V, then do this in the CCS C Compiler (which looks like what you are using):



      set_adc_channel(2);


      If you are using a different compiler, then do this:



      ADCON0 = (ADCON0 & 0xF3) | 0xC;


      This does not completely answer your question, as you are implying that you want to set the PIC's ADC to use this absolute voltage reference for ADC conversions of the other channels. This PIC does not support this. But you could use the ADC reading of this absolute voltage reference to determine what your VDD actually is, and then make necessary compensation of the ADC reading in software.






      share|improve this answer
























        0












        0








        0






        To read the absolute voltage reference on the 10F2xx PIC families, which is 0.6V, then do this in the CCS C Compiler (which looks like what you are using):



        set_adc_channel(2);


        If you are using a different compiler, then do this:



        ADCON0 = (ADCON0 & 0xF3) | 0xC;


        This does not completely answer your question, as you are implying that you want to set the PIC's ADC to use this absolute voltage reference for ADC conversions of the other channels. This PIC does not support this. But you could use the ADC reading of this absolute voltage reference to determine what your VDD actually is, and then make necessary compensation of the ADC reading in software.






        share|improve this answer












        To read the absolute voltage reference on the 10F2xx PIC families, which is 0.6V, then do this in the CCS C Compiler (which looks like what you are using):



        set_adc_channel(2);


        If you are using a different compiler, then do this:



        ADCON0 = (ADCON0 & 0xF3) | 0xC;


        This does not completely answer your question, as you are implying that you want to set the PIC's ADC to use this absolute voltage reference for ADC conversions of the other channels. This PIC does not support this. But you could use the ADC reading of this absolute voltage reference to determine what your VDD actually is, and then make necessary compensation of the ADC reading in software.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 19 '18 at 2:02









        da66en

        819




        819






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53229922%2fuse-pic10f222-internal-absolute-voltage-refrence%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Lugert, Oklahoma