How can I close an external circuit (button press/switch) with lowest latency? - Page 1
Forum section: electronics / beginners

author: sofakng
author_rank: Regular Contributor
timestamp: March 05, 2025, 07:13:57 pm
content: I'm trying to trigger a button press on a joystick (ie. Xbox controller, Playstation, etc) using a microcontroller.There are two contacts on the joystick PCB (ie. signal and ground) that simply need to be connected (just like any button) but I'd like to trigger this using the microcontroller.What is the safest and fastest method?For example, when the microcontroller triggers the signal, I want the button circuit to be closed as fast as possible (ie. no delay).My concern is that most microcontrollers are 5V or 3.3V and some joysticks I am using are only 1.8V or might use different voltages.I think my options are level shifter, relay, optocoupler, or transistor? I think relay will introduce latency (?) and the level shifter requires additional wires (ie. supply voltage) so can somebody explain the best approach?

author: SuzyC
author_rank: Frequent Contributor
timestamp: March 05, 2025, 08:50:21 pm
content: The best way to accomplish a simulated button press would be to use an Optocoupler with a phototransistor as the output pins and any MCU providing the small current to drive the photodiode input of the optocoupler.An ordinary optocoupler would likely be fast enough, but a fast optocoupler can do this also in 100nS or so.

author: MathWizard
author_rank: Super Contributor
timestamp: March 05, 2025, 08:57:11 pm
content: So do you still want the mechanical push button switch ? But you also want an electrically controlled switch, attached to the mech SW pads on the PCB, like a BJT or FET, that can be controlled by an MCU ?I'd want to know more about the signal and circuit, where they come from and where they go. But it should be pretty easy, and plenty fast, especially compared to pushing a button, that on it's own, usually bonces and vibrates for a while when the contacts collide.

author: John B
author_rank: Frequent Contributor
timestamp: March 05, 2025, 10:01:49 pm
content: A regular 817 (PC817, EL817 etc) type optooupler would be more than fast enough. The existing buttons would need some type of debouncing anyways, so the opto won't be the slowest element in the chain.You can also get them in quad packages to help compact your design.

author: David Hess
author_rank: Super Contributor
timestamp: March 05, 2025, 10:16:56 pm
content: I have used bipolar transistor output optocouplers to do this. Nothing special is required.

author: PGPG
author_rank: Frequent Contributor
timestamp: March 06, 2025, 12:10:17 pm
content: Quote from: sofakng on March 05, 2025, 07:13:57 pmIf GND is common I see nothing wrong in just using NPN transistor.

author: jpanhalt
author_rank: Super Contributor
timestamp: March 06, 2025, 12:49:20 pm
content: If the MCU has open-drain pins, you might be able to use that without an additional device. Many PICs have them.

author: BeBuLamar
author_rank: Super Contributor
timestamp: March 06, 2025, 12:54:36 pm
content: Quote from: PGPG on March 06, 2025, 12:10:17 pmAgree the switching speed of a transistor is very fast. I think the the microcontroller would be the thing that slows it down. Microcontroller has to run some kind of code between getting the input and the output.

author: David Hess
author_rank: Super Contributor
timestamp: March 06, 2025, 02:46:26 pm
content: Quote from: PGPG on March 06, 2025, 12:10:17 pmEven with a common ground, which seems unlikely, I would still use an optocoupler to prevent unintended disasters.

author: sofakng
author_rank: Regular Contributor
timestamp: March 06, 2025, 03:10:05 pm
content: Thanks so much for the help everybody! It looks like I have a few options