Searching \ for '3 pushbuttons to 2 inputs?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: massmind.org/techref/ios.htm?key=input
Search entire site for: '3 pushbuttons to 2 inputs?'.

Truncated match.
PICList Thread
'3 pushbuttons to 2 inputs?'
1997\12\22@112658 by Jason Wolfson

flavicon
face
part 0 813 bytes
!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
Does anyone have any clever, low parts count
methods of multiplexing 3 pushbuttons onto
2 port pins?
 
Thanks
Jason Wolfson
Lipidex Corp
 
jason@lipidex.com

1997\12\22@130637 by Philip Martin

flavicon
picon face
In article <01bd0ef3$be656600$spam_OUTb04206d1TakeThisOuTspamlipidex.ma.ultranet.com>, Jason
Wolfson <.....jasonKILLspamspam@spam@LIPIDEX.COM> writes
>Does anyone have any clever, low parts count
>methods of multiplexing 3 pushbuttons onto
>2 port pins?
>
>Thanks
>Jason Wolfson
>Lipidex Corp
>
>jasonspamKILLspamlipidex.com
Easy,

Switch one connects to pin one.
Switch two connects to pin two.

Switch three connects to both pin one and two, each connection via an
IN4148 diode.

Would have done it in asci picture but my art is crap:-)

--
Philip Martin   ----------------------------------------------------------------
Royal Quays             If at first you don't succeed, try again. Then quit:
North Shields.          no use being a damn fool about it !
                                                       W.C. Fields
email .....philipKILLspamspam.....philmart.demon.co.uk

1997\12\22@132651 by John Payson

picon face
> Switch one connects to pin one.
> Switch two connects to pin two.
>
> Switch three connects to both pin one and two, each connection via an
> IN4148 diode.

Slightly easier approach:

[1] Switch one connects pin one to ground
[2] Switch two connects pin two to ground
[3] Switch three connects pin one to pin two

To read switches one and two, set the port pins to input (with pullups
enabled).  To read switch three, ground one port pin and read the other.

I've managed to get eight switches with 2 I/O pins and one input-only pin
using only two resistors as external components.  In practice, I'd say it's
usually better not to scrunch things quite that much.

1997\12\22@135624 by Dmitry Kiryashov

flavicon
face
Jason Wolfson wrote:
>
> Does anyone have any clever, low parts count
> methods of multiplexing 3 pushbuttons onto
> 2 port pins?

Just ideas:

1.
First PIC pin (in output mode) clock a shift register with running
"0" or "1". Shift register switch the keys. To eliminate the additional
switches apply shift register with open collector outputs.
First PIC pin (in input mode) read the out of 1-st cascade of the shift
register to detect situation when scan impulse placed in first position.
(clocking and reading through the one pin require additional elements
such as resitors and transistor(or diode) )
Second PIC pin read the keys level.

2.
First PIC pin through simple low-pass RC filter connected to data input
of shift register and directly connected to clock input of register.
To write "1" to register send the following pulse: (shift register have
to be fall_clocked)
+--------------+
|              V
-+              +----

To write the "0" to register send another pulse:
               +--+
               |  V
----------------+  +-

Due to that trick you have ability to write any information into shift
register.
Second PIC pin read the keys level(the same as in 1-st idea).

But i think will be much easy to add third PIC pin and scan keys
directly.

WBR Dmitry.

1997\12\22@142119 by Dmitry Kiryashov

flavicon
face
John Payson wrote:
>
> > Switch one connects to pin one.
> > Switch two connects to pin two.
> >
> > Switch three connects to both pin one and two, each connection via an
> > IN4148 diode.
>
> Slightly easier approach:
>
> [1] Switch one connects pin one to ground
> [2] Switch two connects pin two to ground
> [3] Switch three connects pin one to pin two
>
> To read switches one and two, set the port pins to input (with pullups
> enabled).  To read switch three, ground one port pin and read the other.

To detect one key this method work fine. But this method don't allow
to detect keys combinations. For example Sw_1+Sw_2 result to the same
scan code as Sw_2+Sw_3 or Sw_1+Sw_3 (00_0).

