How does a USB plug in work?

USB (Universal Serial Bus) is a standard interface used for connecting devices like keyboards, mice, phones, cameras and external hard drives to computers and other devices. The USB plug is the rectangular connector that goes into the USB port on a computer or device. So how exactly does this plug in work to transfer data between devices?

What is a USB plug?

A standard USB plug has a rectangular metal casing that houses 4 pins or contacts. The casing has a longer flat side along the top and bottom and a shorter flat side along the left and right. The pins are located inside the rectangular casing in a single row. The USB symbol is often printed on the top flat side of the plug casing to indicate the correct orientation when plugging it into a USB port.

The 4 pins or contacts in a USB plug are:

  • VBUS: Provides power from the USB host. This is usually red in color.
  • D-: Carries data to the USB host. This is usually white in color.
  • D+: Carries data from the USB host. This is usually green in color.
  • GND: Provides ground or a reference voltage. This is usually black in color.

The USB plug connects into a corresponding USB port or receptacle on a computer, phone, or other device. The USB port also contains pins that align with the pins on the USB plug when it is inserted.

USB communication

The USB system allows communication between a host device like a computer and a peripheral device like a mouse or flash drive. The host acts as the master and controls communication, while the peripheral responds as the slave. Here is how it works:

  • The VBUS and GND pins provide power from the host to the peripheral device. The host supplies 5 volts DC power over these pins.
  • Data is transmitted over the D- and D+ pins. The host uses the D+ and D- pins to send and receive data from the peripheral device.
  • USB supports half duplex communication meaning data can only travel in one direction at a time.
  • The host initiates all communication on the bus and coordinates data transmission between devices.

When you connect a device to a host via USB, the host detects and enumerates the device which means it assigns an address and configuration to the peripheral. Once enumeration is complete, the host can send and receive data to and from the peripheral device.

USB protocols

There are several USB protocols or signaling standards that define the data transmission speeds and communication rules on USB connections.

Protocol Speed
USB 1.0 Low speed – 1.5 Mbps
USB 1.1 Full speed – 12 Mbps
USB 2.0 High speed – 480 Mbps
USB 3.0 SuperSpeed – 5 Gbps
USB 3.1 SuperSpeed+ – 10 Gbps

The protocol defines factors like the clock rate, encoding method, timing, packet sizes and more. The higher speed protocols build on the functions of the earlier protocols. For example, USB 3.0 added new SuperSpeed connections but devices still retain USB 2.0 compatibility.

Key differences

  • Higher speed USB connections use more pins dedicated for transmitting and receiving differential data signals.
  • Faster protocols increase the polling rate and allow communication with devices to happen more frequently.
  • Higher speed protocols use advanced encoding techniques like 8b/10b encoding to boost throughput.

The combination of more pins, faster polling, advanced encoding and other enhancements allow newer USB protocols to achieve such high speeds compared to earlier versions.

USB plug shapes and types

USB connectors come in different shapes and sizes. Here are some common USB connector types:

USB Type A

This is the standard rectangular USB plug found on cables that connect to peripherals and devices. It has a flat rectangular shape approximately 0.4 inches (10mm) wide by 0.2 inches (5mm) high. Type A plugs insert into downstream ports on hosts and hubs.

USB Type B

Type B plugs are square shaped with beveled edges on the top and bottom. They are often used to connect devices like printers, external hard drives and scanners to hosts. The square shape prevents the plug from being inserted incorrectly.

Mini USB

Mini USB connectors are smaller versions of the standard USB connectors used on smaller devices like cameras, GPS units and older phones. They have a width of approximately 0.07 inches (2mm).

Micro USB

Even smaller Micro USB connectors are approximately 0.06 inches (1.8mm) wide and were used on charging cables for phones, audio players and other small devices. The emergence of USB-C has made Micro USB less common.

USB-C

USB Type C is the newest USB connector standard. It has a reversible/symmetrical design that can be plugged in upside down. USB-C ports are now found on many laptops, phones and tablets and can transmit both power and data.

USB 3.0 connectors

USB 3.0 Type A plugs have an additional set of connectors compared to USB 2.0 plugs to allow SuperSpeed data transmission. The USB 3.0 Micro B plug also has an additional set of connectors.

Benefits of the USB interface

There are several benefits to the USB interface that have made it the most common interface for connecting devices:

  • Pluggable – USB devices are designed to allow easy plugging and unplugging. No reboots necessary.
  • Hot swappable – Devices can be connected and disconnected without turning off the system.
  • Expandable – USB allows up to 127 devices to be daisy chained together.
  • High data speeds – Faster USB protocols provide speeds up to 10 Gbps for transferring data like video, music, photos.
  • Low cost – USB cables and connectors are inexpensive to manufacture.
  • Universally compatible – USB provides universal connectivity between diverse host and device manufacturers.
  • Compact – USB connectors are much smaller and compact compared to older interfaces.

