Author Topic: USB power levels  (Read 14738 times)

0 Members and 1 Guest are viewing this topic.

Offline osmosis321Topic starter

  • Regular Contributor
  • *
  • Posts: 64
USB power levels
« on: October 24, 2010, 01:54:49 pm »
I'm very unclear on how USB provides power to connected devices.

For example, if USB detects a device already has a voltage level, what happens then?  If USB powers a device, will it always drive it with 5v or can it do another voltage..

I ask because I've been scrutinizing the layout of this board I'm working on, and it turns out the USB power is directly connected to the main VDD of the board, and I know the PIC24FJ won't survive that voltage for long.

I got lucky - before I became aware of this potential issue I'd connected the USB with the board already powered at 3.3v, and nothing bad happened.  Presumably the USB hardware detected the voltage and didn't provide any of it's own?  And presumably if I connect the board to USB without it's own power, USB will start providing 5v and my MCU will overheat and die?
 

alm

  • Guest
Re: USB power levels
« Reply #1 on: October 24, 2010, 02:06:38 pm »
USB can only provide 5(ish)V. Not sure about detecting already powered devices, I wouldn't rely on this behavior, unless it's clearly part of the spec (and even then, low-end manufacturers usually only implement part of the spec). I've never heard of this, it may just be a side effect of some other protection circuit (eg. reverse power protection diode in 3.3V regulator conducting and overcurrent protection of the USB port kicking in). You may be able to disconnect the USB power pin for self-powered operation.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11648
  • Country: my
  • reassessing directives...
Re: USB power levels
« Reply #2 on: October 24, 2010, 02:58:11 pm »
5V and always. if your circuit is made poorly, sure it can kill your mcu. and even your PC USB port/hub.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline migsantiago

  • Frequent Contributor
  • **
  • Posts: 381
  • Country: 00
    • MigSantiago's Web Site
Re: USB power levels
« Reply #3 on: October 24, 2010, 03:48:02 pm »
Every single USB port must deliver the following power:

Low power port: 5V, 100mA maximum
High power port: 5V, 500mA maximum

Good USB ports disable the 5V supply when the computer is turned off (by software or by hardware jumpers). Cheap USB ports always enable the 5V output, even with your computer turned off.

If you are going to use a PIC24 and a USB port, use a 3.3V regulator to power the PIC.

Make sure that your PIC will not draw more than 100mA.

NEVER SUPPLY ANY VOLTAGE OR CURRENT BACK TO THE VBUS PIN (5V pin).

NEVER CONNECT MORE THAN 10uF OF CAPACITANCE TO THE VBUS PIN (5V pin).
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9019
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: USB power levels
« Reply #4 on: October 24, 2010, 05:43:37 pm »
Good USB ports disable the 5V supply when the computer is turned off (by software or by hardware jumpers). Cheap USB ports always enable the 5V output, even with your computer turned off.
The only USB ports I have seen that could remain on with the computer off were in a Dell laptop, and it was marketed as a feature. Basically, the USB ports turn on whenever the AC adapter is plugged in, to allow users to charge cell phones and other electronics from the USB ports without turning the computer on. That feature can be disabled in BIOS.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline DJPhil

  • Frequent Contributor
  • **
  • Posts: 511
  • Country: 00
Re: USB power levels
« Reply #5 on: October 24, 2010, 05:49:06 pm »
Good USB ports disable the 5V supply when the computer is turned off (by software or by hardware jumpers). Cheap USB ports always enable the 5V output, even with your computer turned off.
The only USB ports I have seen that could remain on with the computer off were in a Dell laptop, and it was marketed as a feature. Basically, the USB ports turn on whenever the AC adapter is plugged in, to allow users to charge cell phones and other electronics from the USB ports without turning the computer on. That feature can be disabled in BIOS.
The last good laptop I worked with was a Compal (not a typo) IFL90, they make very nice ODM laptops that gets rebranded into all sorts of things (Dell and Alienware among them). The IFL90 had an external button and indicator light that would allow 500mA charging on the usb ports, with or without the compter on and with or without power. Very nice feature for emergency cellphone use.
 

Offline RayJones

  • Frequent Contributor
  • **
  • Posts: 490
    • Personal Website