WBR Dmitry.

1997\12\22@143559 by Robert Nansel

flavicon
face
Jason Wolfson wrote:
--------8<--------
>>Does anyone have any clever, low parts count
>>methods of multiplexing 3 pushbuttons onto
>>2 port pins?
--------8<--------

Then Philip Martin replied:

--------8<--------
>Easy,
>
>Switch one connects to pin one.
>Switch two connects to pin two.
>
>Switch three connects to both pin one and two, each connection via an
>IN4148 diode.
--------8<--------

The problem with this (which may not be a problem, depending on the
application) is that you can't distinguish between switch 3 being pressed
vs. switches 1 & 2 being pressed simultaneously. Without some kind of
lockout circuitry in the encoder, there's no way to do this with just a
diode/resistor matrix alone.

That being said, you might be able to do something using diodes & pullup
resistors in conjunction with time multiplexing code to sort out which
switch (or combination) is being pressed. It would go something like this:

B0, B1 are the I/O pins, SW1-SW3 are the switches. SW1 is connected between
B0 & B1 with its diode D1 in series, and SW2 its diode D2 are connected
antiparallel. SW3 is connected to both B0 & B1 through two steering diodes,
D3 & D4:



                      Vcc
 SW3                   |
    __I__              R1
                +      |                           |
+---o   o---o----D3----o--------o----------o-------| B0
|           |                   |          |       |
R3          |             SW1 | o    SW2 | o       |
|           |                -|         -|         |
Gnd          |                 | o        | o       |
            |                   |          |       |
            |         Vcc       |+         |       |
            |          |        D1         D2      |
            |          R2       |          |+      |
            |   +      |        |          |       |
            +----D4----o--------o----------o-------| B1
                                                   |





To read the status of the switches, you must set the TRIS & data bits so as
to cycle B0 and B1 through the following three states:


    B1         B0               Meaning
---------------------------------------------------------

State 0
  out low    in high        Neither SW2 nor SW3 pressed
  out low    in low         SW2 OR SW3 pressed

State 1
  in high    out low        Neither SW1 nor SW3 pressed
  in low     out low        SW1 OR SW3 pressed

State 2
  in low     in low         SW3 pressed
  in high    in high        No switch pressed



Just a little more work will allow you to figure exactly which switch is
pressed.

Note: I haven't tested this, but it seems as if it should work. No doubt
others will spot any errors or shortcomings.

--BN


----------------------------------------------------------------------------
  Country Robot            "Modular robot components
  69 S. Fremont Ave. # 2     for education and industry"
  Pittsburgh, PA 15202
----------------------------------------------------------------------------

1997\12\22@144207 by John Payson

picon face
> To detect one key this method work fine. But this method don't allow
> to detect keys combinations. For example Sw_1+Sw_2 result to the same
> scan code as Sw_2+Sw_3 or Sw_1+Sw_3 (00_0).

I don't think there are any particularly good/reliable approaches for
detecting more than two buttons with two port pins that can deal with
combinations of buttons being pressed.  The closest thing I could
suggest would be wiring buttons with different resistors and using an
RC-timer based approach; not sure that would be 100% reliable, though.

1997\12\22@150521 by Dmitry Kiryashov

flavicon
face
Robert Nansel wrote:

Excellent idea, but check polarity of D3 & D4. With polarity shown in
you
schematic SW3 seems to be never scanned.

WBR Dmitry.

{Quote hidden}

1997\12\22@151606 by Dmitry Kiryashov

flavicon
face
Hello John.

> I don't think there are any particularly good/reliable approaches for
> detecting more than two buttons with two port pins that can deal with
> combinations of buttons being pressed.  The closest thing I could
> suggest would be wiring buttons with different resistors and using an
> RC-timer based approach; not sure that would be 100% reliable, though.

Why not? There are method with additional external shift register.
It have excellent reliabilty (i practically use it).
First PIC pin clock the shift register ( D input through the low pass RC
and \C input directly ) I post idea to PICLIST some minutes before.
Register with open collector's outputs. The keys wired directly to
register output.

