Type A USB Connector | Type B USB Connector |
It is interesting to find type A to type A cables wired straight through and an array of USB gender changers in some computer stores. This is in contradiction of the USB specification. The only type A plug to type A plug devices are bridges which are used to connect two computers together. Other prohibited cables are USB extensions which has a plug on one end (either type A or type B) and a socket on the other. These cables violate the cable length requirements of USB.
USB 2.0 included errata which introduces mini-usb B connectors. The details on these connectors can be found in Mini-B Connector Engineering Change Notice. The reasoning behind the mini connectors came from the range of miniature electronic devices such as mobile phones and organisers. The current type B connector is too large to be easily integrated into these devices.
Just recently released has been the On-The-Go specification which adds peer-to-peer functionality to USB. This introduces USB hosts into mobile phone and electronic organisers, and thus has included a specification for mini-A plugs, mini-A receptacles, and mini-AB receptacles. Moreover, even smaller micro-USB plugs and receptacles are introduced.
Pin Number | Cable Colour | Function |
---|---|---|
1 | Red | VBUS (5 volts) |
2 | White | D- |
3 | Green | D+ |
4 | Black | Ground |
PCB designers will want to reference chapter 6 for standard foot prints and pinouts.
As we have discussed, USB uses a differential transmission pair for data. This is encoded using NRZI and is bit stuffed to ensure adequate transitions in the data stream. On low and full speed devices, a differential ‘1’ is transmitted by pulling D+ over 2.8 V with a 15 kΩ resistor pulled to ground and D- under 0.3 V with a 1.5 kΩ resistor pulled to 3.6 V. A differential ‘0’ on the other hand is a D- greater than 2.8 V and a D+ less than 0.3 V with the same appropriate pull down/up resistors.
The receiver defines a differential ‘1’ as D+ 200 mV greater than D- and a differential ‘0’ as D+ 200 mV less than D-. The polarity of the signal is inverted depending on the speed of the bus. Therefore the terms ‘J’ and ‘K’ states are used in signifying the logic levels. In low speed a ‘J’ state is a differential 0. In full/high speed a ‘J’ state is a differential 1.
USB transceivers will have both differential and single ended outputs. Certain bus states are indicated by single ended signals on D+, D- or both. For example a single ended zero or SE0 can be used to signify a device reset if held for more than 10 ms. A SE0 is generated by holding both D- and D+ low (< 0.3 V). Single ended and differential outputs are important to note if you are using a transceiver and FPGA as your USB device. You cannot get away with sampling just the differential output.
The low speed / full speed bus has a characteristic impedance of 90 Ω +/- 15%. It is therefore important to observe the datasheet when selecting impedance matching series resistors for D+ and D-. Any good datasheet should specify these values and tolerances.
High Speed (480 Mbits/s) mode uses a 17.78 mA constant current for signalling to reduce noise.
For example Philips Semiconductor has a SoftConnectTM technology. When first connected to the bus, this allows the microcontroller to initialise the USB function device before it enables the pull up speed identification resistor, indicating a device is attached to the bus. If the pull up resistor was connected to Vbus, then this would indicate a device has been connected to the bus as soon as the plug is inserted. The host may then attempt to reset the device and ask for a descriptor when the microprocessor hasn’t even started to initialise the usb function device.
Other vendors such as Cypress Semiconductor also use a programmable resistor for Re-NumerationTM purposes in their EzUSB devices where the one device can be enumerated for one function such as In field programming then be disconnected from the bus under firmware control, and enumerate as another different device, all without the user lifting an eyelid. Many of the EzUSB devices do not have any Flash or OTP ROM to store code. They are bootstraped at connection.
Figure 2: Full Speed Device with pull up resistor connected to D+
Figure 3: Low Speed Device with pull up resistor connected to D-
You will notice we have not included speed identification for High Speed mode. High speed devices will start by connecting as a full speed device (1.5 kΩ to 3.3 V). Once it has been attached, it will do a high speed chirp during reset and establish a high speed connection if the hub supports it. If the device operates in high speed mode, then the pull up resistor is removed to balance the line.
A USB 2.0 compliant device is not required to support high-speed mode. This allows cheaper devices to be produced if the speed isn’t critical. This is also the case for a low speed USB 1.1 devices which is not required to support full speed.
However a high speed device must not support low speed mode. It should only support full speed mode needed to connect first, then high speed mode if successfully negotiated later. A USB 2.0 compliant downstream facing device (Hub or Host) must support all three modes, high speed, full speed and low speed.
A USB device specifies its power consumption expressed in 2 mA units in the configuration descriptor which we will examine in detail later. A device cannot increase its power consumption, greater than what it specifies during enumeration, even if it looses external power. There are three classes of USB functions,
High power bus powered functions will draw all its power from the bus and cannot draw more than one unit load until it has been configured, after which it can then drain 5 unit loads (500 mA max) provided it asked for this in its descriptor. High power bus functions must be able to be detected and enumerated at a minimum 4.40 V. When operating at a full unit load, a minimum VBUS of 4.75 V is specified with a maximum of 5.25 V. Once again, these measurements are taken at the upstream plug.
Self power functions may draw up to 1 unit load from the bus and derive the rest of it’s power from an external source. Should this external source fail, it must have provisions in place to draw no more than 1 unit load from the bus. Self powered functions are easier to design to specification as there is not so much of an issue with power consumption. The 1 unit bus powered load allows the detection and enumeration of devices without mains/secondary power applied.
No USB device, whether bus powered or self powered can drive the VBUS on its upstream facing port. If VBUS is lost, the device has a lengthy 10 seconds to remove power from the D+/D- pull-up resistors used for speed identification.
Other VBUS considerations are the Inrush current which must be limited. This is outlined in the USB specification paragraph 7.2.4.1 and is commonly overlooked. Inrush current is contributed to the amount of capacitance on your device between VBUS and ground. The spec therefore specifies that the maximum decoupling capacitance you can have on your device is 10 µF. When you disconnect the device after current is flowing through the inductive USB cable, a large flyback voltage can occur on the open end of the cable. To prevent this, a 1 µF minimum VBUS decoupling capacitance is specified.
For the typical bus powered device, it can not drain any more than 500 mA which is not unreasonable. So what is the complication you ask? Perhaps Suspend Mode?
Another consideration for many devices is the 3.3 V regulator. Many of the USB devices run on 3.3 V. The PDIUSBD11 is one such example. Linear regulators are typically quite inefficient with average quiescent currents in the order of 600 µA, therefore more efficient and thus expensive regulators are called for. In the majority of cases, you must also slow down or stop clocks on microcontrollers to fall within the 500 µA limit.
Many developers ask in the USB Implementor's Forum, what are the complications of exceeding this limit? It is understood, that most hosts and hubs don’t have the ability to detect such an overload of this magnitude and thus if you drain maybe 5 mA or even 10 mA you should still be fine, bearing in mind that at the end of the day, your device violates the USB specification. However in normal operation, if you try to exceed the 100 mA or your designated permissible load, then expect the hub or host to detect this and disconnect your device, in the interest of the integrity of the bus.
Of course these design issues can be avoided if you choose to design a self powered device. Suspend currents may not be a great concern for desktop computers but with the introduction of the On-The-Go Specification we will start seeing USB hosts built into mobile phones and mobile organisers. The power consumption pulled from these devices will adversely effect the operating life of the battery.
USB has a start of frame packet or keep alive sent periodically on the bus. This prevents an idle bus from entering suspend mode in the absence of data.
The device will resume operation when it receives any non-idle signalling. If a device has remote wakeup enabled then it may signal to the host to resume from suspend.