USB device Charging de-mystified.

Warning : Super technical, geeky post ahead!

I was watching Episode 52 of Systm, and Patrick was trying to hack/mod an iPod/iPhone connector to allow it to charge using various sources other than the USB port of your computer. He also wanted to get the line out audio from the connector to connect to any Audio System.

Aside : Systm has just revived into the awesome show it started as. Patrick did one on distillation, two on iPod/iPhone hacking/modding and possibly more coming up. Do watch it if you are interested in this type of stuff.

So, Patrick was able to power up and charge the iPod (a 5th Gen iPod, I believe) by connecting just the VDC and GND pins of the connector to a 5V supply (possibly a VCC pin on a USB cable) and GND respectively, the same did not work on the iPhone. Why??

USB

For this we need to look at USB’s electrical specs, especially the power sinking and supplying parts.

There are 3 classes of USB hosts and 3 classes of USB devices/functions defined in the specs. Hosts are devices like PCs, USB hubs, etc, which can connect to multiple devices and act as the “Master” in most transactions. Devices are “Slaves” in a USB connection. All cameras, phones, thumb drives, etc are considered as devices.

The power source and sink requirements of different device classes can be simplified with the introduction of the concept of a unit load. A unit load is defined to be 100 mA. A device may be either low-power at one unit load (100mA) or high-power, consuming up to five unit loads (500mA). All devices default to low-power. The transition to high-power is under software control. It is the responsibility of software to ensure adequate power is available before allowing devices to consume high-power.

So the 3 USB Host Classes are..

Root port hubs: These are directly attached to the USB Host Controller. Systems that obtain operating power externally, either AC or DC, must supply at least five unit loads to each port

Bus-powered hubs: Draw all of their power for any internal functions and downstream facing ports from VBUS on the hub’s upstream facing port. Bus-powered hubs may only draw up to one unit load upon power-up and five unit loads after configuration.

Self-powered hubs: Power for the internal functions and downstream facing ports does not come from VBUS. However, the USB interface of the hub may draw up to one unit load from VBUS on its upstream facing port to allow the interface to function when the remainder of the hub is powered down.

And the 3 USB Device Classes are..

Low-power bus-powered functions: All power to these devices comes from VBUS. They may draw no more than one unit load at any time.

High-power bus-powered functions: All power to these devices comes from VBUS. They must draw no more than one unit load upon power-up and may draw up to five unit loads after being configured.

Self-powered functions: May draw up to one unit load from VBUS to allow the USB interface to function when the remainder of the function is powered down. All other power comes from an external (to the USB) source.

So basically, there are hosts that can supply up to 500mA and devices which can sync up to 500mA. However, all hosts and devices will default to supplying and sinking (respectively) 100mA. And to switch to the high power mode, the device software (USB Stack) has to request the host to start providing 500mA. This request has to be done through the Default Configuration Pipe of the connection, using “SetConfiguration” USB Device Request. In this configuration, the value of maximum current, in mA, can be set. However, these requests go over the D+ and D- USB pins, since all data goes over those pins. And so, these pins have to be connected to allow the Device to request 500mA.

Now that explains why many times our devices just can’t charge over those USB Wall-Chargers, because they request and expect 500mA charging configuration, but since the USB Wall-Chargers are not “hosts”, and don’t have any micro-Controller or any USB Stack running, they cannot reply to these requests. For that matter, most of them, just like Patrick’s charger, don’t even have D+ and D- pins at all. And since the device can’t get 500mA, it can decide it can’t charge and stops.

So now, finally the question is, why can an iPod charge on 100mA (I have tried it using a USB Wall-Charger, it works), but the iPhone can’t.

The answer is simple, iPhone has a GSM radio for the cellular telecommunications. And GSM radios draw huge amounts of currents when they broadcast the data in bursts. So during these bursts, they may sink in the range of 70mA. So if you have a flat battery, and a charger providing only 100mA, and a radio sinking 70mA, only ~30mA is left for the other components including the touch screen and the backlight. Running on low current might cause many issues, especially on displays and touch sensors. So Apple must have decided to only charge the iPhone, (and in the case of low battery, allow it to boot-up), if 500mA configuration has been successful.

There you go, some interworking of USB and Charging on devices.. Drop me an email, or comment on this post, if you have any questions or queries about these things, and I will try my best to answer them..

Advertisements

