Any chance to get 500mA from USB?

Status
Not open for further replies.

THT

Member
A normal USB port supplies 100mA @5V but I need more. Most ports happily give 500mA but to do it right you have to inform the USB host first. My device (a RFM12B Wireless to Ethernet Bridge) should be able to operate from the following power sources:

* USB when connected to a computer (mostly for debug and firmware uploading)
* USB when connected to USB power supply (for production)
* External DC jack (for production, may be removed in favor of an USB power supply)
* Internal LiPo battery

The internal LiPo battery is charged using a MAX1555 which takes 90mA from USB or 280mA from the DC jack. There is also a cap (0.22F, 3.6V) which powers the RTC for a few days or so. The LiPo is completely optional so I do need the additional cap.

Code:
My current power budget:
Teensy3 + Wiz820io + RFM12B: 0.8W  (3.3V)
Supercap charging (max):     0.25W (3.3V)
LiPo Charging (max):         0.3W  (5V)

So about 1.5W should be enough to power my device which is still below (500mA*5V=2.5W) an USB port will provide. I've chosen an external 3.3V regulator which is able to provide the required 3.3V current.

Is there any chance to modify the USB chip on the Teensy to request 500mA from the host?

If I do understand it correctly USB chargers will always supply 500mA and don't listen to the USB device. As many of these USB chargers supply much more than 500mA it may even be possible to connect these devices to the MAX1555 DC input. But how is it possible to detect such chargers?

many thanks,
Thomas
 
Is there any chance to modify the USB chip on the Teensy to request 500mA from the host?

Yes. You'll need to edit the USB code. Search for "bMaxPower". Look in hardware/teensy/cores. It's in different files for Teensy 2.0 vs 3.0, but the code is basically the same. The number is half the current reported. The default is 50 (for 100 mA). Just edit the code to 250, and you'll be informing the USB host you need 500 mA.

You can read the "usb_configuration" variable to tell if the USB host configured your device. If 500 mA is not available, that variable will never get set to a non-zero value.

While using bMaxPower technically conforms to the USB specs, as a practical matter, the USB host doesn't actually do anything to physically provide more power. You're still connected to the exact same power, regardless of the number you use for bMaxPower. In practice, all this does it allow the host to NOT configure your device if it knows the USB port you're using can't provide enough current. You don't magically get more power. You only get an error message presented to the user if the power isn't available, but an error message is far better than the user believing your product is faulty. For a custom project only you will use, there's probably little reason to bother with bMaxPower.


If I do understand it correctly USB chargers will always supply 500mA and don't listen to the USB device. As many of these USB chargers supply much more than 500mA it may even be possible to connect these devices to the MAX1555 DC input. But how is it possible to detect such chargers?

My (limited) understanding is newer chargers connect resistors to the USB data pins, creating a weakly driven voltage that indicates how much current you can draw. Older chargers connect a pulse generator to the data pins, to try tricking the device into believing a PC was connected and sending Start-of-Frame tokens, but no actual data.

Teensy 3.0 has a peripheral on the USB port which can detect those voltages from the newer charging standard. I have not used it yet, so I have no experience to help you. The best I can do is direct you to the reference manual. The charger detection is chapter 41, starting on page 925.

http://www.pjrc.com/teensy/K20P64M50SF0RM.pdf
 
Last edited:
Chapter 41 is an interesting read but is it worth the trouble? Looks like I'm trying to do more than needed and I should go back a step or two.

As I only connect to a PC for debugging purposes I'll most likely just ignore this bMaxPower and always use what I need (~300mA) . If this fails I know where the problem is.

When there is a dedicated charger connected I could feed power in the MAX1555 DC input but I'll leave this to version 2.0 or so. Maybe I'll even skip the whole LiPo part and go for a LTC4410/LTC4053 combination in a later design which looks like a much better fit.

Thank you Paul for your fast and informative response.
 
My (limited) understanding is newer chargers connect resistors to the USB data pins, creating a weakly driven voltage that indicates how much current you can draw. Older chargers connect a pulse generator to the data pins, to try tricking the device into believing a PC was connected and sending Start-of-Frame tokens, but no actual data.

Teensy 3.0 has a peripheral on the USB port which can detect those voltages from the newer charging standard. I have not used it yet, so I have no experience to help you. The best I can do is direct you to the reference manual. The charger detection is chapter 41, starting on page 925.

Actually, my understanding is that this charging method is only an Apple (non-)standard.

The USB standard for charging specifies that the data pins are in fact shorted together (with no voltage present), and the charger operates within a specified required range of voltage-current, or if a device exceeds that, the charger will change into a constant current source. See: http://bec-systems.com/site/800/how-do-modern-usb-chargers-work

So I think voltage sensing stuff is really only for compatibility with legacy apple-style chargers, not any actual USB standard. But I may be wrong.

- Peter
 
It's hard to tell… I found this interesting link here: http://www.ladyada.net/make/mintyboost/icharge.html . Looks like it's possible for chargers to tell the device how much power it's able to provide. btw... Specifications allow up to 5Amps!

My first breadboard test setup happily takes about 180mA from USB without negotiating it first to the host. Looks like this works as long as you don't go too high (>500mA). I'm sure the USB ports are protected inside the computer but I still prefer a cheap (powered) USB hub in between.

A really nice solution would be to first use less than 100mA with some components switched off. Then try to renegotiate 500mA with the host and switch the components on if this works. If not, let a red LED blink or something like this. But hey, that's another story. I'll just use these 180mA for now…
 
Still one more question…

I cut this small conenction to split Vin from Vusb and attached an external regulator to get more current on 3.3V. Now how do I correctly power the Teensy3? Vin is currently no longer connected and I feed the 3.3V in using pin '3.3V (100mA max)' next to Pin 23. It works but is this correct? Is it still ok to use a 48MHz system clock?

It would be great if you could update this page for Teensy3: http://www.pjrc.com/teensy/external_power.html
 
Still one more question…

I cut this small conenction to split Vin from Vusb and attached an external regulator to get more current on 3.3V. Now how do I correctly power the Teensy3? Vin is currently no longer connected and I feed the 3.3V in using pin '3.3V (100mA max)' next to Pin 23. It works but is this correct? Is it still ok to use a 48MHz system clock?

It would be great if you could update this page for Teensy3: http://www.pjrc.com/teensy/external_power.html

Agreed Paul, please update.

My natural inclination says that you should be fine, the T3 doesn't know where it's getting voltage from or how much current can be played with [to an extent]. So you should be fine at a full clock.
 
Status
Not open for further replies.
Back
Top