Skip to main content

Building a USB KVM using ATTINY85 and FSUSB30 (Part 1)

Before I get started, let me first say that I'm a software guy and anything I write about electronics and hardware should be taken with a grain of salt. The only formal education I have that's related to electronics is a couple of introduction courses to analog and digital electronics back at university (which was some time ago).

With that out of the way, let me share a bit about one of my latest projects: Building a USB KVM from the ground up.

The inspiration for this project came from one of my colleagues at Badoo, who was looking for a KVM that could handle 4K displayport switching (more on this later). Since I was just starting out learning (or rather re-learning) electronics I thought that this would be a fun challenge.

Normally a KVM would handle switching three different signals, Keyboard, Video and Mouse (hence the name) but due to my lack of experience I decided to keep things as simple as possible and stick to only handling the USB signal required to hook up a keyboard.

Why keyboard and not mouse you might ask? Well, the reason is quite simple: Almost all keyboards use USB 1.1 while mouses use USB 2.0. The significance of this is that the requirements for designing a PCB are much more relaxed for USB 1.1 compared to USB 2.0. For example, when designing a circuit for USB 1.1 you can breadboard it first to try it out. This is as far as I know not possible with USB 2.0.

Requirements

Some of the requirements came from my colleague (who was the intended end user) and some from me.
  • Support 1 USB 1.1 keyboard connected to two computers
  • Using a push button to switch between sources
  • Should be possible to boot both connected computers without getting "Keyboard not detected errors"
Out of these three, the last requirements turned out to be the most complicated one. What it means is that the computer not currently connected to the real hardware keyboard needs to be connected to a dummy (faked) keyboard. As we will see later (in a later post), this was also a good show case for what happens when you determine your requirements without doing proper research first.

The dummy keyboard

For the dummy keyboard my main goal was to create something that would be detected as a USB HID keyboard, as cheaply as possible. My first thought was to find an IC that implemented the whole USB HID stack in hardware but it turns out that these kind of chips are both hard to find and/or fairly expensive. Instead I settled on a software implementation.

Picking a software USB stack

There are several software USB stacks (LUFA, emUSB, V-USB, AVR USB, etc.) but most of them have some special requirements on what hardware they will run on (e.g some of them only run on a microcontroller that has built in USB hardware to handle low level USB functionality).

After reading up on the different options I decided to use V-USB from Objective Development. There were two main reasons behind this choice. Firstly, it does not require any specific USB hardware support and secondly, it runs on Atmel's AVR microcontrollers which I was already familiar with from working with the Arduino UNO platform.

USB Schematic

Another great thing about V-USB is that there are some really excellent tutorials out there for building USB HID devices. The device I ended up building was very much based on the design from the following blog post by Joonas Pihlajamaa. It uses an ATTINY85 microcontroller connected to the USB data lines (D+ and D-) using Zener diodes (Z1 and Z2) to keep the voltage levels down to 3.3V.
Figure 1: The dummy USB keyboard circuit.
The design also includes a jumper (JP4) that can be used to test the keyboard. If the jumper is closed it will result in a key-pressed event being generated once every second. This is also indicated by the LED (LED1) being lit up.

To be continued

In the next part we will look at how to configure V-USB  to provide a USB HID Keyboard device that can be detected during boot (by implementing the HID boot protocol).






Comments

  1. How do I make money from slots and casinos and make money
    The casino industry is full of gamblers, but many of the casinos offer games หาเงินออนไลน์ to attract even more players. What deccasino is the best way worrione to make money?

    ReplyDelete

Post a Comment

Popular posts from this blog

Simple outline for multi-sprite characters in Unity 2D using Shader Graph

For the last 6 months I've been working on a new (untitled) 2D game project in Unity both as a way to learn C# and also to play around with some game concepts I've been thinking about for quite a while. Since I'm not much of an artist or a graphic designer I purchased a set of rather nice looking character sprites from  https://tokegameart.net/  that also came with animations and ready to use Unity packages. Since my game has multiple characters on screen at one and each one can be given orders I needed a way to show which one was selected or active. One common way to handle this which felt like a good fit for me is to show an outline around the selected character. Luckily there's a lot of examples and guides explaining how to do this in Unity (and I based this one on a great article by Daniel Ilett). There was one snag though, my characters consist of multiple sprites (one for reach part of the body) that are drawn and animated separately. This meant that it w...

Getting started with OpenSTM32 on OSX

For some time now I have been doing projects (or should I rather say "been playing around") with AVR microcontrollers. Both in the form of different types of Arduinos but also in stand-alone projects (including the USB KVM and a battery powered ATTINY85 board, which I still haven't written a post about). For the most part I really like these microcontrollers, they are versatile, low powered and the development tools available are excellent (and importantly, available on all major platforms). However, In one of my latest projects I encountered a situation where AVRs just might not be enough. What I wanted to do was to capture images from a digital camera module (OV7670) and process them to determine movement speed and direction. While it might in theory be possible to do so on an ATMEGA microcontroller or similar, the small amount of memory available would make such an operation tricky at best. At that point I started looking for a more powerful microcontroller, and o...

Nucleo STM32F446RE and OV7670

After many hours of trial and failure I finally managed to get my OV7670 camera module to work properly with the Nucleo STM32F446RE board. I will try to put together a longer article about some of the issues I encountered and how I solved them but for now the source code is available on GitHub .