Re: USB power levels
« Reply #6 on: October 24, 2010, 06:44:47 pm »
The 5V that may be present on a USB port with the power off is so features such as wake on mouse or wake on keyboard can actually function.

The 5V is actually sourced from the 5V standby line from the power supply, and for us at work it is really handy to power and internal independent watchdog. We build special cables to plug onto an internal USB header and thus power the watchdog without needing to vampire the power supply's purple wire.

Your ATX based PC is never OFF, it is in a low power standby when you press that front panel switch, and the power on the USB's (if present) is one and the same.

So some may consider it a nuisance, some consider it essential.
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9019
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: USB power levels
« Reply #7 on: October 24, 2010, 07:57:00 pm »
The main problem with that is powering all the USB ports. If there are 10 USB ports, you'll need a power supply that can supply at least 5A to handle worst case load. I'm not aware of any standard ATX power supply that can supply that much in standby. (Powering only some USBs in standby would work, though.) Not a problem for a laptop since the AC adapter can always supply its full rated current.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline DavidDLC

  • Frequent Contributor
  • **
  • Posts: 755
  • Country: us
Re: USB power levels
« Reply #8 on: October 24, 2010, 08:15:29 pm »
If you are designing your own USB device you are responsible to implement it so it will report that is a powered or unpowered device during registratrion.
 

alm

  • Guest
Re: USB power levels
« Reply #9 on: October 24, 2010, 08:26:38 pm »
The main problem with that is powering all the USB ports. If there are 10 USB ports, you'll need a power supply that can supply at least 5A to handle worst case load.
USB ports don't have to supply over 100mA unless requested, and they can deny that request, so 1A would be enough for ten ports. Not sure if this handshake is possible without the CPU being enabled, though.
 

Offline migsantiago

  • Frequent Contributor
  • **
  • Posts: 381
  • Country: 00
    • MigSantiago's Web Site
Re: USB power levels
« Reply #10 on: October 24, 2010, 08:38:56 pm »
The main problem with that is powering all the USB ports. If there are 10 USB ports, you'll need a power supply that can supply at least 5A to handle worst case load. I'm not aware of any standard ATX power supply that can supply that much in standby. (Powering only some USBs in standby would work, though.) Not a problem for a laptop since the AC adapter can always supply its full rated current.

A device can only draw 500mA when the OS is running and has configured it, not when the PC is off. The USB port should not provide power when the PC is off because there's no host to manage the current per hub, it's dangerous.

Of course, when designers want to use your PC as a USB charger they often ignore the USB standard and do whatever they please.

USB ports don't have to supply over 100mA unless requested, and they can deny that request, so 1A would be enough for ten ports. Not sure if this handshake is possible without the CPU being enabled, though.

USB ports must always provide up to 100mA, even before the device has been configured. This behavior enables USB devices "to introduce themselves" to the OS when they do not have an external power supply (i.e. USB memories).

Once the device has described itself, it could ask for more current from the host. If the host can provide that current (up to 500mA), then it "configures" the device and lets it draw the current it requires.
 

Offline osmosis321Topic starter

  • Regular Contributor
  • *
  • Posts: 64
Re: USB power levels
« Reply #11 on: October 25, 2010, 03:13:10 pm »
If you are designing your own USB device you are responsible to implement it so it will report that is a powered or unpowered device during registratrion.

I'm using FT232R USB-UART IC.  The chip manufacturer supplies basic .inf files, but they just set up a VCP.  Registration is taken care of by the chip itself, I believe.
 

Offline cyberfish

  • Regular Contributor
  • *
  • Posts: 240
  • Country: gb
Re: USB power levels
« Reply #12 on: October 25, 2010, 04:54:41 pm »
From the FT232 datasheet, page 14 -
http://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT232BM.pdf

Quote
A USB Bus Powered device gets its power from the USB bus. Basic rules for USB Bus power devices are as follows:
a) On plug-in, the device must draw no more than 100mA
b) On USB Suspend the device must draw no more than 500uA (2.5mA for devices configured to support remote wake-up).
c) A Bus Powered High Power Device (one that draws more than 100mA) should use the PWREN# pin to keep the current below 100mA on plug-in and 500uA(2.5mA) on USB suspend.
d) A device that consumes more than 100mA cannot be plugged into a USB Bus Powered Hub
e) No device can draw more that 500mA from the USB Bus.
The power descriptor in the EEPROM should be programmed to match the current draw of the device.
 