Second PIC pin read the second common wire of key's matrix.

I apply this method to scan up to 16 keys matrix with two PIC pins.
(One additional shift register chip + RC)

WBR Dmitry.

1997\12\22@153046 by Andrew Mayo

flavicon
face
There is another method, which I have tried, and it does work, but may
offend the squeamish. It requires only 1 port pin. Basically it involves
connecting the three switches through three different resistors to +5V.
Values of say, 10K,22K and 47K would do, from memory. The other side of
the switches is joined to form a rail, connected back to a schmitt
trigger input on the PIC. A small capacitor (0.1uF) is connected to
ground from this rail.

To scan the switches,turn this line into an output and pull it low. (you
could place a small series resistor like 470 ohms in there if you feel
nervous about discharging the cap directly into the PIC).

Then you turn the line into an input and loop, counting, (or use the
RTC) until the input line reads logic 1. Depending on the time this
took, you can deduce which switch or switches were pressed. If nothing
happens by the maximum time (depends on RC), then no switches were
pressed. Essentially you are doing a single-slope integrating A/D
conversion.

It does work, and due to the nature of CMOS, the switching point for the
input is fairly temperature-independent, and given that modern resistors
and capacitors are quite stable, this seems to be quite effective. Of
course, it can take a millisecond or more to scan the switches....

{Quote hidden}

1997\12\22@183812 by Craig R. Autio

flavicon
face
part 0 2324 bytes
!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
 
{Original Message removed}

1997\12\22@205400 by DREITEK

picon face
In a message dated 97-12-22 15:33:02 EST, you write:

<<
There is another method, which I have tried, and it does work, but may
offend the squeamish. It requires only 1 port pin. Basically it involves
connecting the three switches through three different resistors to +5V.
Values of say, 10K,22K and 47K would do, from memory. The other side of
the switches is joined to form a rail, connected back to a schmitt
trigger input on the PIC. A small capacitor (0.1uF) is connected to
ground from this rail.
 >>
Don't feel squeamish! This technique works well and is quite reliable.  A lot
of the old VCRs with wired remote use exactly this same trick.  I have used it
on several products.  In fact in one case it totaly blew away an engineer that
was hired to reverse engineer my design.  He couldn't figure out how I used 1
bit to read a 5 position rotary switch, and wound up redesigning it from
scratch!.  I used a pic84 and a single PCB (This was all very small for a hand
held medical instrument)  He had to use a PIC73 and two boards sandwiched
together!
His design failed in the field because of surface mount connector failure
between the two boards.  They only made a hand full of his design and then
went out of business!

Good luck
Dave Duley

1997\12\23@022159 by Pasi T Mustalahti

picon face
On Mon, 22 Dec 1997, Jason Wolfson wrote:

> Does anyone have any clever, low parts count
> methods of multiplexing 3 pushbuttons onto
> 2 port pins?
>
> Thanks
> Jason Wolfson
> Lipidex Corp
>
> @spam@jasonKILLspamspamlipidex.com
>
PTM: First approximation: 74147.

If you only have one finger, you can do like this:

       + ------X----X-----X                    V  =diode
               |    |     SC                   Sx =switch
               V    V     V                    X  =connection
               SA   SB    X-X                  R  =resistance
               |    |     | |
               X----------X------------ PB0
                    |       |
                    X-------X---------- PB1
                    R       R
       - -----------X-------X
Here the SC switch gives the same code as SA and SB pressed together.
--------------------------------------------------------------------------
PTM, KILLspampasi.mustalahtiKILLspamspamutu.fi, RemoveMEptmustaTakeThisOuTspamutu.fi, http://www.utu.fi/~ptmusta
Lab.ins. (mikrotuki) ATK-keskus/Mat.Luon.Tdk                    OH1HEK
Lab.engineer (PC support) Computer Center                       OI7234
Mail: Turun Yliopisto / Fysla, Vesilinnantie 5, 20014
Pt 02-3336669, FAX 02-3335632 (Pk 02-2387010, NMT 049-555577)
--------------------------------------------------------------------------

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...