Author Topic: USB implentation & suspend current - a necessity?  (Read 986 times)

0 Members and 1 Guest are viewing this topic.

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: dk
USB implentation & suspend current - a necessity?
« on: April 17, 2022, 08:22:42 am »
Hi :)

I'm trying to add USB to an MCU, USB device only, working at Full speed with a MIDI interface (and potentially DFU).

Just wondering about the suspend current - as I understood at anytime the host could ask my device to go into suspend mode, and then I have to reduce current usage to 2.5mA (or is it 500uA?) on the Vbus, correct?

If that is correct, how bad is it to simply ignore those calls?

Thank you :)
 

Offline pigrew

  • Frequent Contributor
  • **
  • Posts: 680
  • Country: us
Re: USB implentation & suspend current - a necessity?
« Reply #1 on: April 17, 2022, 03:48:40 pm »
Yes, USB 2.0 section 7.1.7.6 states that "All devices must support the Suspend state", and that the device only has 10 ms to suspend after the bus becomes idle.

The limit is either 500 uA or 2.5 mA, depending on if it is a "high power device".

Things will generally work if you don't implement low-power suspend, but you won't be able to put the USB logo on the product. The USB host might get mad, but I don't expect any damage would happen.

Most IC have a suspend or reset pin which the MCU can use to put them in a low power state (so power gating would be unnecessary). The MCU would also need to go into a sleep/suspend state. If you have, for example, analog amplifiers, you may need to resort to power gating.

I'd suggest designing your hardware such that suspend is possible, but not implementing it in software until needed.
 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: dk
Re: USB implentation & suspend current - a necessity?
« Reply #2 on: April 17, 2022, 08:46:04 pm »
Ok thank you both very much for the answers, really nice to know.

My problem is that right now my product does not use USB, and nothing in it is designed to go into low power mode.
(but funny enough it is actually USB powered in a non-compliant way, leaving DP/DM floating - it has never been an issue)

I simply want to add some USB communication to it.

What do I get from having the USB logo on the product?

PS: I get that it's a standard and ideally yes I would happily respect it. Just wanted to know "real world" conditions for not respecting this part of the standard.


EDIT: waaaait - I just realized something, if someone plugs a "USB-compliant" device in a simple phone charger adapter, i.e. just to give it power, then it will always be "Idle" on the DP/DM pins, i.e. always suspend mode, so the device will never start to draw any power?
« Last Edit: April 17, 2022, 08:50:28 pm by simonlasnier »
 

Offline pigrew

  • Frequent Contributor
  • **
  • Posts: 680
  • Country: us
Re: USB implentation & suspend current - a necessity?
« Reply #3 on: April 17, 2022, 09:18:24 pm »
Without certification, you won't be assigned a USB VID/PID code for your device, and worst case the USB IF will sue you for trademark infringement if you claim your device is a USB device (I'm not sure how common this is....). You likely can get away with using an unassigned VID or cloning someone else's, and will very likely be OK if you only use it as a power sink and don't use the USB logo.

The devices must use <=200 mA until they negotiate higher-power from the host/charger. You can draw <200mA indefinitely for 45 minutes if you claim the device's battery is low... The upstream port is perfectly within its rights to turn off the bus power if it wants the device to suspend and the device keeps drawing power.

See the USB Battery Charging Specification for details. It allows for dumb chargers that don't really care what the device is doing, but the devices are still supposed to negotiate. There are other standards and "standards", too... Qualcomm QuickCharge, USB-PD, Apple's fast charging resistors...

EDIT: I reread the spec, and figured out the devices can only draw 200 mA for 45 mins...

EDIT2: The other issue is that there are many "chargers" that leave D+ and D- floating. A USB compliant device would see that D+ and D- are floating, and know that it isn't supposed to draw much current. One reason is to reduce arcing of the contacts in the connector. The USB connector first connects GND/VBUS, and then connects D+/D-. The compliant solution only starts to draw significant once D+/D- are connected since that implies that VBUS and GND already have a good connection. The arcing would happen if current was flowing as VBUS/GND were connected.
« Last Edit: April 18, 2022, 02:38:20 am by pigrew »
 
