Using an Arduino to switch between PCB USB data lines?

Hello all,

I have a USB arcade stick that I would like to dual mod (i.e. connect two controller encoders together) in order to make it work on Xbox 360 and PlayStation 4. I have both PCBs (specifically a MadCatz TE PCB for Xbox 360 and a PDP Mortal Kombat X controller’s guts for PS3 and PS4) ; they are both common ground and their button and joystick inputs are connected.

The traditional method of dual modding two USB controller PCBs involves connecting VCC and GND between the two boards and your USB cable so that they are powered and grounded at all times while the USB cable is plugged into a USB port (either on a console or a computer). You would then solder your USB cable’s D+ and D- wires to the center poles of a DPDT switch, with the two PCBs’ D+ and D- being connected to opposite poles of the same switch. You’d then have to drill a hole on your case somewhere and mount the switch.

What this basically accomplishes is that while both boards are being powered and grounded, only one of them is sending data through the USB cable to the console or PC’s USB port, and you’d be able to change which PCB is the one sending data with the flip of a switch.

The other method involves simply giving each PCB its own USB cable and connecting their inputs, VCC and GND, but that again requires drilling of a hole to thread a second cable. In addition, accidentally plugging in two cables simultaneously with both boards’ VCC being connected will supply too much power and fry them, and that’s another precaution I don’t want to worry about.

While I have done this before, drilling a hole permanently into an arcade stick is very scary, and so I’ve been looking for a way to make it so that I would be able to not have to mount an external switch (because I don’t want to repeatedly unscrew and open up my stick to flip the switch when I want to change consoles either).

There was a device in the arcade stick enthusiast community called the Imp board by one Marcus “Toodles” Post. It was a tiny circuit board with some ICs and a capacitor where you would solder your outgoing cable’s USB lines, as well as the USB lines on the two PCBs you were dual modding. This basically acted as a DPDT switch without the actual switch component and worked by holding down a button on your arcade stick while plugging it in. By doing this it would swap which set of data lines would be going out to the cable. It would also save that selection so that unplugging and replugging with the button held down swaps to the other PCB’s data lines.

The issue with simply purchasing an Imp is that Toodles is no longer selling anything through his online store, so I figured I’d just make my own replica of the Imp board.

I asked some buddies on the forum I frequent, and one of them suggested coding an Arduino to act as a USB data switch.

And that’s ultimately why I’ve come here.

Being a bit in the dark about Arduinos and with about 3 high school semesters knowledge of programming (Turing, then Python and Java, then more Python and some Assembly), I’m here to ask for guidance from experts in creating a micro controller that simply swaps between two sets of PCB data lines if I hold a button while plugging the cable in. I don’t need it to remember my selection like the Imp did, i.e. I’m okay with it not swapping to the other PCB unless I hold down the button and plug it in each time I want to do so.

All input is appreciated. Thanks!

  • (Not) Justin Wong

I know nothing about PC games or game controllers.

You could use an Arduino to operate a relay that takes the place of the DPDT switch.

It may also be possible to use some logic gates to do the switching - but USB operates at very high data rates and I would be out of my comfort zone messing with that stuff.

Because USB operates at very high speed it is quite impossible to channel USB signals through an Arduino.

...R

So you have two USB controller devices and one host(computer). Why does it not work with a hub? That is what USB is good for. Buy a cheap hub and test it.

Connecting button or joystick inputs of multiple modules may not work at all. Each module supplies its own voltage to the sensors, and expects according returns from the passive sensors. Connecting USB power lines from different masters (voltage suppliers) also can cause trouble.

For the USB signal switch you can try an analog multiplexer, but it may be too weak for outgoing signal transmission. A better approach would use separate line drivers and receivers for each port, and multiplex the digital I/O pins of these devices.

MorganS:
So you have two USB controller devices and one host(computer). Why does it not work with a hub? That is what USB is good for. Buy a cheap hub and test it.

