USB charger detection

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB charger detection

4,686 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mhjerde on Mon Mar 12 04:49:05 MST 2012
Hi
I'm using and lpc1343. I would like to detect if I'm connected to a USB charger. USB chargers have the D+ and D- lines shorted. AFAIK I don't have direct access to the USB pins so I'm not sure how I could check for this condition?

Any ideas?
0 Kudos
Reply
4 Replies

3,637 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mhjerde on Fri Mar 16 03:30:09 MST 2012
Thanks Rob

Yes, looks like I need some additional hardware. I don't currently have any spare ADC pins. Maybe I can work out some clever scheme to have one ADC do double duty.

Morten
0 Kudos
Reply

3,637 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Tue Mar 13 10:52:03 MST 2012
You will need to connect something besides the USB pins to detect what you are connected to.
You could use some custom electronics but you might be OK with two pins to the AD converter.

I guess you are using the USB also - in that case you will have a 1.5 k resistor to D+.

Now you can measure the voltages on D+ and D- when connected:


[LIST]
[*]Both lines 3.3V means a dedicated charger (D- and D+ connected)
[*]D- low (< 0.3V) and D+ high (> 2.5V) means you are connected to a 'standard' CDP.
[/LIST]
Detecting the charger port in this way will not show you the difference between a standard port and the Sony port since Sony's resistors will provide 3.3V on both D+/D- also but who cares ...


But there is more ...
Have a look at the USB charging spec that you referred to (I looked at v1.2), there actually are almost complete schematics with algorithms described on how to detect what kind of (charger) port you are connected to.



- I stick with my original remark : "There is no standard (or there are too many)" :eek: They made this too complicated. I would just stay with the simple logical level detection above.
I would also stick to a low charge current (0.5A max) - USB cables and connectors were never made for such high current. I can bake an omelet on the USB connector of my iPad (a very small one I must admit) - this thing becomes too hot for my liking.


Regards,

[INDENT]Rob

[/INDENT]
0 Kudos
Reply

3,637 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mhjerde on Mon Mar 12 23:50:11 MST 2012
Yes, the device is battery powered and it has a USB port. I plan to charge the battery through the USB port.

There is actually a USB Battery Charging Specification 1.1 and it allows 1.5A current draw when connected to a Dedicated Charging Port (DCP) and 500mA when connected to a Charging Downstream Port (CDP). A DCP is typically a wall wart and a CDP is typically a computer. As far as I understand, a DCP is identified by shorted D+ and D-lines, a CDP id identified by D+ and D- being pulled to ground through 15k resistors.

When the USB cable is attached I want to know if I can draw 1.5A, 500mA, 100mA, or nothing at all from the device on the other end. Wallwart USB chargers won't have a MCU, they have resistors connected to the data lines, and that appears to be how you identify them.

If I could control the USB pins I could probably pull one high and check the status of the other one to look for a short. But I can't see a way to do that with the lpc1343.

There is also a couple of non-standard arrangements from Apple and Sony, I guess they started doing it this way before the specification was written, see attachment:

[IMG]http://i.stack.imgur.com/gWODO.jpg[/IMG]
0 Kudos
Reply

3,637 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Mon Mar 12 11:47:59 MST 2012
Unfortunately there is no standard (or there are too many) in how, and if, the USB lines are connected.
At least Apple behaves differently than some of the other USBchargers I have.

Why would you want to detect if you are connected to a charger?
Do you use USB in your device? Then you can just use the VBUS pin to detect that a voltage is present. If you are able to attach to the host then you are connected to a host and you should present your power requirements and keep to them, if not then it is most likely that you are connected to a charger.

I am not compensating for user errors in my device. I even have a few chargers with a USB plus that provide 12V 1.2A. I think quite some USB devices will transform into short-term smoke generators when I connect them to these chargers :eek:

Rob
0 Kudos
Reply