MCP3008 analogue digital converter… how can I use it for the complete opposite of what it was made for?












1














I have set up an mcp3008 chip and a slide pot on my pi because I wanted a nice old fashioned volume control, and all of that seems to working fine and I am quite happy with it.



Now I have 7 redundant analogue channels, which I would quite like to repurpose as simple on/off buttons, because the chip just happens to be there and it would save a bunch of gpio pins which I could use for more interesting stuff.



My problem is, they seem to float wildly all over the place when there is no voltage running through them, so while I can add a switch to one and read 3.3v reliably enough, when the switch is off they just read a bunch of noise. This doesn't happen with the slide pot, presumably since one end is grounded.



Can anyone suggest a simple solution ?



Shall I just live with the noise , or is there something really obvious I am missing?



Bear in mind I am asking because I am a complete moron as far as electronics are concerened, so no answer can be too patronising :)










share|improve this question




















  • 1




    Hello and welcome. Is there any way you could make that question's title more comprehensible? I am still trying to figure out what the opposite of an ADC is (other than the obvious a DAC...).
    – Ghanima
    Dec 13 '18 at 22:08
















1














I have set up an mcp3008 chip and a slide pot on my pi because I wanted a nice old fashioned volume control, and all of that seems to working fine and I am quite happy with it.



Now I have 7 redundant analogue channels, which I would quite like to repurpose as simple on/off buttons, because the chip just happens to be there and it would save a bunch of gpio pins which I could use for more interesting stuff.



My problem is, they seem to float wildly all over the place when there is no voltage running through them, so while I can add a switch to one and read 3.3v reliably enough, when the switch is off they just read a bunch of noise. This doesn't happen with the slide pot, presumably since one end is grounded.



Can anyone suggest a simple solution ?



Shall I just live with the noise , or is there something really obvious I am missing?



Bear in mind I am asking because I am a complete moron as far as electronics are concerened, so no answer can be too patronising :)










share|improve this question




















  • 1




    Hello and welcome. Is there any way you could make that question's title more comprehensible? I am still trying to figure out what the opposite of an ADC is (other than the obvious a DAC...).
    – Ghanima
    Dec 13 '18 at 22:08














1












1








1







I have set up an mcp3008 chip and a slide pot on my pi because I wanted a nice old fashioned volume control, and all of that seems to working fine and I am quite happy with it.



Now I have 7 redundant analogue channels, which I would quite like to repurpose as simple on/off buttons, because the chip just happens to be there and it would save a bunch of gpio pins which I could use for more interesting stuff.



My problem is, they seem to float wildly all over the place when there is no voltage running through them, so while I can add a switch to one and read 3.3v reliably enough, when the switch is off they just read a bunch of noise. This doesn't happen with the slide pot, presumably since one end is grounded.



Can anyone suggest a simple solution ?



Shall I just live with the noise , or is there something really obvious I am missing?



Bear in mind I am asking because I am a complete moron as far as electronics are concerened, so no answer can be too patronising :)










share|improve this question















I have set up an mcp3008 chip and a slide pot on my pi because I wanted a nice old fashioned volume control, and all of that seems to working fine and I am quite happy with it.



Now I have 7 redundant analogue channels, which I would quite like to repurpose as simple on/off buttons, because the chip just happens to be there and it would save a bunch of gpio pins which I could use for more interesting stuff.



My problem is, they seem to float wildly all over the place when there is no voltage running through them, so while I can add a switch to one and read 3.3v reliably enough, when the switch is off they just read a bunch of noise. This doesn't happen with the slide pot, presumably since one end is grounded.



Can anyone suggest a simple solution ?



Shall I just live with the noise , or is there something really obvious I am missing?



Bear in mind I am asking because I am a complete moron as far as electronics are concerened, so no answer can be too patronising :)







gpio analog-to-digital






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 12 '18 at 19:41









akasoggybunz

537




537










asked Dec 12 '18 at 15:46









Laurie Chilvers

91




