|
USB fundamentals 101 Universal Serial Bus (USB) communications has greatly advanced the versatility of PCs and embedded systems with external peripherals. USB provides the next-generation interface for all devices that at one time communicated through the serial port, parallel port, or utilized a custom connector interface to the host computer system. This column introduces the basic architecture of the USB bus, provides some advanced information on the internal workings of USB communications and lists sources of information to provide greater detail for further USB study. USB basics The USB cable itself has a unique keyed interface to ensure proper connection between the host and device. The end of the USB cable that plugs into the host is referred to as Series-A plug and mates with the Series-A receptacle on the host. The end of the USB cable that plugs into the device is referred to as Series-B plug and mates with the Series-B receptacle on the USB device. It was later recognized that the Series-B plug and receptacle may be too large for some USB devices so the Mini-B plug and receptacle was introduced. Figure 1 depicts USB receptacle pinouts.
Figure 1. USB receptacle pinouts USB communications have provided many benefits to the PC and to embedded systems; however, it also has some drawbacks and limitations. Table 1 lists some of the dominant benefits and limitations of USB communications.
Table 1 USB 1.0 was released in January 1996. In September 1998, USB 1.1 was released which added an additional method of transferring data between the host and device. USB 1.0 and 1.1 supported two data transfer speeds; a low speed of 1.5 Mbps and a full speed of 12 Mbps. USB 2.0 was released in April 2000 and added a faster data transfer speed of 480 Mbps while retaining all the characteristics of the original USB 1.1. This introduction of the faster transfer speed allowed devices such as external hard drives, video transport, scanners, and the newer printers that require high data throughput to utilize USB communications. USB components include a root hub which is also referred to as the host and is the PC or primary embedded system; hubs which are bridges with one input and multiple outputs; and peripherals which can also referred to as devices. Figure 2 shows an example of multiple USB devices connected to a host.
Figure 2 USB utilizes a tiered star topology in which each device is connected to hubs which may be connected to other hubs or directly connected to the host which is the PC or primary embedded system. The host controls all communications on a USB bus and only one device at a time communicates with the host. This is referred to as a Äúspeak when spoken to Äù communications protocol. The USB hubs themselves are also USB devices. They communicate with the host the same as any of the devices attached to the USB link. Hubs that are USB 2.0 compatible contain more intelligence within the hub and provide additional data trafficking in order to provide assistance to the host and move the USB data more efficiently. An example of this is the ability of a USB 2.0 hub to buffer data from attached USB 1.1 devices that are transmitting at low or full speed and retransmit the data to a USB 2.0 host at a high speed. This buffering data is defined as the USB 2.0 hub acting as a transaction translator. This ability of the USB 2.0 hub to be a transaction translator allows any attached USB devices regardless of their data transmission speed to communicate with the host at high speed which frees bandwidth for the host for communications with other devices directly attached to it. USB 2.0 supports full backward compatibility to USB 1.1. The majority of USB 2.0 devices that communicate at the high data transfer speed of 480 Mbps are also able to communicate at the full data transfer speed of 12 Mbps which is supported by USB 1.1. As shown in Figure 1, if a USB 2.0 device is connected to a USB 1.1 hub the data transfer speed will be limited to 12 Mbps. The same is also true if a USB 2.0 device was directly connected to a USB 1.1 supported host. This flexibility for USB 2.0 devices to support multiple data transmission speeds is what allows USB 2.0 devices to operate with USB 1.1 based hubs or host. This is the basis for providing the backward compatibility of USB 2.0 to USB 1.1. USB communications Unlike the baud rate setting in RS232 communications, the transmission speed for USB communications is not a constant value. The transmission speed that data is transferred through the bus can be unique for each individual device. If you have a device communicating at low speed such as a mouse, a device communicating at full speed such as a thumb-drive and a device communicating at high speed such as a web camera all connected to a USB 2.0 bus, all three transmission speeds will be present on the bus. Because only one device communicates with the host at a time, the host communicates with each individual device at the transmission speed requested or supported by that particular device. When a USB device is first connected directly to a host or hub, the host will initially detect the presence of the USB device by a change in the voltage level on its signal lines. The host will then begin to request basic information from the device such as what communication speeds the device supports, the device's abilities, what transfer type the device will be utilizing, the bandwidth the device requires, what is the vendor ID, and product ID of the device along with other control information. This initialization process is referred to as enumeration. During enumeration the host will also assign a unique address to the device, reset the device, establish a communication path to the device and will load the appropriate drivers for the device to communicate with the application software. Types of USB data
Table 2
The multiple data transfer speeds in addition to the different transfer types available for efficiently moving data between the host and device is what allows the USB protocol to be such an incredibly versatile and adaptable communications platform. This is the strength of USB communications Äîwhich allows multiple devices ranging from simple data transfer requirements, such as mice and keyboards, to devices requiring complex and high bandwidth data transmission, such as video Äîto utilize the same USB bus. Detailed USB information Within each device or peripheral are what is referred to as endpoints. Endpoints are a uniquely addressable portion of a USB device that is used for communications between a host and the device and are utilized for the sourcing or receiving of data. There are 16 addressable endpoints numbered 0 to 15 available in a device. The endpoints address contains an address number and a direction number. The endpoint address references one of the 16 endpoint buffers or registers within the device. The endpoint number defines if the data is traveling to or from the host and is referenced from the host point of view. An IN endpoint describes data that is traveling from the device to the host. An OUT endpoint describes data that is traveling from the host to the device. Endpoint address 1 with a direction defined as IN and endpoint address 1 with a direction defined as OUT are two separate buffers or registers. This applies to endpoint addresses 1 through 15. Therefore a device could have 30 uniquely addressable endpoints. Endpoint 0 is configured as the control endpoint and is defined as both IN and OUT. All devices are required to have endpoint 0 as a control endpoint. Endpoint 0 is utilized during the enumeration process between the host and device. Each transaction on bus contains a device address and the endpoint address. Full-speed and high-speed devices can utilize the entire 30 additional endpoint address dependent upon their individual function, communication requirements, and data exchange requirements. Low-speed devices are limited to only two additional endpoints in addition to endpoint 0. These two additional endpoints can be configured as a combination of IN or OUT endpoints. The communication exchange between the host and a device that is initialized or set up during the enumeration process is referred to as a pipe. The pipe is a virtual connection between a device's endpoints and the device's controlling software or drivers that are located in the host. The pipe is a pathway for all data exchanged between the host and device. When a device is physically removed from the bus the virtual pipe is eliminated. USB software development These already developed standardized class drivers allow programmers to utilize an existing class driver that is similar in functional requirements to their particular device as a reference. Many times a class driver may be utilized directly or with minor modifications to meet the requirements of a particular device. If a custom USB device is being designed such as a data acquisition system, motor interface or an interface for a legacy system, it is likely that a representative class driver may not be available and a custom driver may have to be created. There are several websites that provide reference information for creating a custom device driver including the Windows 98 Drivers Developer's Kit (DDK) which includes example code for USB drivers. There are also several companies that provide wizard based driver development kits that can greatly simplify the creation of a custom USB driver. USB do's and don'ts
Looking forward Wireless USB defines requirements to allow wireless USB communications based upon the USB protocol. Wireless USB utilizes Ultra-Wideband radio technology and allows for data transfer of up to 480 Mbps within distances of about 3 m and data transfer of up to 110 Mbps within distances of about 10 m. It allows for up to 127 devices to be wirelessly connected, eliminates the need for physical hubs, and provides data encryption to ensure security of the data being transferred between the host and device. The wireless USB specification was released in May 2005 and it is expected that the number of devices that have wireless USB capability will dramatically increase over the next several years. For more information The USB organization's website, www.usb.org, contains the USB specifications, white papers, USB forums and software for USB compliance testing, all for free. This resource is invaluable for any USB hardware development, software development or standard PC/104 board level incorporation into a system design. Some key summary information is shown in Tables 3 and 4. Additional information, references, and web links about USB communications is available at www.jacyltechnology.com.
Table 3
Table 4 . . . . . Joel Huebner is president of Jacyl Technology, Inc. He holds two degrees with honors from Purdue University in Electrical Engineering and Computer Engineering. Joel has more than 15 years’ experience as an electrical design engineer in the military aerospace industry and in the custom electronic design R&D industry. For further information, contact Joel at: Jacyl Technology, Inc. |
|