The following users thanked this post: thm_w, Saimoun

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: dk
Re: USB implentation & suspend current - a necessity?
« Reply #4 on: April 18, 2022, 11:23:25 am »
For the VID I was thinking saving those $5000 per year and using one from those open-source like https://pid.codes/
(the product is commercial but will be open-source and open-hardware).

worst case the USB IF will sue you for trademark infringement if you claim your device is a USB device (I'm not sure how common this is....).

That sounds scary - but aren't there like a million devices out there that use USB (without the logo) without being 100% certified? At least it's the feedback I got when I decided to use a USB plug for power instead of a power barrel plug.


I thought the limit was 100mA before negotiation (instead of 200mA), but either way my device draws about 80mA anyways (that's the max average, there are very short peaks above 100mA once in a while).


EDIT2: The other issue is that there are many "chargers" that leave D+ and D- floating. A USB compliant device would see that D+ and D- are floating, and know that it isn't supposed to draw much current. One reason is to reduce arcing of the contacts in the connector. The USB connector first connects GND/VBUS, and then connects D+/D-. The compliant solution only starts to draw significant once D+/D- are connected since that implies that VBUS and GND already have a good connection. The arcing would happen if current was flowing as VBUS/GND were connected.

Reading both your answers I'm still confused on what a compliant device should do when connected to a dumb USB phone charger, say one that leave DP/DM floating.
First would that not be an issue? Having a completely floating DM pin that will maybe oscillate and create strange behavior on the USB IC/MCU (as normally you would have a 15k pull-down). Should a device add a very high pull-down to avoid this, say 1M ohm?

Then that would still read as D+ high and D- low, and no negotiation is going to happen (since there is not USB host), which means that after 45 min the USB device should stop drawing any power?

I guess the problem comes from that these "dumb USB phone chargers" are actually not USB compliant, but I know for a fact that most (if not all) USB compliant devices I own work perfectly fine with these, so surely they must detect that there is no host and simply draw whatever power they need?
« Last Edit: April 18, 2022, 11:25:13 am by simonlasnier »
 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: dk
Re: USB implentation & suspend current - a necessity?
« Reply #5 on: April 21, 2022, 05:28:31 pm »
Just a little update  8)

I've tested with a USB device that does nothing apart from lighting an LED accord to the mode. The device is connected to my laptop, powered via USB.

When I put the laptop to sleep:
  • if it uses a normal USB port, the device goes into suspend mode, and after 5-10s the Vbus turns off (and the device as well)
  • if it uses a "power" USB port, the device is not in suspend mode, but not connected - it does not turn off

When I use normally the laptop:
  • if the laptop is not connected to power, after 30s the device does into suspend mode
  • if the laptop is connected to power, it does not

My question: say I have a device that does nothing like this one, but that should not be put in suspend mode. Is there a way to send a regular message to the host saying "do not put me to sleep"? :D (the idea being the device does "nothing" on the USB side but still other stuff non-USB related)

Second question: (if someone would like to answer that it would help a lot - thank you  ;D )
Reading both your answers I'm still confused on what a compliant device should do when connected to a dumb USB phone charger, say one that leave DP/DM floating.
First would that not be an issue? Having a completely floating DM pin that will maybe oscillate and create strange behavior on the USB IC/MCU (as normally you would have a 15k pull-down). Should a device add a very high pull-down to avoid this, say 1M ohm?
« Last Edit: April 22, 2022, 08:24:08 am by simonlasnier »
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15292
  • Country: fr
Re: USB implentation & suspend current - a necessity?
« Reply #6 on: April 21, 2022, 06:35:39 pm »
Yes it is required by the standard. And even if you don't care about full compliance, it's a good measure for the user.

While it won't make much of a difference when your device is plugged to a desktop computer, if you use a laptop, that's a different story. Draining the minimum amount of power in suspend mode is the least you can do if you care for your users. You don't want your device to drain the laptop's battery when the laptop is in standby, which will put USB in suspend.

Now if it's purely a personal project, it's up to you. Oh, and those figures are the maximum allowed. If you can achieve lower than this, the better.

Note that some MCUs will draw too much current even in low-power modes to even pass this spec. For instance, I think the RP2040 would fail the 500µA mark.
 

Offline SaimounTopic starter

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: dk
Re: USB implentation & suspend current - a necessity?
« Reply #7 on: April 22, 2022, 08:23:22 am »
Thanks SiliconWizard  ;D

What about my two questions above?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf