24.1 USB Characteristics
All USB devices share several general characteristics. Among these are:
- Hot swapping
In theory, at least, USB peripherals can be connected to and disconnected from the bus at any time, without shutting down the computer or taking any action to inform applications or the OS that a device is being added or removed. In practice, this is not always the case, particularly with older interfaces and devices.
- Automatic configuration
The USB host controller chipset installed on the PC motherboard or an add-on USB port card manages driver software and allocates bandwidth to each USB device attached to the bus. When a device is added or removed, the USB host controller automatically loads or unloads the driver for that device.
| || |
Educate your USB drivers. When you connect a USB peripheral to a root hub port or external hub, the USB driver "learns" that device/port combination. If you connect and disconnect USB devices frequently, you can make things faster and easier by allowing the PC to learn all combinations of device and port. Rather than simply connecting a device to a port and leaving it connected, plug that device in turn into each available USB port. That way, you can connect any device to any port and have it recognized immediately.
- Interrupt sharing
A USB host controller occupies one interrupt, which is shared among all devices attached to the bus. This small resource footprint allows multiple USB host controllers to be installed in a system without undue demands on scarce IRQs. Although each USB host controller can in theory support as many as 127 devices, it's often better to distribute multiple USB devices among host controllers to avoid conflicts.
- Bandwidth sharing and allocation
A USB 1.1 bus provides 12 Mb/s of bandwidth and a USB 2.0 bus provides 480 Mb/s of bandwidth, which is shared among all devices attached to the bus. Many devices may communicate simultaneously on a USB, provided that adequate bandwidth is available to service all of them at the same time. Properly designed USB peripherals and drivers use bandwidth dynamically, releasing bandwidth they are not using so that it can be used by other devices. For isochronous (time-critical) tasks such as audio or video streams, USB permits dedicating bandwidth as needed to a particular peripheral, although that dedicated bandwidth then becomes permanently unavailable for use by other peripherals.
- Embedded power connections
In addition to providing a data connection, USB provides electrical power to peripherals, allowing you to eliminate the tangle of power cables required by traditional peripherals. That power, however, is limited to 500 milliamps (MA), which must be shared by all unpowered devices connected to the USB port. In practice, that means that only low-power peripherals, such as keyboards and mice, can be powered directly by a USB connection. High-power peripherals, such as printers and scanners, usually (but not always) have their own power bricks and are powered directly from a standard AC receptacle. For example, the Canon Canoscan 1220U relies on the USB port for power. Despite the minimal amount of current available on the USB port, it is possible to connect multiple unpowered USB peripherals by connecting them to powered USB hubs, each port of which has its own 500 milliamp supply.
| || |
Multiple USB devices connected to an unpowered hub can collectively exceed the maximum power that hub can deliver, particularly if you have connected one or more high-draw hub-powered devices. Many unpowered hubs, particularly those embedded in keyboards and similar devices, do not supply the full 500 mA called for by the USB specification. For example, the USB hub embedded in Microsoft USB keyboards can supply at most 200 to 250 mA. Connecting too many devices or devices that draw too much current is one frequent cause of USB problems.
The following sections detail other important characteristics of USB interfaces and devices.
24.1.1 USB Versions
Three versions of USB exist:
- USB 1.0
USB 1.0 was the original specification. Most systems produced from 1996 through mid-1998 have USB 1.0 ports. USB 1.0 supports data rates of 1.5 Mb/s and 12 Mb/s. Relatively few USB 1.0 peripherals were produced, because by the time USB peripherals began shipping in volume USB 1.0 had been superseded by USB 1.1. USB 1.0-compliant peripherals generally operate properly when connected to a USB 1.1 or USB 2.0 interface, but USB 1.1 or USB 2.0 peripherals may not function properly when connected to a USB 1.0 interface. USB 1.0 interfaces are primitive and buggy, so if your motherboard has USB 1.0 ports, we recommend you disable those ports in BIOS Setup and install an add-on PCI USB port card. The first release of Windows 98 included USB 1.0 support.
- USB 1.1
USB 1.1 was formalized in September 1998, although many manufacturers produced USB 1.1-compliant motherboards and peripherals based on the proposed standard long before the formal standard was adopted. USB 1.1 also supports data rates of 1.5 Mb/s and 12 Mb/s, and was largely a clarification of ambiguities in the USB 1.0 specification. A few functional definitions were changed in USB 1.1, including minor changes to hub specifications, removing provision for battery-powered hubs, adding interrupt-out mode, and changes to recommended enumeration to eliminate the requirement for an 8-byte endpoint zero. Most changes, however, merely tightened up the existing requirements, because experience had shown that there were enough ambiguities in the USB 1.0 specification to allow producing interfaces and devices that complied with the standard but were not interoperable. USB 1.1 interfaces and devices began shipping in mid-1998 and are still in production. Early USB 1.1 interfaces and devices suffered many incompatibilities, but current production models have relatively fewer such issues. You can download the Universal Serial Bus Revision 1.1 Specification from http://www.usb.org/developers/data/usbspec.zip.
- USB 2.0
USB 2.0 was formalized in April 2000, with various errata and Engineering Change Notices later incorporated as supplements. USB 2.0 supports data rates of 1.5 Mb/s, 12 Mb/s, and 480 Mb/s, and provides full backward compatibility with USB 1.0 and USB 1.1 devices.
The uptake of USB 2.0 was slower than expected, because USB 2.0 chipsets were slower in arriving than expected and because Microsoft initially did not provide USB 2.0 Windows drivers. In early 2002, Microsoft shipped native USB 2.0 drivers for Windows XP, and announced that they would ship native Windows 2000 USB 2.0 drivers later in 2002. Microsoft has no plans to provide Windows 9X USB 2.0 drivers. Using USB 2.0 under Windows 9X requires drivers supplied by the manufacturer of the motherboard (or PCI/USB card) and USB 2.0 peripherals.
With so many of the major players in the computer industry backing USB 2.0, there is little doubt that it will ramp up quickly during 2002 and into 2003. Most motherboards produced from mid-2002 onward will have USB 2.0 ports, and USB 2.0 peripherals will begin to ship in volume during 2002. Older systems can be upgraded to support USB 2.0 by adding an inexpensive adapter.
In addition to its much higher speed, the attraction of USB 2.0 is its standardization. Earlier USB versions had frequent compatibility problems, not least because two different and slightly incompatible controller standards existed. USB 2.0 defines one controller interface, called the Enhanced Host Controller Interface (EHCI), which should go a long way toward eliminating compatibility problems. This remains to be seen, because USB 2.0 devices are still relatively uncommon as we write this, but we think it likely that USB 2.0 will come much closer to the Plug-N-Play ideal than USB 1.0/1.1 ever did.
For an overview of USB 2.0, see http://www.usb.org/developers/usb20/backgrounder.html. You can download the most recent complete Universal Serial Bus Revision 2.0 Specification from http://www.usb.org/developers/data/usb_20.zip.
24.1.2 USB Speeds
USB defines the following three speeds, all of which can coexist on one bus:
- Low Speed
Low Speed USB peripherals operate at a data rate of 1.5 Mb/s, and are supported by USB 1.1 and USB 2.0 interfaces. Low Speed USB is intended for such low-bandwidth devices as mice and keyboards, and is designed to be inexpensive to implement. Low Speed USB devices use a captive cable that can be no longer than 3 meters. Actual throughput on Low Speed USB is typically limited by overhead and other factors to about 1.2 Mb/s, or 150 KB/s.
- Full Speed
Full Speed USB peripherals operate at a data rate of 12.0 Mb/s, and are supported by USB 1.1 and USB 2.0 interfaces. Full Speed is the fastest speed supported by USB 1.0 and USB 1.1, and is intended for such moderate-bandwidth devices as printers and scanners. Full Speed USB devices use active components, which are more expensive to implement than the passive components used by Low Speed USB. Full Speed USB devices use a detachable cable that can be no longer than 5 meters. Full Speed USB seldom exceeds actual throughput of 900 KB/s or so.
- High Speed
High Speed USB peripherals operate at a data rate of 480.0 Mb/s, and are supported only by USB 2.0 interfaces. High Speed USB is intended for such high-bandwidth devices as external drives. High Speed USB devices use active components that are more expensive than Full Speed USB components. Also, High Speed USB hubs require additional circuitry to arbitrate between mixed High Speed and Full Speed devices connected to that hub. Accordingly, High Speed USB devices, particularly hubs, are typically more expensive than USB 1.1 devices, although we expect the differential to disappear by the end of 2002. High Speed USB devices use the same detachable cable used by Full Speed USB devices, which can be no longer than 5 meters. High Speed USB typically achieves actual maximum throughput of 35 to 40 MB/s, which is fast enough to keep up with all but the fastest hard drives.
Note that USB bandwidth is shared among all devices connected to the bus, and that the system reserves some bandwidth (typically 10%) for control signals and other administrative purposes. Although many High Speed USB devices require much less than 480 Mb/s, if you do connect more than one high-bandwidth High Speed device to a single USB channel you may throttle the bandwidth available to each when more than one are operating. In that situation, if your system has more than one USB 2.0 HCI, we recommend splitting your high-bandwidth devices among different host controllers.
24.1.3 USB Topology
USB uses a tiered-star topology, shown in Figure 24-1. At the center of the star is the USB host, which defines the USB, and only one of which is permitted per USB. (Note, however, that more than one USB host may be installed in a PC, and in fact most recent motherboards have multiple USB hosts installed.) The USB host resides inside the PC, and is implemented as a combination of hardware, firmware, and software. The USB host has one or more USB root hubs, which provide attachment points called USB ports to which USB hubs and USB functions may be connected. (Loosely speaking, a USB Function is a peripheral such as a scanner, printer, mouse, digital camera, etc.)
Figure 24-1. USB topology
USB hubs use two types of connections. An upstream connection links the USB hub to another USB hub in the next higher tier. A downstream connection links the USB hub to another USB hub or to a USB function located in the next lower tier. Each USB hub has one upstream port, and may have as many as seven downstream ports. Via daisy-chaining, USB allows connecting a maximum of 127 devices (USB hubs and USB functions) in a maximum of seven tiers. The limitation on number of tiers is required to ensure that the most distant USB device can communicate within the maximum allowable propagation delay defined in the USB specification.
| || |
In practical terms, you seldom need more than two or three USB tiers to connect a typical assortment of USB peripherals to a PC. However, it's worth noting that the USB limit of 5 meters on cable length applies between tiers. For example, if you need to locate a USB peripheral some distance away from a PC, you can extend the separation to as far as 30 meters by putting the USB peripheral in Tier 7 and installing USB hubs in Tiers 2 through 6. Note that Tier 7 can contain only USB functions. A USB hub that resides in Tier 7 is useless, because any device connected to that hub resides in the nonexistent Tier 8.
If you mix USB 1.1 and USB 2.0 devices on a bus, it's important to understand the following points:
USB 2.0 hubs support USB 1.0/1.1 and USB 2.0 devices, including downstream USB 1.0/1.1 hubs and USB 2.0 hubs, providing full bandwidth to each device according to its version.
USB 1.0/1.1 hubs support USB 1.0/1.1 and USB 2.0 devices, but USB 2.0 devices connected to a USB 1.1 hub function as USB 1.1 Full Speed devices (i.e., at 12 Mb/s maximum), which means that it is pointless to connect a USB 2.0 hub downstream from a USB 1.1 hub.
Although USB 2.0 hubs provide transparent support for Low Speed and Full Speed USB devices, that support incurs significant overhead on the USB 2.0 hub and is intended only for limited use, such as connecting a USB mouse and keyboard. Connecting multiple Low Speed or Full Speed USB devices to a USB 2.0 hub, either directly or downstream, degrades the ability of the USB 2.0 hub to support High Speed USB 2.0 devices. If you have many Low Speed or Full Speed USB devices, connect them to a USB 1.1 root hub port and reserve your USB 2.0 ports for High Speed devices.
24.1.4 USB Cables and Connectors
USB connectors and cables are simple and rigidly standardized. USB defines three plug/jack combinations, designated Series A, Series B, and Series mini-B.
| || |
Series mini-B connectors are smaller versions of the standard Series B connector, designed for devices like digital cameras, for which a standard Series B connector is physically too large. Most devices that use Series mini-B connectors come with a Series A to Series mini-B cable.
The narrow Series A jacks, shown in Figure 24-2, appear on the back of a PC or USB hub, and may be labeled "down" jacks. These provide connection points for USB peripherals, including USB hubs. Some USB peripherals have permanently connected cables that terminate in a Series A plug. Series A plugs always face upstream, toward the host system, and Series A jacks always face downstream, toward the device.
Figure 24-2. USB Series A connector
Peripherals that do not have a permanent cable instead have a Series B jack, shown in Figure 24-3. Series B plugs always face downstream, and Series B jacks always face upstream. Use a standard USB A-B device cable to connect these peripherals to the PC or hub.
Figure 24-3. USB Series B connector
A USB cable uses four wires, two each for data and power. The data wires are a green/white twisted pair that carry +Data and -Data respectively. USB uses differential digital signaling, which means that the same signal is present on each data wire, but with different polarity. This allows electrical noise to be eliminated from the circuit because induced voltages affect the + and - signals equally, netting to zero. The power wires may or may not be twisted. The red wire carries nominal +5V DC, and the black is a ground return for the power circuit. The USB specification permits cables as long as 5 meters (~16 feet), a limitation enforced by the allowable propagation delay between a port and a connected device.
The USB specification defines only three types of USB cable:
- Low-speed captive cable
Keyboards and similar low-speed devices use a USB low-speed captive cable. The maximum allowable length for a low-speed USB cable is 3 meters (9 feet, 10 inches). This limit is determined by the rise and fall times of low-speed USB signaling, which restricts low-speed USB cables to a maximum length only 60% that of standard full-speed/high-speed cables. A USB standards-compliant low-speed cable must be captive or hard-wired, which is to say that the cable either must be permanently connected to the device or must use a nonstandard or proprietary connector on the end that connects to the device. The concern is that if a low-speed USB device used a standard USB device connector, a standard detachable USB cable longer than acceptable for low-speed USB devices could be used to connect that device.
- Standard detachable cable
Most full-speed and high-speed USB devices use a USB standard detachable cable. This cable is terminated on one end with a Series A plug and on the other with a Series B plug or Series mini-B plug. The maximum allowable length for a standard detachable cable is 5 meters (16 feet, 5 inches).
- High-/full-speed captive cable
Some full-speed and high-speed USB devices use a USB high-/full-speed captive cable. This cable is terminated on one end with a Series A plug. The other end terminates either as a hard-wired connection to the device or with a vendor-proprietary connector. The maximum allowable length for a high-/full-speed captive cable is also 5 meters.
Although the USB standard states that only these three cable assemblies are acceptable, it further emphasizes it by specifically prohibiting the following cable assemblies, all of which have been manufactured and sold despite their non-compliance:
- Cable assembly that violates USB topology rules
Some vendors produce cables that terminate with two Series A plugs, two Series B receptacles, or two Series mini-B receptacles, which allow connecting USB ports and devices in prohibited combinations.
| || |
Cables with two Series A plugs are particularly dangerous, because they can be used to link two powered ports with differing ground potentials, which may cause a fire. In theory, such a cable could be used to link two PCs directly via USB. In practice, this does not work and is dangerous. The only acceptable way to link two PCs via USB is to use a USB bridge. Note that some cables have USB bridge circuitry built into them, and so are in reality more than a simple cable. This prohibition does not apply to such USB bridge devices.
- Extension cable assembly
A cable that terminates with a Series A plug and a Series A receptacle, a Series B plug and a Series B receptacle, or a Series mini-B plug and a Series mini-B receptacle is specifically prohibited by the USB specification. However, many vendors sell such cables, including some vendors who should know better. The purpose of these cables is to extend the distance between port and device by joining multiple cable segments. The risk is that the joined cables will exceed the maximum 5 meters permissible under the standard, which can cause problems from sporadic operation to complete failure of the entire USB. Even if the joined cables total less than 5 meters, the electrical characteristics of the extended cable may fall outside specifications. Avoid using extension cables under any circumstance.
- Standard detachable cable assembly for low-speed USB devices
The USB specification does not permit low-speed devices to use standard detachable cables. Standard detachable cables are used only to connect high-speed/full-speed devices. Their capacitive load exceeds the maximum allowable for a low-speed device.
| || |
There is much confusion about which USB cables can be used at which speeds. Some vendors have confused the issue by producing so-called USB 2.0 cables. In fact, any detachable USB 1.1 cable is also a USB 2.0 cable, and can be used at 480 Mb/s. Note, however, that many of the cables supplied with USB 1.1 devices are technically not USB 1.1 cables because they don't meet USB requirements. These out-of-spec cables may work reliably with USB 1.1 devices, but are simply not good enough for the higher data rate of High Speed USB 2.0 connections. By some estimates, 30% or more of the cables supplied with USB 1.1 devices do not meet USB specifications.
24.1.5 USB Data Transfer Modes
USB uses a set of unidirectional and bidirectional pipes to transfer user data and control information between the host and USB devices. Each device may support multiple pipes for different purposes, and data transferred in one pipe is independent from data transferred in other pipes. For example, a USB printer might have one pipe that it uses to receive page data from the host, and a second pipe that it uses to transfer status information to the host. USB defines the following data flow types:
- Isochronous Data Transfers
Isochronous Data Transfers are used for periodic, continuous communication between the host and a device, typically time-critical data such as audio or video streams. Isochronous Data Transfers are enabled by reserving the required amount of bandwidth for the isochronous device, which the USB host controller makes unavailable to other devices whether or not the isochronous device happens to be using that bandwidth at any given time. Isochronous Data Transfers have the highest priority for bandwidth. If all available bandwidth is reserved for Isochronous Data Transfers, no other device can use the USB.
- Interrupt Data Transfers
Interrupt Data Transfers are used for small, limited-latency transfers when timely, reliable delivery of data is required, for example to receive coordinate changes from a mouse or status changes from a modem. Interrupt Data Transfers have lower priority for available bandwidth than do Isochronous Data Transfers.
- Control Transfers
Control Transfers are used to configure a device when it is connected to the USB, and may be used for other device-specific control, configuration, and status commands, including controlling other pipes on the device. Control Transfers usually comprise small amounts of data that is not time critical, and have lower priority for available bandwidth than do Interrupt Data Transfers.
- Bulk Data Transfers
Bulk Data Transfers are used to communicate large amounts of non-periodic, bursty data with relaxed timing constraints to a device, e.g., sending page data to a USB printer. Bulk Data Transfers are not time critical, and have the lowest priority for available bandwidth. Some early HCIs implemented bulk mode poorly, and so work properly with USB devices like keyboards and mice but are unsuitable for use with devices like scanners and printers.