USB Hardware Basics

May 25, 2013
I am almost entirely ignoring USB 3.0, just so you know.

USB speeds

There are "theoretical" speeds used for boasting by USB manufacturers. (This isn't quite true; these are the actual clock speeds on the bus). There are many factors that determine the actual speed a USB device can communicate at, and most USB devices do not achieve anything even remotely close to these data rates.

USB 1.1 had only Low and Full speed, USB 2.0 introduces High speed. There are plans to double the speed of USB 3.0 to 10 Gb/s sometime in 2013.

A device that is limited only by the USB bus itself might be expected to transfer data at 60 percent of the bus clock rate. Design limitations in the device itself often are the limiting factor. Some sources say you might expect 53 MB/s for high speed and 1.2 MB/s for full speed (doing bulk transfers, which are the fastest).

As an example, an Arduino Uno can communicate no faster than 115200 baud (115.2 Kbit/second), even though it is a full speed device. (All AVR devices I have yet examined identify themselves as full speed devices, including several 32u4 based devices and the 90USB1286 "teensy++ 2.0).

USB devices indicate their speed (and their presence on the bus) by pull up resistors to 3.3 volts on the D- and D+ lines.

High Speed devices have the "full speed resistor" and appear first as full speed devices. They later configure themselves as high speed devices and remove the resistor.

Hosts, Hubs, Controllers, and Devices

USB is based on a bus with one host and up to 127 devices. In practice there are only a few devices on a bus and the bus is expanded in a "tiered star" topology using hubs. Hubs may be embedded in a computer, a monitor, a keyboard, or any number of places.

The USB standard says that a device is either a hub or a function. This can lead to some pedantic silliness, but just comfort yourself knowing that your mouse is both a device and in particular a function.

The standard says that the topology can only have 7 levels. The host "root hub" uses one of these levels, and you cannot put a hub at the end with any useful effect. This means that you can have only 5 hubs chained together between the root hub in your computer and whatever device is at the end. I have never seen anyone crazy enough to do anything like this.

Note that software is blissfully unaware of any hubs between the host controller and the target device.

Note that cable length is limited to 5 meters, so if you did the absurd thing of getting 5 hubs and stringing things out as far as you could, you could reach to 30 meters away. I would be a gigantic pain in the ass and why would you do it?

There are 3 kinds of USB host controllers, each with their own specification! USB 3 adds a fourth, but we weren't going to talk about that. You can tell that a committee couldn't agree on things.

Wires and signals

There are 4 wires in a USB cable, two of these are power (+5) and ground. The remaining two carry a differential data pair. All are inside of a shielded cable. At most 500 mA can be drawn by a single USB device, and a device must announce its current requirements during enumeration, and is not allowed to change them later. Note that hubs will require a source of external power if they are expected to supply a total of more than 500 mA (minus their internal requirements). There is lots of fine print and important details about power requirements.

Each USB device identifies itself with a pair of numbers (vendor and device ID). This allows "plug and play" (oh, how we hate this phrase), wherein the host operating system can dynamically decide what device driver to delegate to handle each USB device that appears on the bus.

A USB cable consists of 4 conductors:

Note that there is only one data pair (in contrast to ethernet which has two pairs). This implies that USB uses some kind of half duplex protocol where first one side talks and then another side replies and there is some orderly control over who is sending and who is receiving at any given point in time. We will get to all this in due time.

A USB cable is limited to a length of 5 meters (about 16 feet). To reach out further than this, you have to use USB hubs (see above).

A USB 3.0 cable has the exact same four conductors just described, for compatibility with USB 2.0. It also adds 5 new conductors (a ground and two twisted pairs) to support the new higher speed transfers with different signalling.

USB connectors

There are standard, mini, and micro USB connectors at this time, and who knows what the future holds. Actually it holds USB 3.0 which has some new connector issues, which we are not fully exploring here.

Cables have distinct upstream and downstream ends.

Note that the "A" end of USB 2.0 and USB 3.0 are mechanically compatible and desgined to interoperate. This means that you can plug an "old" usb 2.0 gadget into a "new" usb 3.0 socket and it will work, which is a good thing.

Interestingly, a standard male USB A plug is rated for only 1500 insertions, at which point it is expected to get "sloppy" and require replacement. The delicate looking micro USB plug is actually more durable than the mini plug, being rated for 10,000 insertions. The trick with the mini is to build the device to solidly reinforce the connector within the device. It is often a surface mount connector that easily can be popped off of a circuit board.

The familiar big flat end of a cable that you plug into your computer is called a standard "A" receptacle.

At one point I needed to repair a device with a broken micro USB connector. I replaced it with a standard "B" female connector, and needed to figure out the pinout for the female "B". It looked like this, viewed from the underside (the copy I obtained had 4 pins on 0.1 inch centers on the bottom:

	Vcc   D-

	Gnd   D+

	  ^^^  Insert cable from here

Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org