16 comments so far

  1. Craig on

    Its funny – I see a gazillion posts about problems with USB wall chargers and Gen 2 IPOD Shuffle devices – which I am also having. Your discussion around 500ma devices trying to negotiate current with the el-cheapo wall chargets, failing, and stopping – explains exactly what is likely going on. Touche!

  2. NTT on

    @Craig.

    Haha.. Yup.. We have all seen this before. It was great to dig up the specs and figure out what is going on.. Glad to be of help.

  3. Harrison on

    Hi, there,

    There is a special way you can charge apple devides without using “SetConfiguration” USB Device Request: give both D+ and D- 2.0V +-2% voltage using resistor deviders.

    • Alistair on

      @Harrison. True only for Apple stuff. Apple doesn’t follow the USB specs and has its own proprietary way of signalling what current draw it allows. Read this for some of the story http://www.ladyada.net/make/mintyboost/icharge.html.

      The USB specs state that a wall charger should put a termination resistance of 200 ohms between the D+ and D- (a short works too). This informs the portable device that it can draw more than 500mA, in fact up to 1800mA.

      The result of Apple’s dive into proprietary behavior is a confusion of USB charging devices. Those that claim apple compatibility invariably don’t provide the advertised current to USB compliant devices.

      And now I read further down the Chinese USB charging specs of which I’ll have to dig into as I’m sure they are also part of the problem.

  4. NTT on

    @Harrison.

    Hmm.. That’s interesting. So will this work on iPhone as well? Because for the iPods you just need to connect the VDC and GND, as far as I know. Setting D+ and D- to 2.0V will also enable the iPhone to move up to 500mA?

  5. Pascal on

    Finally finally finally……
    Someone can explain this!!!!

    I guess this also exmplains why USB devices connected to a computer where you don’t have administrator rights, will not charge, or charge very slowly your devices. It probably can’t request the 500mA since you have no rihts!

  6. NTT on

    @Pascal.

    Yup. But there’s more to it than I thought when I posted this..

    Check this out.. It get more interesting..

    http://tzywen.com/modules.php?name=News&file=article&sid=683&mode=thread&order=0&thold=0

  7. Arun on

    Ok…

    I’ll try to answer this question.

    USB devices can charge in two ways:

    1. From a USB host/hub
    2. From a USB wall-charger

    The USB connector u connect to the device will help the Device to understand what type of charging is going to happen.

    1) If the D+ and D- lines are fine (not shorted/pulled up high/tristated) the USB device expects that it is connected to a PC. It then expects the set Configuration command to start drawing current to begin charging. The USB standard allows a device to draw 100mA without getting the set configuration command. Some devices choose to use this for charging other’s don’t. This is a matter of policy. Most of the phones dont’ charge unless it gets a set configuration command. Most of the music players choose to charge at 100 mA if the set configuration command is not received. Once the set configuration command is received it can draw upto 500 mA.

    2) If the device is connected to a USB wall charger it expects that

    a) D+ and D- lines are either pulled up high or b) They should be shorted

    Some devices support only (a) some support both (a) and (b)

    So depending upon the support, if the D+ and D- lines are pulled up high or shorted, the device detects the USB plug in as a charger plugin. Then it can draw far more than 500mA. Usually these devices draw upto 800 – 1000mA (depends on the charger spec). As a matter of fact the Chinese charging specification allows upto 1800mA and the USB charging specification allows upto 1700mA for a wall charger. But devices don’t choose to use such a high charging current because of heating troubles…

    Thaz the story… If u want more info, just ping me.

  8. NTT on

    @Arun.

    OK. That’s really really interesting.. So is this shorting or pulling up high f D+ and D- lines a part of the USB standard?? Or is it something that ppl just decided to use??

    I have worked with the Chinese Charging Standards before, so I am aware of the 1800mA limit.. But I didn’t expect that devices could start pulling that much current just by detecting the D+ and D-.. Sounds like a receipe for disaster.

  9. Malaz on

    Just to comment. I just purchased a Treo Pro and it wouldn’t charge using my 500mA car USB adapter. It charges fine using the AC wall USB adapter that came with it and it charges fine using a laptop’s USB adapter. After reading this article and others on the internet, the Treo Pro USB charger that is sold by Palm has the spec’s of 1000mA output, which may explain why the generic ones I bought didn’t work, even though they worked with the iPhone and the mp3 player we have in our family.

  10. NTT on

    @Malaz

    Thanks for your comment. I have realized that this USB charging is more complicated that I initially thought.

    Do read the other comments on the post. They have some interesting content!!

  11. Wayne on

    Found this page whilst researching USB charging. I have a Samsung Galaxy TAB (7″). I believe that in full charge mode, it draws somewhere in the order of 2 Amps. The Samsung car and AC chargers both state 2.1Amps. I have purchased a dual USB charger from the UK (ebay) that offers 1 outlet (labeled s) for the TAB and 1 for a phone (labeled i), perhaps even an iPhone. The S will charge the TAB and the data terminals are indeed shorted (~1.5 Ohms), while the i outlet will not charge it and the data pins are not shorted. I am finding though that 2 are not enough.

    So, I am on the lookout for a multi (4 or more) port charging hub that I can connect to my car or home outlet. I figure I will want to charge things like my TAB, GS2, 2nd mobile, BT headset. Maybe more. It will therefore will need to supply at least 3amps to cover all this. I think having a unit that either has some shorted and some open data pins, or switches to select same might be the go. The closest to this I can find is an mbeat 13 port (WOOHOO) hub with switches. One wonders if these switches could be rigged to do the data pin shorting rather than the power switching.

    On a side note. I also read that some chargers, in high current mode, use other methods (some mentioned here), such as pulling data high, or inserting a resistor between the data pins rather than a direct short. Yet another variable to consider when creating a ‘universal’ charger. I guess I just have to deal with the equipment that I have at the time.

  12. NTT on

    Yup. As more and more manufacturers start making phones with only USB, they will have more and more random ways of dealing with high amperage charging.. Only if there was a standard for that..

    Ladyada has done lots of analysis of this..

    http://www.adafruit.com/blog/2010/08/03/the-mysteries-of-apple-device-charging-video/

  13. The attacker is then marked with the antibody so that the body knows it is threatening
    and it can be killed.

  14. Alexandria on

    Managing the system’s resources is 1 of its responsibilities.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: