How does a USB work for dummies?

What is USB?

USB stands for Universal Serial Bus. It is a standard protocol that allows devices to connect and communicate with each other. USB was created in the mid 1990s to standardize connections between computers and peripherals like mice, keyboards, printers, cameras and more.

The main benefits of USB are:

  • Standardization – One USB port that can connect many types of devices.
  • Ease of Use – USB devices are plug-and-play with automatic configuration.
  • Speed – USB provides faster data transfer speeds compared to old serial and parallel ports.
  • Expandability – Multiple USB devices can be daisy-chained together.

USB has become the standard interface for connecting devices to computers and other peripherals. Most computers today come with multiple USB ports built-in.

USB Versions and Speed

There have been several versions of the USB standard over the years with different connection types and speeds:

USB Version Speed Connector Type
USB 1.0 1.5 Mbps (Low Speed) Type A and Type B
USB 1.1 12 Mbps (Full Speed) Type A and Type B
USB 2.0 480 Mbps (High Speed) Type A and Type B
USB 3.0/3.1 5 Gbps (SuperSpeed) Type A, Type B, Type C
USB 3.2 10/20 Gbps (SuperSpeed+) Type C

The most common USB version today is USB 2.0 and 3.0. USB 3 provides up to 10 times faster transfer speeds but is backwards compatible with USB 2.0.

USB Type C is the newest USB connector type that is being used on modern smartphones, tablets and laptops. It is reversible and supports the faster USB 3.1 and 3.2 data speeds.

USB Cable

A USB cable consists of four wires:

  • VCC – Provides +5 volts of power to a connected USB device.
  • D- – USB data cable for transmitting data.
  • D+ – USB data cable for receiving data.
  • GND – Ground wire.

The power wires allow USB devices to be powered directly from the USB port without extra power cables. The data wires carry all communication between the USB device and computer.

In a USB cable there are always a pair of data wires labeled D+ and D-. They carry the actual data signals.

The power and ground wires provide power to the USB device. A standard USB port provides 5V, 500mA of power but there are charge-only USB ports that can provide higher current ratings up to 2A.

USB Device Communication

When you first connect a USB device, the computer initiates a process called USB enumeration to identify the device and configure it. This involves several steps:

  1. The USB host controller detects a new connection and resets the USB port. This prepares the data wires for communication.
  2. An interrupt is sent to the host controller to signal a new device has been attached.
  3. The host queries the device for information and assigns it a unique address.
  4. The device sends information about its capabilities, manufacturer, serial number, etc.
  5. The host loads the appropriate driver for the USB device.
  6. The necessary data pipes between the host and device are configured.
  7. The device is now ready to send/receive data.

During enumeration, the host loads the appropriate drivers and software required to operate the USB device. This allows devices from different manufacturers to work seamlessly on any computer.

Once enumeration is complete, communication between the USB device and computer is handled by host controller software and hardware. This facilitates data transfer between the USB device and the computer’s operating system.

USB Device Types

There are several device classes that are standardly defined by the USB protocol:

  • HID (Human Interface Device) – Keyboards, mice, gamepads, joysticks
  • Mass Storage – USB flash drives, external hard drives, memory card readers
  • Communications – Modems, networking adapters
  • Audio – Headsets, microphones, speakers
  • Printer – Printers, scanners
  • Video – Webcams
  • CDC (Communication Device Class) – Ethernet adapters, modems

The USB host recognizes these standard device classes during enumeration and loads the appropriate drivers. For other specialized USB devices, custom drivers may need to be installed.

USB Host Controllers

The USB host controller is the hardware interface that manages all data transfer between the USB device and computer. It acts as the conductor between the USB software stack and the hardware ports.

Inside every USB host controller there are multiple endpoints. Each endpoint facilitates data transfer for connected USB devices. There is one endpoint for each device that is plugged into the controller.

The main types of USB host controllers are:

  • UHCI (Universal Host Controller Interface) – Original USB 1.1 host controller interface created by Intel. Supported USB 1.1 speeds.
  • OHCI (Open Host Controller Interface) – Open standard created as an alternative to UHCI. Provides full and low speed USB transfers.
  • EHCI (Enhanced Host Controller Interface) – Designed to support USB 2.0 Hi-Speed transfers up to 480 Mbps.
  • xHCI (Extensible Host Controller Interface) – Modern USB host controller standard that supports all prior versions as well as new USB 3.x SuperSpeed transfers.

Most modern computers have an xHCI controller which provides support for USB 1.0, 2.0 and 3.x devices. This allows you to connect both old and new USB devices to the same port.

USB Ports and Connectors

There are several types of USB ports and connectors that are used to connect devices.

USB Type A – This is the standard rectangular USB port or plug found on computers and hubs. It is designed for connecting USB cables.