Because the end goal is to have a single controller containing two separate PCBs and a single USB cable with the ability to switch which PCB is sending data through that cable by holding down a specific button while plugging it in. I don’t see how a hub accomplishes that.

DrDiettrich:
Connecting button or joystick inputs of multiple modules may not work at all. Each module supplies its own voltage to the sensors, and expects according returns from the passive sensors. Connecting USB power lines from different masters (voltage suppliers) also can cause trouble.

For the USB signal switch you can try an analog multiplexer, but it may be too weak for outgoing signal transmission. A better approach would use separate line drivers and receivers for each port, and multiplex the digital I/O pins of these devices.

I’ve tried looking at MUX USB Switch ICs on digikey and mouser, and they essentially function exactly how I want (i.e. like a DPDT). The problem is that they’re way too tiny to solder to by hand, which is why people reiterated the idea of using a micro controller to handle the switch.

But why does one controller have to be switched off or disabled? If both of them work at the same time then it doesn't matter which one you have your fingers on.

Most USB devices need to announce themselves to the host computer. They do this when they first see power coming in. If you switch the magical switch, then how does the newly-connected device know that it is connected and it's time to re-send the startup sequence? Conversely, the host is still sending data to the old one and it doesn't yet know that it has been disconnected and it should stop waiting for a response.

If you are unplugging the thing (and holding down a button) to re-initialise the second unit, then why not just use two cables? Paint them different colours. Your local hobby shop will help you find paint which sticks to that plastic properly. It might cost a dollar or two.

MorganS:
But why does one controller have to be switched off or disabled? If both of them work at the same time then it doesn't matter which one you have your fingers on.

I'm not turning off either of the PCBs completely. Both PCBs are going to be receiving 5V and GND at all times. The key thing is that only one set of D+ and D- from either PCB is going to be low while the other is high in order to switch which console I can use the arcade stick on. A PS3/PS4 controller PCB will not work on an Xbox 360 console and vice versa which is why I need to be able to switch data lines in the first place (and no, simply connecting the D+ and D- from both PCBs together doesn't work either).

I even made a picture of it in Paint using the DPDT switch example.

If you ask me why that works or why it won't work any other way I won't be able to give you an answer, but people in the arcade stick community have been doing it this way (either through the use of DPDT switches or that Imp board that requires a button press on plug-in) for years and it has never failed. I even have another stick with this exact DPDT setup and I can switch between Xbox mode and PlayStation mode. Even when the stick is plugged into my computer and I open joy.cpl, if I flip the switch it simply changes which PCB the computer is seeing; nothing breaks or whatever. The only reason I don't want to use that method again for this new one is because, like I said, I don't want to do any more drilling.

MorganS:
If you are unplugging the thing (and holding down a button) to re-initialise the second unit, then why not just use two cables? Paint them different colours. Your local hobby shop will help you find paint which sticks to that plastic properly. It might cost a dollar or two.

I touched on this in the OP.

NotJustinWong:
The other method involves simply giving each PCB its own USB cable and connecting their inputs, VCC and GND, but that again requires drilling of a hole to thread a second cable. In addition, accidentally plugging in two cables simultaneously with both boards' VCC being connected will supply too much power and fry them, and that's another precaution I don't want to worry about.

NotJustinWong:
I even made a picture of it in Paint using the DPDT switch example.

Did you read Reply #1 - second paragraph?

...R

Robin2:
Did you read Reply #1 - second paragraph?

…R

Sorry, completely missed it hahah. I’ll look into it thanks

OK, so you really have one device which you want to be able to plug into an Xbox or a PlayStation? You only want to have one cord dangling out of this device? It needs a way of starting up in one mode or the other and doesn't need to be hot-pluggable?

The Arduino idea would be great except when it's not plugged into anything, the Arduino gets no power. So how can it do anything before you plug it into a power source? A battery? That won't last long when driving a relay.

I would use an actual toggle switch. Just like your diagram. There's a zillion different styles available so pick one that looks cool and fits your colour scheme.

Alternatively, have a cable with a short Y section at the host end, with two colour-coded USB plugs.