2
\$\begingroup\$

I did buy some off the shelf ones, but they seem to fail after a few months and or screwing up the USB ports.

I opened the switch box up and noticed that the two power lines were always connected to both the output and the input lines. The only switching that's done is at the two data lines, which I thought was odd. (It might be the reason why it keeps failing as both computers sending 5.2 V down their power lines, and if one is even slightly less than the other, the power goes to the other one, destroying the port.)

It is not really a true switcher, since to truly switch, it has to disconnect all 4 (or 5 if you include the shield) lines as if you unplugged it and replugged it in physically. Below is my wiring diagram: enter image description here

Now this design is starting to fail too after a few months of use despite the switch still works, so this design of mine also destroys the USB ports too? Maybe I should add an inline diode somewhere on the two power lines all going to input, but can't travel back up? But I shouldn't really need a diode if my switch completely isolates the two outputs (just like unplugging and replugging), it either is output A OR output B unless the switch is faulty....or starting to show signs of failure which is why after a few months it makes the computer says USB device not recognized when it switches to the output?

I am not really keen on spending over $300 KVM switch just to switch between two computers if I can do it for cheaper. What does a KVM switch have that my homemade USB switch doesn't have....besides video switching feed? Hmmmm....

And I made another one for the keyboard, but that one doesn't even work....never worked for the keyboard for some reason....only the mouse one worked and that only worked up til now and starting to show the same funkiness the off the shelf one I bought did...

\$\endgroup\$
2
  • \$\begingroup\$ Is this a mechanical switch? If so, I'd suspect dirty/worn/poor contacts to be the cause. Most mechanical switches require a minimum wetting current which the USB signal lines are unlikely to reach. Some solid state switch mechanism is probably required, but parasitics come into play with high speed stuff like USB. \$\endgroup\$ Commented Jun 25 at 15:16
  • \$\begingroup\$ Have you seen what VGA/USB KVM switches cost? They are considerably cheaper than $300, consider that as an option. I have a longer answer with some commentary as an answer below. \$\endgroup\$
    – MacGuffin
    Commented Jun 26 at 1:04

2 Answers 2

4
\$\begingroup\$

The mechanical switch does one thing wrong which may kill your USB port.

One important point about USB is hot-plugging, and for hardware support, the USB connector is mechanically designed to allow it - meaning, connector shells make contact first to discharge most potential difference from static charges, then the power supply and ground pins make contact next so device is having a stable ground reference and supply before the data pins finally make contact.

Otherwise, lets assume your mechanical switch is a normal switch and all pins should switch simultaneously, but sometimes it will happen that for example 5V supply and data pin are the two first pins that touch. If your mouse has the max 10uF capacitance and is basically a load resistance, it will give a 5V jolt on the data wire.

Which is why cheap makeshift and improvised products destroy USB ports or don't work properly, and why real products actually intended for switching USB devices cost as much as they do because they are designed to do it properly and the money is saved as you don't need to buy new computers due to damaged USB ports.

Basically you would need some load switches and a data mux with enable to control supply and data separately and so that power also comes only from selected port if present and when switching between ports the data should be switched while power is off. Grounds can be assumed to be tied together.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Further to the above, it is very unlikely that a mechanical switch is impedance controlled (let alone the method in which it is connected). The connection may work for USB ports at low speed and maybe even full speed, but you have no chance of passing hi speed or super speed signals through an in controlled impedance line. The signal integrity of the signal will be destroyed and nothing will work. \$\endgroup\$ Commented Jun 25 at 22:24
  • 1
    \$\begingroup\$ I'll pile on some by also suggesting that a mechanical DIY USB switch might work at the low 1.5 Mbps speed but not the higher 12 Mbps. If that is the case then it can explain why a mouse might work but a keyboard might not. A mouse is not likely to use 12 Mbps but a keyboard just might. It's not that a keyboard would need 12 Mbps to function, it's just that it might be cheaper to source a 12 Mbps chip of some sort than a slower 1.5 Mbps chip. Pricing on mass produced products are funny like that. \$\endgroup\$
    – MacGuffin
    Commented Jun 26 at 0:54
1
\$\begingroup\$

I am not really keen on spending over $300 KVM switch just to switch between two computers if I can do it for cheaper. What does a KVM switch have that my homemade USB switch doesn't have....besides video switching feed? Hmmmm....

I have bought plenty of KVM switches for work for far less than $300. If you don't care about switching video then getting a VGA KVM switch can be cheap, I've seen them sell for less than $50 new-in-box.

A KVM will often allow for a keyboard macro to do the switching, a nice feature once the macro "sticks" in the mind since it means flipping back and forth quickly without needing to move a hand from the keyboard. Every KVM switch I've seen has an integrated hub so there is one connection to the computer then two (sometimes more) USB ports so that there's separate ports for a keyboard and mouse. If there's extra USB ports then they can be handy for a printer, extra input device, or perhaps more but not great for using with flash drives. It would be too easy to flip the drive between computers without a proper dismount and that could corrupt the data on the drive.

I have had some KVM switches that will "steal" keystrokes because the macro switching system was poorly done. This can be easily worked around (at least this worked for me so far) by swapping the ports used for the mouse and keyboard on the switch. The KVM will have ports marked for keyboard and mouse but both are still just USB ports. The difference will be that the port marked for a keyboard will look for macros to switch and "steal" those keytrokes for itself than pass that on to the computers. If this gets annoying just disable the macro switching by swapping the keyboard and mouse on the ports. Similarly if the advertised macro switching isn't working then double check that the correct ports were used.

I've seen $300 KVM switches before. One was a very nice switch that was all mechanical, no keyboard macros, just a big knob on the front that made an oddly satisfying "klunk" when turned. The other $300 KVM switch I used had four ports and could switch both VGA and DVI, useful for when there was a mix of new workstations and old servers. I'd switch the KVM and the monitor would detect loss of video on one port or the other (VGA or DVI) then switch to the other. Or it did that most the time, sometimes I'd have to lift my hand off the keyboard to punch a button on the display to force a switch.

I'll apologize if the extra commentary was too much of an aside. I wanted to address a couple common complaints of low end KVM switches and I suspect that the use of only switching USB than video is because of a need to deal with two computers with differing video connections. If the issue is the video ports not matching then consider a dual display KVM, connect just one port to each computer, both video ports to the display, and perhaps the display will switch automatically when it detects loss of one signal and gain of the other. If this isn't automatic then check the display settings for auto-scan of video ports.

I added a bit of commentary also because my answer was so short, I felt a need to pad it out some. Try a VGA KVM for a low cost two port USB switch.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.