USB: Advantages, Disadvantages and Architecture (Part 1/6)
USB i.e. Universal Serial Bus is an interfacing standard through which two devices can communicate with each other. For example, devices like digital cameras, flash drives, mouse, tablets, etc communicate with computer via USB. It was first introduced in mid-1990s with the aim of simplifying the communication between devices. Various companies like Compaq, DEC, IBM, Intel, Microsoft, Nortel and NEC contributed to its development. However, presently it is developed by USB Implementers Forum.
The USB interfacing consists of two main devices host and peripheral. The most common example is Computer (Host) and Flash drive (Peripheral). The host manages the communication. Multiple numbers of peripherals can be connected through single host at the same time.
The initial version of USB was meant for slower devices. As the demand for high speed communication increased, new version were developed and released. USB currently supports 4 different modes in terms of speed :
MODE | PERFORMANCE | APPLICATION |
---|---|---|
Low speed | 1.5Mbit/s | Keyboard, Mouse, Game, Peripherals |
Full Speed | 12Mbit/s | Scanner,Printer, Digital Audio |
High speed | 480Mbit/s | Broadband, Mass Storage, imaging |
Super Speed | 5Gbit/s | Real time streaming, Portable storage devices |
Transfer speed comparison for different modes :
Data size | Time Taken | ||
---|---|---|---|
USB 1.0 | USB 2.0 | USB 3.0 | |
Image/MP3(4MB) | 5.3 sec | 0.1 sec | 0.01 sec |
Flash drive (1 GB ) | 22 Min | 33 sec | 3.3 sec |
HD-Movies (16 GB ) | 9.3 Hr | 13.9 min | 70 sec |
Advantages of USB
• Ease of Use : USB was designed considering the easy interface for the users in the following ways – :
Single Interface for multiple devices : The versatile nature of USB removes the complexity of different connector type and hardware requirements for each peripheral.
Auto configuration : The windows automatically loads driver whenever a USB device is plugged in for first time. Once the driver is installed, the windows automatically configure the device whenever it is plugged in.
Easy to expand : Generally a normal PC contains 3-4 USB ports. In case if more ports are required, USB hubs can be used to add external ports.
Compact Size : USB sockets are small in size as compared to RS232 or parallel ports.
No external power needed : The host supplies the power to the peripheral which is required for its working.
• Reliability : The USB protocol helps in detecting errors and notifying the transmitter to retransmit the data. The hardware, drivers and software also ensure an error free communication.
• Low cost : With its versatile nature and increasing demand, it has become very inexpensive to manufacture USB supported devices. The components, connector, and cable are easily available at low cost.
Besides so many advantages there are some limitations which make USB ineffective for some task.
Limitations
• Speed : With introduction of USB3.0, it is possible to achieve 5Gbits/sec. But it is still lower than Gigabit Ethernet. The Fire Wire 800(IEEE-1394b) is also a competitor for USB.
• Peer to Peer Communication : As per the USB standard, the communication takes place between the host and peripheral. Two hosts cannot communicate directly to each other. Same is the case for peripheral. On the other hand, interfaces like Fire Wire supports peripheral to peripheral communication. For overcoming the limitation, the USB introduced the concept of OTG (On The Go). The OTG device normally functions as peripheral, but it can also function as host with some limited capability when required.
• Distance : According to USB standards, the connecting cable can be as long as 5 meters beyond which USB hubs can be used for expanding the connectivity.
• Broadcasting : Universal Serial Bus does not provide the broadcasting feature, only individual messages can be communicated between host and peripheral.
USB System Architecture
The USB is controlled by host; there can be multiple peripherals but only one host per bus. The host can be taken as master and peripheral as slaves, whereby the former is responsible for managing the connection, transactions, and scheduling bandwidth. The USB system uses tiered start topology. It consists of 7 bit addressing; this means it can support up to 127 devices at once.
The connection cable consists of 4 shielded wires out of which two are for power (+5V and Ground) and the remaining are twisted pair differential data signals which use NRZI (Non Return to Zero invert) scheme to transmit data. In order to synchronize the host and receiver clocks, Sync field is used.
Endpoints
In USB, the information flows between host and device. The endpoints are source or sink of information in a communication channel. These are blocks of memory in a controller chip containing buffers for transmission and reception.
Two endpoints can have same endpoint number but different directions. When the device is plugged in, only the default endpoint 0 is accessible. This endpoint receives control and status request from host during enumeration process. The other endpoints are declared as per requirement after configuration of the device.
Pipes
A pipe is a logical data connection between host controller’s software and device endpoint. The information is exchanged through this pipe. It is created during enumeration process. When the device is unplugged, unneeded pipes are removed.
There are two types of pipes
• Message pipes : These are bi-directional pipes which follow defined packet format. They are controlled by host and only support control transfer.
• Stream pipes : These are unidirectional pipes which don’t follow any specific data format. They can be controlled by host or device (peripheral) and support bulk, isochronous and interrupt types of transfer.
The Default Control pipe is a special type of message pipe which is bidirectional and supports control transfer type. It uses endpoint 0-IN and endpoint 0-OUT. This pipe can be accessed when device is plugged in.
Transfer Types
There are four types of transfer modes or types which can be for communication :
• Control Transfer: This transfer type is used to transfer the control information while identifying and configuring the device.
• Bulk Transfer: In this transfer type, large amount of data is moved and time is not a critical factor here. It can be used as fillers.
• Interrupt Transfer: This type of transfer is for small data transmission with immediate attention.
Transaction
A single transaction contains transmission of up to three packets. These packets are :
• Token Packet: This packet is always sent by Host.
• Data Packet: This packet can be send by Host or Device.
• Handshake Packet: This packet provides success/failure information for the data packet received. If Host transmits the data packet, the device sends the handshake packet and vice versa.
Handshaking
Handshaking is mechanism to check the success/failure of a request or to check the delivery of a packet. It is done to avoid loss of packets and to ensure successful transmission. Terms related to handshaking.
USB Device States
A USB device has several possible states described as follows – :
• Attached State : This state occurs when the device is attached to the Host.
• Powered State : After the device is attached, the Host provides power to the device if it does not have its own power supply. The device should not draw more than 100 mA in this state.
• Default State : This state occurs when the device is reset and has not been assigned unique address. In this state the device uses default control pipe for communication and default address 0.
• Addressed State : The USB device enters this state after it gets unique address which is used for future communications.
• Configured : When the Host obtains required information from the device, it loads the appropriate driver for the device. The host configures the device by selecting a configuration. The device is now ready to do the operations it was meant for.
Enumeration
Enumerating is making peripheral device recognizable at host end. For making enumeration successful some steps have to be followed.
• Writing firmware code for the controller chip: This firmware will be responsible for sending device description, decoding the packets and responding to the host.
After successful enumeration, the device will be known to the host and an application will be needed to make use of the USB communication. Application uses Operating System’s API (for e.g. Windows API). The application can transmit or receive data by using Buffers.
Device Class
Every USB device has a device class defining the functionality and purpose of that device. The host loads the suitable driver according to the device class. The most common device classes are :
• Human Interface Device (HID): This class is generally used by devices which use Interrupt Transfer for data communication. Examples are keyboard, mouse or joystick.
• Mass Storage: Devices which need to transfer large amount of data through Bulk Transfer implements this class. Examples are USB flash drive, memory card reader or external hard disk.
• Audio: This class is implemented by audio devices like microphone, speaker, external sound card etc. The device uses Isochronous Transfer for data communication.
• USB Hub: It is used by USB hubs to expand the number of ports.
• Image: Used by device like webcam or scanner.
• Printer: Used by Laser printer, inkjet printer or CNC machines.
The next article covers the protocol of USB defining the various types of packet fields. Stay tuned for the upcoming details of USB in the series.
Filed Under: Articles
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.