91








  • 1




    Hello and welcome. Is there any way you could make that question's title more comprehensible? I am still trying to figure out what the opposite of an ADC is (other than the obvious a DAC...).
    – Ghanima
    Dec 13 '18 at 22:08














  • 1




    Hello and welcome. Is there any way you could make that question's title more comprehensible? I am still trying to figure out what the opposite of an ADC is (other than the obvious a DAC...).
    – Ghanima
    Dec 13 '18 at 22:08








1




1




Hello and welcome. Is there any way you could make that question's title more comprehensible? I am still trying to figure out what the opposite of an ADC is (other than the obvious a DAC...).
– Ghanima
Dec 13 '18 at 22:08




Hello and welcome. Is there any way you could make that question's title more comprehensible? I am still trying to figure out what the opposite of an ADC is (other than the obvious a DAC...).
– Ghanima
Dec 13 '18 at 22:08










2 Answers
2






active

oldest

votes


















6














You will have to use a Pull-Up resistor to get clean difference between the two desired states.

This way you will have no floating input but either VCC (3.3V) or GND (0.0V) at the input of your MCP3008.

(You can ignore the logic gate in the image).



(Alternatively a Pull-Down resistor will work just as well).






share|improve this answer

















  • 2




    Something which confused me when I first heard of it: "pull-up" is not a special kind of resistor, it is a particular use for one ;)
    – goldilocks
    Dec 12 '18 at 16:40








  • 2




    I would try a 10k resistor per channel. That would not draw a great deal of current, would easily be defeated by a button, but would also resist random interference on the channel.
    – joan
    Dec 12 '18 at 16:56



















1














