Saturday, August 8, 2009

How to Design a Circuit with USB Host and Device Function


Before designing a circuit with usb host and device function, you may need to know your CPU's features about that if it supports OTG or two channels came with one channel is for Host controller and the other is for usb device (slave). In this article I assume that I am at second situation and also don't use a standard A type receptacle to get more space on pcba. So your device will have two receptacles(female) connectors. For which type we should use. Please check "Universal Serial Bus". But somehow it hard to completely understand especially on the eletrical features about host and device side.

So let's first see the most USB devices (slave) they come with mini-B receptacle(5 pins). Let's check their schematic mostly like below,


Figure 1. USB Mini-B receptacle

The pin 4 is marked as NC but it can be equal to as "ID" pin, any device can be served as USB slave device when this pin is pull down to "GND". And also many chargers they use Mini-B plug insertting this Mini-B receptacle to do bettary charge using pin 1.

Let's also see the most USB host devices they are designed with Standard A receptacle(4 pins) as following,
Figure 2. Standard A Type receptacle

So there's no ID pin on the standard A Type receptacle, this design is also popularly used at laptop or PC. This means any cable coming with standard A plug in one side inserts standard A Type receptacle will get VBUS +5V power from host source to the other end of cable. For example, see following cable;


Figure 3. A cable Mini-B/M to Standard A/M

This means that there's no connection(floating) from pin4 on Mini-B plug to Standard A plug inside of this cable.

How does OTG work
The USB On-The-Go standard introduces a new plug receptacle called micro-AB. It can accept either a micro-A plug or a micro-B plug. Micro-A Adapters allow for connection to standard-A plug type USB cables, as used on standard USB 2.0 Devices.
The OTG cable has a micro-A plug on one side, and a micro-B plug on the other (it cannot have two plugs of the same type). OTG adds a fifth pin to the standard USB connector, called the ID-pin; the micro-A plug has the ID pin grounded, while the ID in the micro-B plug is floating. The device that has a micro-A plugged in becomes an OTG A-device, and the one that has micro-B plugged becomes a B-device (see OTG). The type of the plug inserted is detected by the state of the pin ID .
Can USB OTG devices go backward compliant with USB2.0? Yes!

So let's see an example of Micro-AB receptacle circuit which is based on OTG design below;

Figure 4. Example for OTG design

Using a P-MOSFET to be as switch +5V for open and close operation. So if a micro-A plug has the ID pin grounded connected to the Micro-AB receptacle will let P-MOSFET turned on and +5V will go to VBUS; See as following,


Figure 5. An OTG A-device

Contrary to above, if a micro-B plug has ID pin floating, the P-MOSFET will turn off; so the output of P-MOSFET will have no voltage. But the net of VBUS will have +5V around from external host inserted. Also see as following,


Figure 6. An OTG B-device

If some chargers they use a Micro-B plug cable and try to charge an OTG B-device, it won't damage that device; because ID pin is floating inside of that cable. The operation is illustrated in figure 7.


Figure 7. External Power is Blocked

If A device with CPU doesn't support OTG but using two physical D-/D+ channels, 1 USB1.1 host controller and 1 USB 2.0 device. Thanks to OTG's backward compatibilty, we can use figure 1 for USB2.0 device design and use figure 6 for USB1.1 host design.

Currently varied adapters were produced for OTG applications;


Figure 8. Adapters

Designing this USB host or On-The-Go hosting applications, need to add one current limitation 5V at 500mA DC/DC Converter which fulfills to USB standard specifications. It's in front of switch.

Durability is the one of most important property, the Micro-USB receptacle are designed to allow up to 10,000 cycles of insertion and removal between the receptacle and plug, compared to 500 for the standard USB and Mini-USB receptacle.

No comments:

Post a Comment