Offline Hewitson

  • Contributor
  • Posts: 16
Re: USB power levels
« Reply #13 on: October 28, 2010, 04:16:02 am »
Quote from: migsantiago
Every single USB port must deliver the following power:

Low power port: 5V, 100mA maximum
High power port: 5V, 500mA maximum
Must? Plenty don't. Motherboard manufacturers rarely pay attention to things like this.

Quote from: migsantiago
Good USB ports disable the 5V supply when the computer is turned off  (by software or by hardware jumpers). Cheap USB ports always enable the 5V output, even with your computer turned off.
Unsure where you get that logic from, surely they are supposed to be on so you can turn on the computer with a USB keyboard or mouse.
 

Offline EEVblog

  • Administrator
  • *****
  • Posts: 37742
  • Country: au
    • EEVblog
Re: USB power levels
« Reply #14 on: October 28, 2010, 08:12:06 am »
I've found the 100mA/500mA thing to be generally a rule that is mostly never followed.
Every port I have tested has been able to deliver 500mA without asking (i.e. into a dumb resistive load)

Dave.
 

Offline cyberfish

  • Regular Contributor
  • *
  • Posts: 240
  • Country: gb
Re: USB power levels
« Reply #15 on: October 28, 2010, 08:19:08 am »
Quote
Every port I have tested has been able to deliver 500mA without asking (i.e. into a dumb resistive load)
That is probably because many products are not compliant (draw 500mA without asking), forcing host implementations to also have to support that. I guess they just don't want to put a USB microcontroller in a cellphone charger that costs $1.

I wouldn't be surprised if they remove this requirement in USB 3.0 (did they?). But that will cause problems with unpowered hubs. Who will, I guess, have to detect this overcurrent condition and just shutdown the port.
 

Offline cyberfish

  • Regular Contributor
  • *
  • Posts: 240
  • Country: gb
Re: USB power levels
« Reply #16 on: October 28, 2010, 08:21:49 am »
For another example of where this current limit matters, I am currently working with a single board computer (gumstix) that has a USB OTG port that will only source 100mA, and will blow up if USB slave tries to draw 500mA.

My webcam does proper power negotiation, and correctly refuses to work when the host doesn't want to give it 500mA.

I had to slice the USB cable and provide my own power from a 7805.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11648
  • Country: my
  • reassessing directives...
Re: USB power levels
« Reply #17 on: October 28, 2010, 01:23:28 pm »
my PC USB will reset the device/itself if accidental short is occured. did that while poking around Arduino, luckily it didnt blow up.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline migsantiago

  • Frequent Contributor
  • **
  • Posts: 381
  • Country: 00
    • MigSantiago's Web Site
Re: USB power levels
« Reply #18 on: October 28, 2010, 02:56:39 pm »
Quote from: migsantiago
Every single USB port must deliver the following power:

Low power port: 5V, 100mA maximum
High power port: 5V, 500mA maximum
Must? Plenty don't. Motherboard manufacturers rarely pay attention to things like this.

Quote from: migsantiago
Good USB ports disable the 5V supply when the computer is turned off  (by software or by hardware jumpers). Cheap USB ports always enable the 5V output, even with your computer turned off.
Unsure where you get that logic from, surely they are supposed to be on so you can turn on the computer with a USB keyboard or mouse.

Yeah, must... and plenty don't. The USB specification is not followed at 100%, I know.

For example, my laptop disables its USB ports when it's turned off. USB power must not be supplied when the host is not working... but as you said before, the manufacturers don't do so.
 

Offline RayJones

  • Frequent Contributor
  • **
  • Posts: 490
    • Personal Website
Re: USB power levels
« Reply #19 on: October 28, 2010, 08:10:00 pm »
 USB power must not be supplied when the host is not working...

Any citation for such a statement?

I'd consider a good USB port to be one that allows the individual user to choose whether the power stays or goes with power off.
Enforcing one form or the other will always get one type of customer offside.

 

Offline migsantiago

  • Frequent Contributor
  • **
  • Posts: 381
  • Country: 00
    • MigSantiago's Web Site
Re: USB power levels
« Reply #20 on: October 28, 2010, 09:38:00 pm »
  USB power must not be supplied when the host is not working...

Any citation for such a statement?

