1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Electronics Not Longer Needed - Building an Arduino Controlled USB Switch Box

Discussion in 'Modding' started by dynamis_dk, 30 Jan 2020.

  1. dynamis_dk

    dynamis_dk Grr... Grumpy!!

    Joined:
    23 Nov 2005
    Posts:
    3,762
    Likes Received:
    339
    So at the moment the way I'm sharing out my usb keyboard / mouse is with 2 physical 4 to 1 switch boxes. Now they work just fine but it means box 1 is my keyboard and box 2 is my mouse, meaning each time I change output device (Main PC or Work Docking Station) I need to press two buttons... so it got me thinking. Given the hardware swtich is just plain traces on a PCB and no protector circuits couldn't I knock something up with a bunch of mosfets and an Arduino.

    Now I have very little electrical knowledge. I can google my way round Arduino as I've a programming background and I know how to etch etc but actual brain cells containing electronics knowledge tops of around 'don't stick forks in plug sockets' :)

    Keeping that in mine I had a mess and came up with this as a rough idea. The pin connections might not be all spot on but it to demo my idea rather than a technical work piece. This design would give me 1 switch box to have one input (say keyboard) to 3 different devices (i.e. PC, Laptop and Xbox).

    [​IMG]

    When ARD_P1 is 'on' from the Arduino, USB1 finds its way to USB3. ARD_P2 = USB2 etc

    Presuming that the idea is workable from an electronics point of view, can some one advise on a suitable mosfet which can be switched by logic level Arduino power levels? I know standard peripherals on USB are 500ma max, not like a keyboard or mouse is gonna be pulling that top end I'm sure, but I don't really understand the required volt/amp needs at the gate pin. The way I understand it with a N-Channel mosfet at 0v @ gate there will be no flow between source and drain. apply the right voltage at gate, it will allow flow from source to drain - just like turning on a switch. Any of that theory right?
     
  2. Xlog

    Xlog Minimodder

    Joined:
    16 Dec 2006
    Posts:
    714
    Likes Received:
    80
    Quick & dirty solution - just use a hub with a single switch box .
    If you want to do it properly from scratch - use a dedicated multiplexer IC. If you are ok with only USB1.1, then small signal relays should work (maybe even USB2, but thats a big maybe).
    Or just buy a KVM....
     
    Last edited: 30 Jan 2020
  3. dynamis_dk

    dynamis_dk Grr... Grumpy!!

    Joined:
    23 Nov 2005
    Posts:
    3,762
    Likes Received:
    339
    I don’t wanna buy a KVM as I haven’t really found anything cheap enough that’ll do 3 usb devices spread over 4 pc devices.

    mill look into the multiplexer thing tho; never heard of em so I’ll have a google arou d
     
  4. Xlog

    Xlog Minimodder

    Joined:
    16 Dec 2006
    Posts:
    714
    Likes Received:
    80
    Like this or this or only usb? Unless you want something special, like 3 USB cables to every PC or selective USB switching.
     
  5. dynamis_dk

    dynamis_dk Grr... Grumpy!!

    Joined:
    23 Nov 2005
    Posts:
    3,762
    Likes Received:
    339
    Cheers mate, some good options there. I like the first one with HDMI, that’s a lot cheaper then I found something similar when I got the manual switches. Only thing which would put me off a little of you need access to all sides but I could maybe strip one down to see if extending the switches was possible onto another little PCs then hide the rest of the bits under the desk. Cheers for taking the time to have a look.

    unfortunatly tho it looks like they won’t work as I need something which outputs the keyboard and mouse on its own usb cable rather then taking the two and only one cable going to the PC end :( I’ve got a Xbox adapter which need each device in its own port so anything which takes all inputs and connects then via one usb cable won’t work.

    I’ve had a quick look at the multiplexers you mentioned and there is a dual 4 output one which looks like it would do the job so I might look to get a few to play with and see what I can make of it :)
     
  6. Xlog

    Xlog Minimodder

    Joined:
    16 Dec 2006
    Posts:
    714
    Likes Received:
    80
    Ah, so you do need something special, haven't specified it in your first post. Take a look at MAX4899AE, though if you are not comfortable on soldering qfn packages there are also some 2:1 multiplexers from TI (TS3USB221, modules available on ebay), that you could theoretically put in parallel.
     
  7. dynamis_dk

    dynamis_dk Grr... Grumpy!!

    Joined:
    23 Nov 2005
    Posts:
    3,762
    Likes Received:
    339
    I got myself a few CD4052B dual 4 way multiplexers this week and have had a little play to see how they work. I've used 2 banks of LED's as a test, each CD4052B having the LED positive on its X common and ground on its Y common. I've got the Arduino sketch working so a press of the button powered on each LED in turn, in order. Then a hold down press set the inhibit pin effectively turning all the outputs off. In theory is should do the job just fine.

    In the USB controlling version I would have CD4052B 'A' having the USB D+ and D-, on its X and Y common pins leaving CD4052B 'B' routing the V_USB and Ground.

    I've read that you shouldn't just interrupt the power ground on a USB device when programmatically switching USB, so I'm thinking I'll add some kind of delay order so on switching the USB device between outputs 1 & 2, the code should disconnect the USB1 data lines first, then wait a little while, then disconnect the USB1 power/ground lines. Then on USB2, switch to the power lines, then a short wait and switch date lines.

    Does this sound like a reasonable approach?
     
  8. Xlog

    Xlog Minimodder

    Joined:
    16 Dec 2006
    Posts:
    714
    Likes Received:
    80
    1. Those muxes are not for power and wont work, the ON resistance then VDD is 5V is 470Ohms, so on dead short they will be able to source 10mA max. Dont disconnect ground, use P-Mos for power.
    2. Cant really say if that mux will work for data, its out of spec even for USB1.1 (propagation delay is way too high, USB1.1 operational frequency barely fits in mux'es frequency response, havent even looked at other parameters), but hey, you might get lucky.
     
  9. Boscoe

    Boscoe Electronics extraordinaire.

    Joined:
    5 Jan 2010
    Posts:
    1,127
    Likes Received:
    69
    This is really not going to work. Just look at the body diodes of the FETs. USB can’t be considered as just an ordinary signal, it has requirements, the most critical one being characteristic impedance. Your FETs will be covered in parasitic capacitance that will destroy the signal integrity of high speed USB, not alone the diodes. Remember USB is bidirectional. You need something like the following, there’s a reason they exist.

    http://www.ti.com/product/TS3USB221A#
     
  10. Dr. Coin

    Dr. Coin Multimodder

    Joined:
    13 Sep 2013
    Posts:
    1,102
    Likes Received:
    296
    Per Boscoe's comment my review of your circuit seems to be a moot but here it is: I was wondering why USB 4 pin (GND) is ties to USB2 Pin 2 (D-)? Similarly why is Q4 switching USB3 D- to USB 4 Pin 4 (GND)?

    If you do go commercial I can recommend the following: https://www.amazon.co.uk/UGREEN-Sharing-Keyboard-Scanner-Printer-Black/dp/B01N6GD9JO/ I have been using one for about a year now. My only compliant is that it does not appear to carry the power through as it should. No issue with mouse, keyboard, game pad and USB memory sticks, but external hard drives don't work. Solved the issue by plugin in a powered hub.

    I know you are looking to share with four computers the company has a a version in USB 2.0 https://www.amazon.co.uk/UGREEN-Sharing-Switcher-Adapter-Keyboard/dp/B01CU4QD1I The single button might be annoying when cycling between four devices.
     
  11. dynamis_dk

    dynamis_dk Grr... Grumpy!!

    Joined:
    23 Nov 2005
    Posts:
    3,762
    Likes Received:
    339
    Cheers guys. I've abandoned this now, just too much work / spend to get something which I might never be able to build. I've got some physical switch boxes which work fine so I've stripped them, mounted them in a row and I'm going to make a few long buttons which join all the physical push switches into one big button so each button selects an output. Not as compact or interesting as a little electronic project but I just don't have the skill set as proven above.

    Cheers for the info tho :)
     

Share This Page