0
\$\begingroup\$

Schematic enter image description here The arrows are GPIO's

I want to be able to close multiple switches at once in any particular order in order to manipulate GPIO's manually. I could give each GPIO its own resistor, but when I close multiple switches the current will increase (by 2, 3, 4 times) reducing battery life. I tried to find a way where each GPIO would share the same resistor and be properly pulled down, while still remaining isolated by the switches. Would the above circuit work?

In particular, when the switch is open will the GPIO be at ground as I want it to be, and when the switch is closed will only the specified GPIO be high?

\$\endgroup\$
0

2 Answers 2

1
\$\begingroup\$

No, your circuit won't work as you want.

When any switch is closed, the associated diode will pull the junction between the diodes and the resistor up to about Vcc - 0.7 volts, leaving the unselected GPIO inputs in an unknown state (but perhaps, due to leakage in the diodes, the unselected inputs may appear as Highs.)

\$\endgroup\$
1
  • \$\begingroup\$ what about tri-stated bus,apart from high and low you can float the GPIO,but I haven't done it ever,may be try floating it with I2c interface on GPIO? \$\endgroup\$
    – MaMba
    Aug 26, 2015 at 13:51
2
\$\begingroup\$

Besides Petre's analysis, think about this for a moment. If your circuit would work, your R1 would be 'strong' enough (value low enough) to pull 4 GPIO's low. If that were the case, you could use 4 resistors with a value four times as high, to achieve te same effect.

In most cases the very small current through pull-up reistors is not enough to warrant special attention. But if it is, an appropriate trick is to enable the resistors only during the (relatively short) time you want to read the switches. This can be done using one extra GPIO. Or use the internal pull-ups of your micro-controller, which can (in all cases I am aware of) be enabled and disabled under SW control.

\$\endgroup\$
3
  • \$\begingroup\$ Newb question: what's SW control? I was thinking about programming the internal resistors to behave in the way I want them to. I guess I'll just do that. I was just exploring if this would work. \$\endgroup\$
    – Alex
    Aug 27, 2015 at 0:22
  • \$\begingroup\$ Also, I thought that R1 was a pull down resistor in this set up? The controller in question will constantly draw about 10-16 mA while in use. Even if I just gave each GPIO it's own 13 kΩ resistor it wouldn't be the largest current draw even when all the switches are closed. I guess I was just splitting hairs. \$\endgroup\$
    – Alex
    Aug 27, 2015 at 0:28
  • \$\begingroup\$ OK, pull-up instead of pull-down. SW control == Software Control. A pull-up (or down) resistor can be much higher than 13k, IIRC internal pull-up resistors are more like 100k. \$\endgroup\$ Aug 27, 2015 at 6:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.