'Open Collector, Buttons'
I'm building a project which requires 4 pushbuttons to be attached to
a bus interface. I *could* obviously use a tristate buffer, but I'm
trying to keep the chip count down. I do have one spare pin on the
PIC (A2), so my initial solution was to have this pin as the common
connector to 4 switches, and have the other side of the switches
wired to B0-B3, (which is in use as part of a bus interface).
When the bus in in use, I float A2, so pressing a button doesn't
interfere with the bus operation. When I'm not using the bus, I flip
B0-B3 to inputs, set A2 high, read B0-B3, set A2 low, read B0-B3 again
and figure out which switches are closed. (Alternatively, make B0-B3
outputs, A2 input, strobe each in turn, and look for corresponding
strobe on A2).
Of course, a moment's thought demonstrates that if two switches are
closed at the same time, unspeakable confusion will occur, because
two of the bus lines will be shorted together, regardless of whether
or not A2 is floating, and when the bus *is* in use, disaster will
So, I'm thinking - presumably if I got a transistor for each line,
arranged in an open-collector configuration, such that B0-B3 remain
outputs, each driving a transistor, I could take the second
approach described above (use A2 as input), and it wouldn't matter
if two buttons were pressed simultaneously. (I don't need to detect
simultaneous presses - it's just that they can't interfere with
My question is, (and once again, I'm forced to demonstrate my
complete lack of elec eng knowledge...), how exactly do I connect
the transistors? I need a series resistor on the base, yes? If so,
what sort of value should I use?
Alternatively, if anyone can suggest a simpler way to get around
this problem, I'm all ears!
If I understood what you are doing right (and I just gave it a quick
read... sorry) you can isolate the switches from your address lines by
simply adding a series diode to each switch. You can press 2 buttons and
all it does is connect the address lines with two back to back diodes...
which doesn't conduct.
Assuming you drive an address line high to see if a switch is closed, point
the diode from the PIC output to each switch. If you output lows to detect
switch closures, spin the diodes round the other way.
Mail me off list if this didn't make sense, and include a sketch of your
thing. I'll draw you what I mean.
Good luck with your project.
At 12:15 AM 6/13/99 -0700, you wrote:
Ernie Murphy wrote:
> If I understood what you are doing right (and I just gave it a quick
> read... sorry) you can isolate the switches from your address lines by
> simply adding a series diode to each switch. You can press 2 buttons and
> all it does is connect the address lines with two back to back diodes...
> which doesn't conduct.
> Assuming you drive an address line high to see if a switch is closed, point
> the diode from the PIC output to each switch. If you output lows to detect
> switch closures, spin the diodes round the other way.
Have a look at:
nice little schematic of it there.
Don McKenzie dontronics.com donhttp://www.dontronics.com
Don's Download Dungeon: http://www.dontronics.com/download.html
Australian Electronics Ring http://www.dontronics.com/aering.html
Win $500USD Cash. Micro design contest: http://www.simmstick.com
>(Alternatively, make B0-B3
>outputs, A2 input, strobe each in turn, and look for corresponding
>strobe on A2).
Yeah I'd do it this way:
Connect one side of each switch to A2 with a 10k pullup resistor to Vdd.
Connect the other side of the switches to B0-B3.
bring B0 low, with B1-3 high.
if RA2 is low key 1 is pressed.
bring B1 low, the others high
if RA2 is low key 2 is pressed.
BTW if you had a pin on portb spare you could use an internal pullup so
wouldn't need the external one.
At 12:15 AM 13/06/99 -0700, you wrote:
Doh! How did I miss that?
You guys are absolutely correct... diodes do the job just fine.
Thanks a million,
> You guys are absolutely correct... diodes do the job just fine.
You can also use resistors. I do that - it saves space (vs SOT23), they can
come in packs (eg 4x0805) and have no polarity.
More... (looser matching)
- Last day of these posts
- In 1999
, 2000 only
- New search...