9

I am new to designing something to be powered by USB. Ideally It can either be plugged in to an adapter to a UK wall plug, or a powered USB port on another device. I have the circuit design in place using Kicad but I've never powered a device using USB.

Is is simply just connecting V+ to the bits that need power, ground to the bits that need ground and a 1uF capacitor connector between the two (if so which way should they be connected)? Or is this wildly wrong? I don't need any data transfer to D+ and D- have been left open. Do these need to be connected to ground with pull down resistors or something? Id like to get this right so I can do it when designing other products.

Im powering an attiny and some 5mm LEDs

  • 1
    Its not technically correct according to the USB spec, but there are 100000000's of devices out there which do just that. As long as you don't try to draw too much current, you'll be fine. – brhans Mar 12 '16 at 14:43
  • As for the capacitor: If your circuit doesn’t really care about a stable supply or does its own voltage regulation you can leave it out (or replace it with the capacitor recommended in your voltage regulator’s datasheet). For ceramic capacitors (most common in the 1μF range) the polarity doesn’t matter, for tantalum or electrolyte the + side is usually marked. – Michael Mar 13 '16 at 13:50
  • If you can't afford USB bus negotiation, then don't go for USB plug. It's as simple as that. – Agent_L Mar 13 '16 at 16:27

6 Answers6

16

USB devices can draw up to 100 mA to perform initial negotiation, called enumeration, with the host. During this process they can request up to 500 mA. The host then decides whether to grant the extra power or shut down the device.

In some cases the host may tell a device to go into low power sleep mode.

Most wall-powered computers just connect the USB power to their 5 V supply via a polyfuse and don't attempt to control or even monitor current. Battery operated device often do carefully manage USB power. You may therefore get away with just drawing power without asking when connected to a desktop computer, but possibly not when connected to a laptop.

Of course, this is all in the USB spec.

Olin Lathrop
  • 310,974
  • 36
  • 428
  • 915
  • 1
    Is this still correct for USB3+? – AndrejaKo Mar 12 '16 at 16:44
  • Cant plugging things in the USB port damage the computer if it draws too much power or somehow shorts. I've ruined one computer from USB experiments... this is maybe different, though. – Evan Carslake Mar 12 '16 at 19:47
  • 1
    @EvanCarslake yes, but that's also the fault of the computer you plugged it into - they are supposed to have self resetting fuses on the USB power lines for just that reason. But some manufacturers cut corners. – Grant Mar 13 '16 at 01:38
3

It depends on how much power you need. By default you get low power mode, which can deliver up to 100mA, which is enough for a lot of things. You can get up to 500mA if you negotiate high power mode with the the host. This has been covered in other questions.

Willis Blackburn
  • 1,217
  • 1
  • 13
  • 24
2

As others have already stated, you can pretty much always draw 100mA from any USB host.

If you want/need more power than that (without violating USB specifications & making something that could potentially harm your host devices), then you can either:

  1. Connect a MCU/CPU pin to the data pins, so you can negotiate higher charging rates with the host

or

  1. Sense the D+/D- pins actively. When connected to a (specification conforming) charger, the D+/D- pins are shorted together in the charger, so your device can know that it's "allowed" to take power at a high rate without negotiation. When connected to a host, these pins will not bs shorted, so your device will need to limit itself to 100mA draw.
Robherc KV5ROB
  • 5,088
  • 1
  • 10
  • 24
1

Theres the theory and there is the practice.

The theory is that before enumeration you are only allowed to draw 100ma. Furthermore there are time limits after which if enumeration fails you must drop down to a very low power state. USB wall warts ("battery charging" spec) short the D+ and D- lines together to indicate that they are not a regular USB host.

The practice is that hosts (even laptops) normally just have dumb current limiting with a fixed theshold. So if you don't care about getting your device certified as USB compliant you can just draw 500ma (or even slightly more) immediately and it will work fine with the vast majority of hosts.

Peter Green
  • 21,158
  • 1
  • 38
  • 76
0

I believe that USB 3.0 devices can draw up to 1000mA provided that the host allows it.

Jacob P
  • 165
  • 5
  • 1
    That's only after successful initialization & negotiation between host & client. I don't remember exactly the amount, but without initialization, you're only allowed a *very* low draw rate. Something like 100mA, IIRC – Robherc KV5ROB Mar 13 '16 at 03:17
  • @RobhercKV5ROB thanks for the comment, I'm new to this site. – Jacob P Mar 13 '16 at 08:11
0

Stay at or under 100 mA and you don't have to worry about enumeration. If you're building a one-off, I wouldn't worry about pulling up to 500 mA, even without enumeration. If you're building a product, toss a 50-cent MCU in there to enumerate the bus and ask for more current.

Jay Carlson
  • 2,819
  • 1
  • 14
  • 21