3
\$\begingroup\$

I have a target device that has push buttons that when pressed send a constant 3.3v signal to the MCU button input GPIO's until released. Externally from a different device (perhaps a Raspberry Pi) I would like to stimulate the MCU button input GPIO's while still permitting the original buttons to work.

Is it safe to just connect a 3.3v pin I control to the same MCU button line as the button?

\$\endgroup\$
  • \$\begingroup\$ How is the target button wired? Schematic or photo please. \$\endgroup\$ – Passerby Dec 11 '15 at 13:22
  • \$\begingroup\$ The buttons are actually capacitive touch buttons that are first processed by some nondescript IC and this IC has the line connected to the MCU. I do not have schematics and I'm having to reverse engineer this as I go. The button lines connect over the PCB to a MCU GPIO pin. When the button is active the line going to the GPIO pin is 3.3v. When the button is not active the line is 0.0v. \$\endgroup\$ – gesell Dec 11 '15 at 13:34
  • \$\begingroup\$ Are you able to insert 1kohm resistors between the nondescript IC and the MCU it currently hard wires to? Are you able to potentially insert something like OR gates giving you the opportunity of cleanly injecting a 2nd signal? \$\endgroup\$ – Andy aka Dec 11 '15 at 13:54
  • \$\begingroup\$ @Andyaka Yes I am able to easily desolder the line going between the MCU and the Button IC. I could insert a 1K ohm resister. I could also insert gates. Is it possible to insert OR gates without having to then add another pin to control their state? (PS. thank you all for helping. Really encouraging) \$\endgroup\$ – gesell Dec 11 '15 at 14:03
2
\$\begingroup\$

EDIT:

Now that you have added information in the comments that they aren't even actually buttons, more is needed, because you also want to not destroy the other IC. You need to be 100% clear and 100% accurate in your problem description or we will not be able, or not want, to help you.

Original Solution (not applicable anymore, but leaving for posterity, so to speak):

The dashed block is inside your own controller, it's a toggle switch letting you choose between +3.3V out or 0V out. It has a series resistance, effectively, which will heat up. Now if it's really 5mW, or actually capable of 100mW for a sustained time, we don't know. But if it happens to be 'weak' and only 5mW, you will blow up the IO port on your own processor when it wants to output 0V and you push the button. Because the button is very strong. (Often less than 0.1Ohm contact resistance).

So you need to make sure that can't happen. The easiest is like this:

schematic

simulate this circuit – Schematic created using CircuitLab

Now in the same scenario, the 3.3V difference between your output and the button's forced 3.3V will fall mostly (rounded off you can say all of it) across the external 5.1k Resistor, because it's waaaaaaaaay larger than any other resistance in the system. That means that at most only:

I = V / R = 3.3V / 5100 Ohm = 0.00065A = 0.65mA

Will be flowing. Just about any device that is available to you, if not all, will be able to source and sink 2mA or more on a GPIO pin without any damage. It's usual these days to be more than 10mA and a Datasheet of the device or processor will usually tell you how much it is. So no damage.

The new solution:

You now need to protect both chips. You could do that by adding a resistor for both, but that won't work too well, because either one is the boss, or they divide the voltage across those resistors, effectively creating a three level voltage, observe:

schematic

simulate this circuit

If SW1 is on, and SW2 is on (i.e. connected to 3.3V), both chips agree and the line voltage will be 3.3V, all is fine, assuming the GPIO input is high impedance, which it very likely is.

If they are both off (connected to 0V), they agree again, and the voltage will be 0V. Fine!

The risk is, when no button is pushed but your device sends a signal, which is a likely scenario, or possibly the other way around, that one is on and the other off. The line voltage will become exactly half the VCC.

That's not what you want and a very bad situation. Half VCC is in fact the worst possible situation you can have, because many logic level chips will get the input into an 'undetermined' state, where the electronics inside the chip might even start to oscillate, or just start consuming a lot of power for nothing. Bad.

So you need to chuck in a couple of diodes to create an OR port:

schematic

simulate this circuit

Here when one of the switches is high and the other not, the diode for the one that's on will conduct, but the diode in the path of the one that is off will block any excess current going into that chip's output.

Of course, that means you can't pull down the line actively any more, and when both are trying to set 0V, the GPIO Input will float for a while before leakages determine high or low. This is also bad. So you need a resistor pulling that line down, to make it go low in that case. Now you've basically made a small diode OR port.

I used the BAT54 in the example, because they are Schottky diodes with a very low forward voltage at low currents, so they waste nearly nothing, but you could also use 1N4148 for a 3.3V or 5V logic level system, as they take only about 0.6V in this setup and that's still okay. With a 1.8V system, just warning you for the future, you may be much better off getting an actual OR port, since taking away 0.6V of 1.8V will put it way too close to the dangerous middle voltage. Even taking off only 0.3V might be close to a guaranteed limit in those low, low voltage ranges.

\$\endgroup\$
  • \$\begingroup\$ I think you need to read the comment under the question - it paints a slightly different picture. \$\endgroup\$ – Andy aka Dec 11 '15 at 13:45
  • \$\begingroup\$ @Andyaka Indeed. That wasn't there when I answered. Editing now. \$\endgroup\$ – Asmyldof Dec 11 '15 at 13:47
  • \$\begingroup\$ It's still helpful. I'm trying to understand and process it all at the moment \$\endgroup\$ – gesell Dec 11 '15 at 13:48
  • \$\begingroup\$ @Asmyldof yeah that's what I thought!!! \$\endgroup\$ – Andy aka Dec 11 '15 at 13:52
  • 1
    \$\begingroup\$ @gesell yes you can. \$\endgroup\$ – Passerby Dec 11 '15 at 15:40

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.