Thanks to these benefits, USB provides an easy plug-and-play interface for a wide range of devices to communicate with host computers and systems.

How does a USB port work?

A USB port or receptacle is found on host devices like desktop computers, laptops, phones, TVs and game consoles. The USB port connects to internal circuitry and a controller chip inside the host device. Here is how USB ports work on the inside:

  • The VBUS and GND pins from the USB port connect internally to 5 volt and ground power sources on the host device.
  • The D+ and D- data pins connect to a USB host controller chip.
  • USB host chips manage the enumeration process, coordinate data transfer, and implement the USB protocol.
  • The host chip allows the operating system to communicate with connected USB devices.

So the USB port pins connect to power and data pathways managed by the USB host controller. This allows enumeration, communication, and powering of peripherals over the port.

Host controller

The USB host controller chip acts as the interface between the host operating system and the USB peripheral devices connected to it. It performs several important functions:

  • Detects devices connected or removed from USB ports
  • Manages power distribution over VBUS to peripherals
  • Initializes enumeration and configuration of devices
  • Implementes USB protocols by packing and unpacking data
  • Transmits and receives packets of data over the USB bus
  • Handles data buffering and flow control
  • Maintains signaling states on the USB bus

The controller offloads USB management tasks from the main processor and allows USB communication to proceed smoothly. Most computing devices have an integrated USB host controller in their processor chipset.

How is power supplied over USB?

USB ports provide power over the VBUS and GND pins to power peripherals. How much power is provided depends on the USB standard:

  • USB 1.1 – Provides 5 V at up to 500mA (2.5W)
  • USB 2.0 – 5V at up to 500mA (2.5W)
  • USB 3.0 – 5V at up to 900mA (4.5W)
  • USB-C – 5V, 9V, 15V or 20V depending on capability

Devices like external hard drives may require more power and hence get additional power from a separate power cord that plugs into AC power. Low power devices like keyboards get enough power from the VBUS pin itself.

The USB host manages power distribution. Peripherals must initially pull only 5mA of current. After enumeration, they can draw up to 100mA. High power draw devices may be able to get up to 500mA after requesting higher current allocation.

USB cable wiring

A USB cable contains four wires that connect to the four pins on the USB plugs. Here is how the wires connect:

  • Red wire – Connects to the VBUS pin
  • White wire – Connects to the D- pin
  • Green wire – Connects to the D+ pin
  • Black wire – Connects to the GND pin

The connectors at each end depend on the type of USB devices being connected. For example a USB A to B cable would have a Type A plug on one end and a Type B plug on the other end.

Twisted pairs

The data wires D+ and D- form a twisted pair to reduce noise interference. The power wires also form a twisted pair. Twisting the wires shields them better against external interference from electromagnetic fields.

Key parts of a USB system

A typical USB system consists of:

  • Host – The USB host device containing USB ports and a host controller.
  • Hubs – Provide additional USB ports and allow daisy chaining connections.
  • Peripheral devices – The USB human interface devices, printers, cameras etc.
  • Cables – Carry power and data between USB devices.
  • Software Driver – Required on the host to communicate with peripherals.

The USB host manages all data flow and power over the bus. Devices connect in a tiered star topology with peripherals at the branches and the host at the center. Hubs are connection points enabling multiple peripherals to connect to the host. USB cables act as point-to-point connections between the device components.

USB developers and the role of USB-IF

The Universal Serial Bus was developed in the mid 1990s by a group of seven companies – Compaq, DEC, IBM, Intel, Microsoft, NEC and Nortel. The goal was to standardize the connection of computer peripherals to personal computers.

The USB 1.0 specification was released in January 1996. It specified data rates of 1.5 Mbps Low Speed and 12 Mbps Full Speed. This was followed by updates like USB 1.1, USB 2.0 and so on.

USB-IF or USB Implementers Forum is a non-profit organization created to support and accelerate USB adoption. It promotes USB standards and compliance testing across the industry. The USB-IF organization consists of over 700 companies working to deliver USB solutions.

Future USB generations

The USB standards continue to evolve with new higher speed generations:

  • USB 3.2 – Released in 2017, provides 20 Gbps with new multi-lane operation.
  • USB 4 – Announced in 2019, incorporates Thunderbolt 3 protocol and will offer up to 40 Gbps speeds.
  • USB 5 – Still in development and promises to double USB 4 speeds up to 80 Gbps.

Faster generations aim to meet demands for higher speed data transfers and improved power delivery to connected devices.

Conclusion

USB connectors and cables provide an easy plug-and-play interface to connect peripherals like mice, keyboards, phones and flash drives to computing devices. The host manages the USB bus and powers peripherals. The four pin interface allows power and data transfer. Progressively faster USB standards like USB4 and USB5 continue to evolve to meet demands for higher data transfer rates across platforms and devices.