USB power supply considerations - MobiFlight/MobiFlight-Connector GitHub Wiki
First of all, USB is complicated. The specifications aren’t entirely straightforward and sometimes seem to contradict themselves. Due to the complexity, this article can only give a brief overview. It is by no means a complete guide to USB and I will leave out information if they are not relevant. However, I will add conclusions considerations for „best practice“ with regards to sim panel building.
It is important to understand the difference between the actual USB specification and the USB connector specification. The latter defines the plug and receptacle and does not make any statement about the current that can be drawn from it. It outlines the mechanical (and electrical) characteristics of USB connectors. Typical connectors are USB-A, USB-B, MicroUSB or USB-C.
The USB specification on the other hand defines the function. The main difference between the USB versions is the data transmission speed. There is also an interesting difference in the power supply definitions between USB 2.0 and 3.x. We won’t deal with data transmission speeds here because it’s usually irrelevant and almost all appliances we use are USB 2.0 anyway.
Since USB is usually backwards compatible, a device using a USB-C plug can be anything from USB 2.0 to USB 4 Gen4. Remember: USB-C is just the definition of the plug! Therefore it is not possible to make a generally valid statement about the current capabilities of a cable or device without taking a closer look.
Before we start looking into the details of USB power supply, we need to introduce a few terms to bring us all on the same page. A USB capable appliance has two main properties: data operation and power supply.
- A USB appliance that transmits or receives data can be either a host or a device.
- A USB appliance delivering power is called a source, an appliance receiving power is a sink.
In almost all cases, the host will also be the source and the device will be the sink.1 Until the introduction of USB-C, there was a clear definition that let you distinguish a host from a device by looking at the connector. Hosts would always have a USB-A connector. USB-C changed this axiom. We will talk about it later.
The first thing we need to accept is that not we, or our sink, decides how much power we can get. It is the source’s (your computer‘s) decision. Always.2 As per USB 2.0 specification, the source must provide 100mA to every device. Yes, 100mA, or (as per specification) one unit load. This is called low-power mode. You probably thought of 500mA, right? Well… the sink can indicate that it is a high-power device and request up to 500mA from the source. This process is called enumeration and it’s a very complex thing that happens in the first milliseconds when you plug in a USB appliance. There is a lot more going on during this process, but we’ll focus on power supply.
The USB 2.0 specification states
A device may be either low-power at one unit load or highpower, 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. 2
Host controllers monitor their power consumption. That's the reason why you cannot simply request more, but rather ask for more. However, the initial specification is already a bit older and has been updated a few times. Nowadays you can usually expect to the 500mA from a computer's USB port, because
Root port hubs: Are directly attached to the USB Host Controller. Hub power is derived from the same source as the Host Controller. Systems that obtain operating power externally, either AC or DC, must supply at least five unit loads to each port. Such ports are called high-power ports.2
For USB 3.x the same rules apply as for USB 2.0. The main difference is that we can get 150mA initially, and up to 900mA after enumeration. But wait! It is important to understand that you don’t get 900mA automatically if you plug your USB device into a 3.x port. You can only get the higher current if your device identifies as a USB 3.x device. A regular Arduino board, which is a USB 2.0 device, will not get more than 500mA from a USB 3.x port.
Yes... and this is the part where it becomes complicated. So far, we have only talked about the USB specifications. The thing we didn't take into consideration: Do manufacturers really care? No, they don't. Most USB hardware providers exceed the requirements of the specification with regards to power supply. They don't want to take the risk that random USB devices don't work with their hardware. In most cases you will be able to draw more power from a USB source. That's good for us! But please keep in mind: Strictly speaking, you're operating outside of the USB specification. There is no guarantee that it will always work with any hardware.
Here is the good news: Active USB hubs must provide 500mA per port.2 That means if you’re using a self-powered hub, you can always assume to have 500mA (or 900mA if it's a USB 3.x hub) available on every single port.
to be continued
1 https://www.usb.org/sites/default/files/USB%20Type-C%20Spec%20R2.0%20-%20August%202019.pdf Paragraph 2.3.3
2 https://www.usb.org/document-library/usb-20-specification Paragraph 7.2.1