USB Type B – Typically a square shaped port used on USB peripherals and devices. It connects to a type A cable.

USB Type C – A newer slim port that is oval shaped and allows connections in both orientations. Found on newer smartphones and laptops.

USB Mini – A smaller version of USB typically used on smaller devices like cameras and phones.

USB Micro – An even smaller USB variant often used on charging cables for mobile devices.

So in summary:

  • Type A – Found on host computers and hubs.
  • Type B – Found on USB devices and peripherals.
  • Type C – New slim reversible connector.
  • Mini & Micro – Small variants for smaller devices.

USB Hubs

A USB hub allows you to connect multiple USB devices to a single USB port on your computer. It expands a single port into multiple ports.

Some common reasons to use a USB hub include:

  • You need more USB ports than built into your computer.
  • Connecting devices that are far away using a long USB cable.
  • Charging multiple USB devices from one port.
  • Isolating and protecting devices from other connected devices.

There are two main types of USB hubs:

Passive Hubs – These are basic hubs that provide additional USB ports but do not boost power or data signals.

Active Hubs – Active hubs include circuitry to boost power and re-amplify data signals. This allows you to use longer cables and connect devices further away without degradation.

Most USB hubs connect using a type A connector to the host while providing type A ports for connecting devices. Some hubs may include additional charging ports that provide higher power for charging phones and tablets.

USB Power and Charging

All USB ports provide power over the VBUS and GND pins to power connected USB devices.

A standard downstream USB 2.0 port provides 5V, 0.5A of power which is suitable for lower power devices like mice or keyboards. This is enough to allow bus-powered USB devices to operate without external power supplies.

Some special charge-only USB ports can provide up to 2A power for charging higher power devices like tablets and phones. The charging ports only provide power and do not transfer any data.

USB 3.1 introduced USB Power Delivery which allows negotiation of higher voltages and power up to 100W. This enables fast charging of laptops, phones and power-hungry devices over supported USB-C cables.

USB Battery Charging supplementsm the USB 2.0 spec and enables high-powered 1500mA charging from compatible charging downstream ports. This allows fast charging of phones and tablets using standard USB cables.

So in summary, a USB port can provide power for:

  • Low power bus devices like keyboards – 5V, 0.5A
  • Charging phones and tablets – 5V, 1.5-2A
  • Power Delivery over USB-C – up to 20V, 5A (100W)

This means USB has the flexibility to power anything from small sensors to high-end laptops and monitors.

USB Data Rates and Protocols

USB supports several modes of communication between devices based on speed:

USB 1.0

  • Low Speed – 1.5 Mbps
  • Control, keyboard, mice

USB 1.1

  • Full Speed – 12 Mbps
  • Printers, scanners, cameras

USB 2.0

  • High Speed – 480 Mbps
  • Storage, video, networking

USB 3.x

  • Super Speed – 5 Gbps
  • High-bandwidth storage and graphics

USB 3.2

  • Super Speed+ – 10 Gbps / 20 Gbps
  • Latest generation specs

USB employs several protocols to support different data flows between devices:

Control Transfers – Low bandwidth used for command and control signals like enumeration or transactions.

Interrupt Transfers – Small periodic data transfers such as characters from a keyboard.

Bulk Transfers – Large bursty data transfers such as file transfers. High bandwidth utilization.

Isochronous Transfers – Real-time constant data rate transfers like audio or video streaming. Guaranteed latency.

By supporting multiple transfer types, USB is able to provide support for a wide variety of device capabilities and data flows.

USB Alternate Modes

USB alternate modes allow the USB-C connector and cable to be used for alternate protocols besides USB like:

  • DisplayPort for video output
  • Thunderbolt 3 for peripherals and displays
  • HDMI output to HDMI monitors and TVs
  • Analog audio transmission

This means a USB-C port can output video signals directly to a display without any additional adapters. It helps extend the capabilities of USB-C for both data and video transmission.

Alternate modes are configured using the USB Power Delivery specification over USB-C cables. This enables new functionality while maintaining backwards compatibility with existing USB 2.0 and 3.1 data transmission.

Some common alternate modes include:

  • DisplayPort Alternate Mode – DisplayPort video output
  • MHL Alternate Mode – HDMI and analog audio output
  • Thunderbolt Alternate Mode – Thunderbolt peripheral interconnect

So a USB-C port with alternate modes allows you to connect monitors, send video, charge devices and use Thunderbolt devices all using the same compact connector!

Conclusion

USB has evolved from a simple way to connect keyboards and mice to a universal connectivity standard capable of everything from data to video to charging.

With the introduction of USB-C and new higher speed versions like USB 3.2 and Thunderbolt 3, the interface continues to be the de-facto standard for connecting devices to computers and other peripherals.

USB’s plug-and-play usability, universality, speed and versatility make it integral to the modern world of computers, devices and connectivity.