I'd consider a good USB port to be one that allows the individual user to choose whether the power stays or goes with power off.
Enforcing one form or the other will always get one type of customer offside.

Hello. This is the complete USB 2.0 standard (usb_20.pdf).

http://www.usb.org/developers/docs/usb_20_081810.zip

I am afraid there's no direct citation for what I said, but it can actually be deduced from the following text.

Quote
7.2.1 Classes of 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.  The number of unit loads a device can draw is an
absolute maximum, not an average over time.  A device may be either low-power at one unit load or high-
power, consuming up to five unit loads.  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.

If the host is not working, current control is not guaranteed, and the possibility of damaging the USB port is present. Therefore, power should not be supplied.

Quote
7.2.1.2.1 Over-current Protection

The host and all self-powered hubs must implement over-current protection for safety reasons, and the hub must
have a way to detect the over-current condition and report it to the USB software
.  Should the aggregate current
drawn by a gang of downstream facing ports exceed a preset value, the over-current protection circuit removes
or reduces power from all affected downstream facing ports.  The over-current condition is reported through the
hub to Host Controller, as described in Section 11.12.5.  The preset value cannot exceed 5.0 A and must be
sufficiently above the maximum allowable port current such that transient currents (e.g., during power up or
dynamic attach or reconfiguration) do not trip the over-current protector.

The hub should not supply any current if the host will not manage it. Therefore, if the host is turned off, every USB port power should aswell be turned off.

Please view the Table 7-7 I attached. As you can see, a managed USB port should only provide 100mA of current when a device is not configured (not enumerated). After the device has "spoken" with the host, the host lets it withdraw up to 500mA of current (high power port only).

What actually is happening is that MoBo manufacturers do not implement the current measuring and host controlling. If a PC is turned off, then its host (chip controller) is turned off, and no power should be delivered.
 

Offline cyberfish

  • Regular Contributor
  • *
  • Posts: 240
  • Country: gb
Re: USB power levels
« Reply #21 on: October 29, 2010, 02:38:56 am »
I don't think "software control" is required for host if the host can put out 500mA.

It doesn't make sense for the host to limit current output to 100mA if it can put out 500mA.

The software handshake is for when the host can't source 500mA. That's why the specification says the client has to ask before drawing >100mA, not the host has to limit the current to 100mA before the client asks.

If a host can source 500mA, it can just ignore the high current request, and always grant it.

On the other hand, a host that can only source 100mA will just always decline the request. Again, no change in electrical behaviour.

So a motherboard that will source 500mA without the client asking is standard compliant, but a client that draws 500mA without asking is not.
 

Offline EEVblog

  • Administrator
  • *****
  • Posts: 37742
  • Country: au
    • EEVblog
Re: USB power levels
« Reply #22 on: October 29, 2010, 03:56:34 am »
So a motherboard that will source 500mA without the client asking is standard compliant, but a client that draws 500mA without asking is not.

Gosh darn it, my latest project is not compliant!  ;D

Dave.
 

Offline migsantiago

  • Frequent Contributor
  • **
  • Posts: 381
  • Country: 00
    • MigSantiago's Web Site
Re: USB power levels
« Reply #23 on: October 29, 2010, 03:08:31 pm »
Yeah, the USB standard is perfect in every way... but we designers just ignore it.

There's a special USB State called suspend in which the device must reduce its consumption to 2.5mA. The USB libraries that the CCS compiler ships do not implement that power consumption, it's up to me... but I've never done so.

Most students nowadays use the USB port as a plain power supply, they plug whatever they need and sink any current they want.

So, USB powers are ideal... in reality, you do whatever you want with them  :D

EDIT: It seems that in the latest version the CCS compiler actually implements suspension :o

Code: [Select]
/*******************************************************************************
/* usb_isr_uidle()
/*
/* Summary: USB peripheral detected IDLE.  Put the USB peripheral to sleep.
/*
/********************************************************************************/
void usb_isr_uidle() {
   UIR_UIDLE=0;
   bit_set(UCTRL,1); //set suspend. we are now suspended
   bit_clear(UIR,2); //clear activity interept flag
   bit_set(UIE,2);   //enable activity interrupt flag. (we are now suspended until we get an activity interrupt. nice)
}
« Last Edit: October 29, 2010, 03:10:29 pm by migsantiago »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf