[SOLVED !] 12f683 a/d mutliple buttons


Closed Thread
Results 1 to 5 of 5

Thread: 12f683 a/d mutliple buttons2591 days old

  1. #1
    danbicks
    Guest danbicks's Avatar

    0 Not allowed!

    Default 12f683 a/d mutliple buttons

    Hi Guys,

    I am sure this has been done before, and the idea is simple using an a/d to read a potential divider voltage and convert to a button beying pressed.

    Here is the idea if I have 5 x 10k resistor all in series, top end of resistor goes to +5v there should be 1volt drop across each resistor, good old ohms law.

    A push button will be connected to each divider point in the chain giving me 4 buttons for a five resistor combination, more could be added if need be. Then I simply sample the voltage, if its 4volts then no button has been pressed if it is different from this a button has been pressed.

    My question is has anyone posted code similar to this, and how reliable from mis readings would this method be?

    Big thanks wizkids

    Dans

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.

  • #2
    Senior Member barak's Avatar
    Join Date
    Apr 2008
    Posts
    725
    Thumbs Up
    Received: 30
    Given: 11
    Total Downloaded
    1.53 GB

    0 Not allowed!

    Default Re: 12f683 a/d mutliple buttons

    I think if you want to sense multiple switches pressed simultaneously, you need to do it in parallel. I would use resistors in "binary" ratio.
    Code:
     
          _ VCC
          |
          |     10K                           220
          ----/\/\/\--|-----------------.----/\/\/\---> ADC
                      |                _|_
                      |                ___ 10nF
                      |                 |
                      |                 |
                      |--%---/\/\/\-----|160K
                      |--%---/\/\/\-----|80K
                      |--%---/\/\/\-----|40K
                      |--%---/\/\/\-----|20K
                                        |
                                       --- VSS
                                        -
    This way each switches combination will give you a distinct value that you can use in a lookup table. Donít forget accuracy, temperature etc will affect the circuit so the table needs to correlate a switch combination to a min.-max. range.
    This can also be done without ADC by measuring the RC time:
    Code:
         
                      _ VCC
                      |                
                      |                
                      |------/\/\/\-----|160K
                      |--%---/\/\/\-----|80K
                      |--%---/\/\/\-----|40K
                      |--%---/\/\/\-----|20K
                      |--%---/\/\/\-----|10K     220
                                        |------/\/\/\---> I/O
                                       _|_
                                       ___ 0.1uF
                                        |
                                        |
                                        |                                                                      
                                       --- VSS
                                        -

  • 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
    danbicks
    Guest danbicks's Avatar

    0 Not allowed!

    Default Re: 12f683 a/d mutliple buttons

    Barak,

    Brilliant, I did not think of this using two or three combinations of buttons being pressed at the same time, excellent and yes this may be a requirement and would allow for more combinations. Temperature change is also a very good point. Right I am of to work coding big thanks mate.

    Dans

  • 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.

  • #4
    Senior Member barak's Avatar
    Join Date
    Apr 2008
    Posts
    725
    Thumbs Up
    Received: 30
    Given: 11
    Total Downloaded
    1.53 GB

    0 Not allowed!

    Default Re: 12f683 a/d mutliple buttons

    Don't forget to do some averaging before you determine which switch(s) is/are closed

  • 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
    Senior Member barak's Avatar
    Join Date
    Apr 2008
    Posts
    725
    Thumbs Up
    Received: 30
    Given: 11
    Total Downloaded
    1.53 GB

    0 Not allowed!

    Default Re: 12f683 a/d mutliple buttons

    Just to clarify,
    The use of "binary" ratio for the resistors is so that the output will be in some in relation to the binary values represented by the switches.

    In the drawing I posted, SW0 is on the 160K, SW1 on 80K, SW2 on 40K and SW3 on 20K.

    So for 0000 you get VCC and for 1111 you get a divider formed by the 10K and all 4 resistors in parallel which is 10.7K so the voltage will be close to 2.5V.
    You can change the scale by selecting values other than 10K.

    For the example I posted with VCC=5VDC, 10K top resistor these are the values you should expect:

    Code:
    SW %   R-||||     Vo 
            ohm      Vdc
    -----   -----   -------
    1111    10.7     2.58
    1110    11.4     2.67
    1101    12.3     2.76
    1100    13.3     2.86
    1011    14.5     2.96
    1010    16.0     3.08
    1001    17.8     3.20
    1000    20.0     3.33
    0111    22.9     3.48
    0110    26.7     3.64
    0101    32.0     3.81
    0100    40.0     4.00
    0011    53.3     4.21
    0010    80.0     4.44
    0001    160.0    4.71
    0000 infinity    5.00

  • 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. Snow buttons
      By [email protected] in forum The Lounge
      Replies: 11
      Last Post: 19th December 2015, 06:12
    2. [SOLVED !] need help on interupts and buttons
      By suxtronix in forum Proton Plus Compiler v3
      Replies: 5
      Last Post: 4th February 2010, 01:19
    3. 2 Tactile Buttons
      By t0pP8uZz in forum Proton Plus Compiler v3
      Replies: 9
      Last Post: 26th November 2009, 18:28
    4. Buttons, Buttons.....Help!
      By DanRiches in forum The Lounge
      Replies: 9
      Last Post: 24th November 2008, 16:04
    5. [SOLVED !] Normally closed buttons
      By john burke in forum Labcenter Proteus VSM
      Replies: 10
      Last Post: 15th January 2006, 20:29

    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