Understanding USB Technology: Features, Speeds, and Protocols
Introduction to USB Technology
USB (Universal Serial Bus) interface is a method of data transmission and power distribution that was introduced to the market for PCs and peripherals to enhance the old and tedious serial interfaces (RS-232) and parallel interfaces. The interface consists of four wires, offers various speeds, and is “plug and play,” requiring no external power in most cases.
The Universal Serial Bus allows the connection of up to 127 peripherals to a single port of a PC, with automatic detection and configuration as soon as it is physically connected. There is no need to install any additional hardware or software, or to restart the computer. It was developed by leading companies in telecommunications and computing: Compaq, DEC, IBM, Intel, Microsoft, NEC, and Northern Telecom.
Key Features of USB
The USB bus supports the simultaneous exchange of data between a host computer and a wide range of peripherals. All peripherals share the bandwidth of the bus through a token-passing protocol. The computer provides the token to the selected peripheral, and then the peripheral returns the token in its response. This allows devices to be connected and disconnected from the bus without affecting other devices.
Since all peripherals share the bus, and information may be submitted at any time and simultaneously, the data is divided into packets. Each packet header contains an identifier that indicates the target audience. Packets are used in a robust system for detecting and correcting errors, based on a CRC.
USB Speeds
- Low-Speed (USB 1.0): Offers a transfer rate of up to 1.5 Mbit/s (192 KB/s). Used mostly for human interface devices like keyboards, mice, and joysticks (still in use due to lower cost).
- Full Speed (USB 1.1): Transfer rate up to 12 Mbit/s (1.5 MB/s). This was the fastest before the USB 2.0 specification. These devices divide the bandwidth of the USB connection between them, based on an algorithm for FIFO buffers.
- High Speed (USB 2.0): Transfer rate up to 480 Mbit/s (60 MB/s).
- Super Speed (USB 3.0): Currently in the final development phase, with a transfer rate of up to 4.8 Gbit/s (600 MB/s). The bus speed is ten times faster than USB 2.0, due to the replacement of the traditional link of one optical fiber that works with traditional copper connectors, to make it compatible with previous standards.
Physical Interface
The USB defines two lines to transmit data (D+ and D-) and two others to transmit power (VBus and GND), thus avoiding the use of external power. For data transmission, it uses an algorithm called NRZI (Non-Return to Zero Inverted).
USB transfers signal and power to peripherals using a 4-wire cable, shielded for transmissions at 12 Mbps or higher and unshielded for transmissions at 1.5 Mbps.
In the shielded cable, the wire pair is twisted for the signal, while the ground and power wires are straight. In the case of unshielded cables, all wires are straight.
At the electrical level, the USB transfers signal and power on four wires.
At the power level, the cable provides a rated voltage of 5V. It is necessary to correctly define the wire diameter so that there is not an excessive voltage drop on the cable. A termination resistor is installed on the data line to detect and trace port and speed settings.
At the signal level, it has a characteristic impedance of 90Ω. The receiver sensitivity can be at least 200mV and must be able to admit a good degree of rejection of common-mode voltage. The clock is transmitted in the flow of data encoding is NRZI type, there being a device that generates a bit of stuffing (bit stuffing) which ensures that the clock frequency remains constant. Each packet is preceded by a synchronization field.
USB Connector Types
There are two different types of connectors, depending on the device platform: A and B.
Type-A connectors are rectangular and generally used for devices that do not require too much bandwidth (such as keyboards, mice, webcams, etc.).
Type-B connectors have a square shape and are mainly used for high-speed devices (external hard drives, etc.).
Type A and Type B Connectors
USB Transfer Protocol
All USB devices are composed of a series of endpoints and a unique address assigned by the system. An endpoint is a buffer that stores data within the device. Each endpoint has a unique identifier that is assigned to a particular factory and direction of data flow. All devices must support endpoint 0, which is used for configuration.
Connections between the various endpoints of a device and the host are called pipes. Pipes allow data to move between host software and a device endpoint. Each pipe is determined by the type of service, endpoint number, packet size, address, etc.
There are four types of distinct endpoints (Control, Bulk, Isochronous, and Interrupt). Each type is used in a transfer, and the associations (pipes) that occur between these endpoints are:
- Control Pipe or Message: This is a communication channel between two control endpoints, one input and one output, so that bidirectional communication can be established. All devices have two control endpoints at address 0, which can be set before setting the device. Through this endpoint, the host can read about the USB device before starting the transfer.
- Stream Pipe: A unidirectional communication channel between the system and an endpoint of type Bulk, Isochronous, or Interrupt.
Transfers can be, depending on the endpoint, of the following types:
- Control Transfer: Used to make settings; there is always endpoint 0. All USB devices must support this type of transfer. Control data is used to configure the peripheral when connected to USB. Some specific drivers can use this link to upload their own control information. This link has no data loss, since the detection devices have active error recovery at the USB.
- Isochronous Transfers: Used for the transmission of compressed audio or video. This type of transmission operates in real-time. This is the highest priority mode. Only high-speed and full-speed devices can incorporate isochronous endpoints. Voice transmission is an example of this application. If it is not transmitted properly, parasites (glitches) can be heard, and the application can detect certain errors called underruns.
- Interrupt Transfer: Used for the transmission of small, rapid packets aimed at human perceptions (mouse pointers). This type of transfer is for devices that must receive regular attention and use low-speed devices. This type of transmission ensures the transfer of small amounts of data. The response time cannot be less than the value specified by the interface. The mouse or other pointing device is a typical application of this mode of transmission.
- Bulk Transfers: This mode is used for transmitting large amounts of information. Like the control rate, this link has no data loss. This type of transfer is useful when the transfer rate is not critical, such as sending a file for printing or receiving data from a scanner. In these applications, the transfer is fast, but you can wait if necessary. Only medium to high-speed devices use this type of transfer.
Enumeration
When you connect a USB device to a PC, a process called enumeration occurs. The host communicates with the device, which provides its parameters, such as:
- Power consumption expressed in units of charge
- Number and types of endpoints
- Product class
- Transfer type
- Reason for scrutiny, and so on.
The enumeration process is initialized by the host when it detects that a new device has joined the bus. The host assigns an address to the device and enables the configuration, allowing the transfer of data.