Transistors/mosfets to replace manual switches? - Page 1
Forum section: electronics / beginners

author: multiplyduck
author_rank: Newbie
timestamp: June 25, 2021, 06:48:55 pm
content: I am trying to build some logic into an old-style game controller.The controller normally works simply by a series of manual switches letting its respective pin be grounded or in open circuit.What I aim to do is replace the manual switches with output from an arduino. However, I realize I cannot just connect each signal pin to an arduino digital pin, so my first thought was using transistors or mosfets. I read that transistors might introduce a significant voltage drop, so perhaps small mosfets, such as BS170, would make sense? Am I thinking along the right lines?If I had to use relays I wouldn't really be in doubt on how to hook it up since they basically just open or close the circuit like switches, but it isn't obvious to me how I would connect mosfets to act in the same way. Looking at examples of how to use mosfets, I suppose I would connect the gate to an arduino output pin (with a 10K resister to ground in between?), but the other pins? The mosfet examples I find are mainly concerned about driving a load (LED, etc), whereas what I want to do is connect something to ground.Maybe I am needlessly confusing myself? Or maybe mosfets are not obvious way to go?

author: Peabody
author_rank: Super Contributor
timestamp: June 25, 2021, 07:16:23 pm
content: The BS170 is the right kind of mosfet (N-channel) for a low-side switch, and might work just fine. But do you know how much current flows to ground when one of the manual switches is closed?

author: SmokedComponent
author_rank: Regular Contributor
timestamp: June 25, 2021, 07:30:38 pm
content: Since both the Arduino and the game controller are powered from the same 5V rail, you could just skip the transistors altogether and directly use outputs of the MCU in (almost) open-drain mode - by switching the IO pins between input and output mode (default low) instead of leaving them in output mode and switching between high/low.Just check that the current flowing into ground from the controller's buttons isn't to high (it shouldn't be, they're probably using few K pull-ups)

author: Manul
author_rank: Super Contributor
timestamp: June 25, 2021, 07:31:36 pm
content: Quote from: multiplyduck on June 25, 2021, 06:48:55 pmYou can directly connect to Arduino if both circuits are working at same logic level. I assume you use Arduino UNO which is 5V. What is voltage at game controller buttons?P.S. There will be a problem if you use physical buttons at the same time as Arduino control (assuming direct connection). This can be soved by software (emulate open drain by changing pin between input and output LOW), or hardware (emulate open drain by using series diode, or just add current limitting resistor).

author: multiplyduck
author_rank: Newbie
timestamp: June 26, 2021, 12:31:44 pm
content: Thank you everyone for your replies!Oh, so I CAN just connect to an arduino pin directly. Clever trick with switching the pins between input and output low. Would anything happen if I accidentally set a pin as output high?All of you ask about either voltage or current: I measure just below 5V on the controller switches, but I am not able to measure any current flowing through when I bridge a switch with my multimeter in amp mode.

author: Faringdon
author_rank: Super Contributor
timestamp: June 26, 2021, 01:11:36 pm
content: QuoteThen you get current through the pin of 5V/ [pin resistance]...which wont be good, so put in a limiting resistor if you want.Remember that when you set a arduino pin to output, you are just making it the output of the internal transistor, which either turns the pin on to gnd, for low, .....to power for high, and to nothign for "High z".

author: Manul
author_rank: Super Contributor
timestamp: June 26, 2021, 01:23:46 pm
content: Quote from: multiplyduck on June 26, 2021, 12:31:44 pmIf you do not use physical switches (for example, you remove them), then in this case it is not a problem and in fact you can just set Arduino pin HIGH and LOW.BUT, there is yet another case to consider. Is both Arduino and game controller powered from same 5V source? If yes, then good. If no, then there is potential problem. You need to prevent one device feeding another through logic lines, if one is unpowered.

author: multiplyduck
author_rank: Newbie
timestamp: June 26, 2021, 04:17:00 pm
content: Quote from: Manul on June 26, 2021, 01:23:46 pmI will be removing the physical switches (or rather, rewiring them to some input pins on the arduino, but that's another story).So, the game controller itself by default is as simple as it gets; it consists of the manual switches alone, nothing else. The controller's connector, however, does provide a 5V rail (which by default is unused) which I plan to hook the arduino up to. I can't imagine this 5V rail being powered by a different source than the buttons, all of them coming from the same game console. Is there a way I can test that?