USB KVM Switch

Running multiple computers can have advantages. In my case at my desk I run a windows machine during the day, and keep a Linux machine running around the clock for various tasks. Usually remote terminal access is all that is needed for day to day interfacing, but sometimes I’d like to be able to access the GUI. In these cases, the switching of monitors and keyboards is necessary, and to say the least, quite annoying. I decided to do a search for some simple small inexpensive KVM switches without hoards of cables attached to them and came up empty handed. Things were either more expensive, or not exactly what I was looking for. I didn’t want video or audio switching, only keyboard and mouse, as I already have a secondary monitor.


Frustrated with the options, I decided to look into whether it would be possible to build something myself. After a bit of thinking, I decided that with just a few chips, it would be possible to build something relatively easily.

Lets look at what we need. We require a chip to interface with multiple USB devices, manage them and interface with the computer. Sounds complicated, but a USB HUB Chip will do that for us no problem. Looking for something easy enough to use, and also leaded for ease of soldering, I decided on the TUSB2036. Not the most cutting edge chip, and not the easiest to configure, but, it looked doable and inexpensive. Next we would need a way to initiate switching. My first thought was a small network of MOSFETs to switch between the inputs, but in testing, this seemed difficult to achieve. I then did some searching for some chips to accomplish this and found a nice match; the TS3USB30E. This chip looked easy to use, and able to do exactly what I wanted. The final chip could be a simple one to switch the TS3USB30E chip from one input to the other. In theory this could be a simple microcontroller. Something small and cheap, but I also wanted a microcontroller that would be able to interface via USB with the computer, to receive keyboard input to initiate the switching as well as a physical button, something with a built in USB serial interface would be required. There are many chips that would work, but because the task would be simply to switch inputs, the least expensive serial capable chip I could work with was the ATMega16u2. I initially tried the ATMega8u2, but ran out of space for the firmware.


Threw everything together and spun up a board; and a bodge later we have a working prototype.


I made an error with the hub chip that would throw a windows low powered hub message, but a bodge wire fixed that. In hindsight I would probably use a couple different chips, and put all the connectors on one side of the board, instead of two sides, but layout of USB stuff could make that rough. Anyway, it’s working as expected, so I’m quite happy with it.