A pull up/down resistor is the correct solution - the question is which way do you want to be default? Based on your description you are going to want a pull down. Why? You say that if "the switch is on, I can read 3.3V" - which makes me think that you have the switch wired to 3.3V and want to see a logical 1 when it is closed, logical 0 when open. In this case, by using a pull down an open circuit (the switch) reads as a zero. This has the added advantage of not pulling current unless the switch is closed. The most important thing you've learned here is it is generally not a good idea to leave inputs floating.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("schematics", function () {
    StackExchange.schematics.init();
    });
    }, "cicuitlab");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "447"
    };
    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: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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%2fraspberrypi.stackexchange.com%2fquestions%2f91870%2fmcp3008-analogue-digital-converter-how-can-i-use-it-for-the-complete-opposite%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    6














    You will have to use a Pull-Up resistor to get clean difference between the two desired states.

    This way you will have no floating input but either VCC (3.3V) or GND (0.0V) at the input of your MCP3008.

    (You can ignore the logic gate in the image).



    (Alternatively a Pull-Down resistor will work just as well).






    share|improve this answer

















    • 2




      Something which confused me when I first heard of it: "pull-up" is not a special kind of resistor, it is a particular use for one ;)
      – goldilocks
      Dec 12 '18 at 16:40








    • 2




      I would try a 10k resistor per channel. That would not draw a great deal of current, would easily be defeated by a button, but would also resist random interference on the channel.
      – joan
      Dec 12 '18 at 16:56
















    6














    You will have to use a Pull-Up resistor to get clean difference between the two desired states.

    This way you will have no floating input but either VCC (3.3V) or GND (0.0V) at the input of your MCP3008.

    (You can ignore the logic gate in the image).



    (Alternatively a Pull-Down resistor will work just as well).






    share|improve this answer

















    • 2




      Something which confused me when I first heard of it: "pull-up" is not a special kind of resistor, it is a particular use for one ;)
      – goldilocks
      Dec 12 '18 at 16:40








    • 2




      I would try a 10k resistor per channel. That would not draw a great deal of current, would easily be defeated by a button, but would also resist random interference on the channel.
      – joan
      Dec 12 '18 at 16:56














    6












    6








    6






    You will have to use a Pull-Up resistor to get clean difference between the two desired states.

    This way you will have no floating input but either VCC (3.3V) or GND (0.0V) at the input of your MCP3008.

    (You can ignore the logic gate in the image).



    (Alternatively a Pull-Down resistor will work just as well).






    share|improve this answer












    You will have to use a Pull-Up resistor to get clean difference between the two desired states.

    This way you will have no floating input but either VCC (3.3V) or GND (0.0V) at the input of your MCP3008.

    (You can ignore the logic gate in the image).



    (Alternatively a Pull-Down resistor will work just as well).







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 12 '18 at 15:50









    kwasmich

    1,619718




    1,619718








    • 2




      Something which confused me when I first heard of it: "pull-up" is not a special kind of resistor, it is a particular use for one ;)
      – goldilocks
      Dec 12 '18 at 16:40








    • 2




      I would try a 10k resistor per channel. That would not draw a great deal of current, would easily be defeated by a button, but would also resist random interference on the channel.
      – joan
      Dec 12 '18 at 16:56














    • 2




      Something which confused me when I first heard of it: "pull-up" is not a special kind of resistor, it is a particular use for one ;)
      – goldilocks
      Dec 12 '18 at 16:40








    • 2




      I would try a 10k resistor per channel. That would not draw a great deal of current, would easily be defeated by a button, but would also resist random interference on the channel.
      – joan
      Dec 12 '18 at 16:56








    2




    2




    Something which confused me when I first heard of it: "pull-up" is not a special kind of resistor, it is a particular use for one ;)
    – goldilocks
    Dec 12 '18 at 16:40






    Something which confused me when I first heard of it: "pull-up" is not a special kind of resistor, it is a particular use for one ;)
    – goldilocks
    Dec 12 '18 at 16:40






    2




    2




    I would try a 10k resistor per channel. That would not draw a great deal of current, would easily be defeated by a button, but would also resist random interference on the channel.
    – joan
    Dec 12 '18 at 16:56




    I would try a 10k resistor per channel. That would not draw a great deal of current, would easily be defeated by a button, but would also resist random interference on the channel.
    – joan
    Dec 12 '18 at 16:56













    1














    A pull up/down resistor is the correct solution - the question is which way do you want to be default? Based on your description you are going to want a pull down. Why? You say that if "the switch is on, I can read 3.3V" - which makes me think that you have the switch wired to 3.3V and want to see a logical 1 when it is closed, logical 0 when open. In this case, by using a pull down an open circuit (the switch) reads as a zero. This has the added advantage of not pulling current unless the switch is closed. The most important thing you've learned here is it is generally not a good idea to leave inputs floating.






    share|improve this answer


























      1














      A pull up/down resistor is the correct solution - the question is which way do you want to be default? Based on your description you are going to want a pull down. Why? You say that if "the switch is on, I can read 3.3V" - which makes me think that you have the switch wired to 3.3V and want to see a logical 1 when it is closed, logical 0 when open. In this case, by using a pull down an open circuit (the switch) reads as a zero. This has the added advantage of not pulling current unless the switch is closed. The most important thing you've learned here is it is generally not a good idea to leave inputs floating.






      share|improve this answer
























        1












        1








        1






        A pull up/down resistor is the correct solution - the question is which way do you want to be default? Based on your description you are going to want a pull down. Why? You say that if "the switch is on, I can read 3.3V" - which makes me think that you have the switch wired to 3.3V and want to see a logical 1 when it is closed, logical 0 when open. In this case, by using a pull down an open circuit (the switch) reads as a zero. This has the added advantage of not pulling current unless the switch is closed. The most important thing you've learned here is it is generally not a good idea to leave inputs floating.






        share|improve this answer












        A pull up/down resistor is the correct solution - the question is which way do you want to be default? Based on your description you are going to want a pull down. Why? You say that if "the switch is on, I can read 3.3V" - which makes me think that you have the switch wired to 3.3V and want to see a logical 1 when it is closed, logical 0 when open. In this case, by using a pull down an open circuit (the switch) reads as a zero. This has the added advantage of not pulling current unless the switch is closed. The most important thing you've learned here is it is generally not a good idea to leave inputs floating.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 12 '18 at 23:09









        user95070

        111




        111






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Raspberry Pi Stack Exchange!


            • 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%2fraspberrypi.stackexchange.com%2fquestions%2f91870%2fmcp3008-analogue-digital-converter-how-can-i-use-it-for-the-complete-opposite%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

            Plaza Victoria

            Puebla de Zaragoza

            Musa