Raspberry Pi USB Power Issues
Let’s coming back to the USB ports. We did some testing and connected 4 devices to the RPi 2 B each drawing a current of approx. 160 mA from the port. The result was that the first three devices were power supplied properly. When the 4th device was connected, the system became instable and all devices were disabled and re-enabled on the USB periodically and could not be used.
We found on some forum, that the current that can be supplied by the RPi 2 B to the USB ports, is limited to 600 mA in total. In our test we were with 640 mA slightly above this limit and this might have caused the malfunction.
Fortunately, the current limit can be increased to 1.2 A by a software setting. This sets GPIO38 high, enabling a transistor which is able to source a higher current. A detailed description can be found in the links below.
In order to increase the power limit it is only necessary to add the following line to /boot/config.txt:
After a restart of the RPi, the output current is increased and up to 1.2 A can be drawn in total from the 4 USB ports. Our test with the 4 devices worked well after we applied the setting.
- We tested it with Raspbian Jessie
- This should also work with the RaspberryPi B+
This topic is discussed in the Raspberry Pi community and you can find some more information here:
B+ and max_usb_current
About Rpi2 usb power output (0.6Amp/1.2Amp switch)
While the LucidControl USB data acquisition modules need less than 100 mA of total current, the USB relay output module and USB analog output module need a higher currents which can especially for the analog output module go up to 200 mA per module. Even in this extreme scenario the Raspberry Pi 2 B sources the USB IO modules properly.
There are still some Pitfalls
Schematic Power Supply of Raspberry Pi with USB IO Module
Per specification USB devices have to be able to work at a minimum voltage of 4.75 V and this can become a problem when drawing high currents from the Raspberry Pi.
Many problems someone may encounter are caused by power supplies. This is valid in general electronic design and of course also for the RPi, especially when chargers of mobile phones are used as power supply.
The picture shows the principle of the test setup with a power supply sourcing the Raspberry Pi with the voltage VIn. When the RPi is sourced via the Micro-USB connector an input circuit ensures that the RPi is not destroyed by wrong polarity of the supplied voltage and a polyfuse opens the circuit in case of an overload. The resistance of the polyfuse causes a low voltage drop which depends on the current drawn.
The voltage V5 behind the input circuit is available on the pinhead connector at the pins 2 and 4. These pins are designed as power supply output pins for add-on modules and you have to be careful using them as power supply input pins of your RPi.
The voltage VUsbOut is supplied at the USB connectors to the USB cable and the VUsbIn represents the voltage which is finally the input voltage of the USB device. In order to ensure proper operation of a USB device is must be ensured that VUsbIn has a minimum value of 4.75 V.
In our test the total current was approx. 900 mA resulting of 4 x 160 mA + 260 mA for the Raspberry Pi itself.
The following measurements were made with a charger of the Samsung Galaxy S3. The voltage VIn is nearly constant and it does not matter if the 4 USB modules are connected or only the RPi is running. The charger is labeled with 5.0 V / 1.0 A but it is only able to source approx. 4.8 V what might be enough for charging the mobile phones battery but not accurate enough as a power supply for a computer.
Behind the input circuit we measured V5 at pin 2 of the pinhead connector and we see that the voltage drop over the input circuit (e.g. the polyfuse) is 120 mV. Now we should recall that this does not comply with the USB standard which requires 4.75 V. From here on it is uncertain if the USB device would work or not. The voltages violating USB standards are highlighted red in the table.
An additional voltage drop results from the USB supply circuit. With max_usb_current=1 this voltage drop is 60 mV and 4.63 V are supplied to the USB cable.
And it is getting worse. Often low cost USB cables are used and it is forgotten that cables cause a voltage drop, too. This may not matter for low power devices e.g. like a keyboard or a mouse. But when drawing higher currents, the voltage drop of low quality connectors and thin wire diameters must be considered. In our experiment the worst case was a voltage drop of additional 100 mV and the device was supplied with 4.81 V (of the charger) – 180 mV (of the RPi internal circuit, e.g. polyfuse) – 100 mV (caused by cable and connectors) = 4.53 V what is 220 mV below the minimum voltage of the USB specification.
In this test a Samsung Galaxy S3 charger was used inside the specification as it is able to source 1 A. The output voltage was constant 4.8 V where it did not matter if only the RPi was supplied or if the additional 4 x 160 mA were drawn from the USB ports.
For hobby projects this might be acceptable but when the Raspberry Pi is used in reliable professional applications the power supply must be considered as a critical factor.
In our applications we are sourcing the Raspberry Pi with a 5V industrial power supply so we have a VIn which is 5 V – 4.81 V = 190 mV higher than in the charger test. Adding the 190 mV Offset to the measured VUsbIn gives 4.78 V which is inside the USB specification but not brilliant.
If a power supply allows adjusting the voltage a bit it is a feasible solution to increase the power supply voltage by 100 mV so that 5.1 V are applied to the Raspberry Pi Micro-USB connector.
Alternatively, and that’s what we do, is supplying the 5.0 V directly to the pinhead connector at pin 2.
It must be considered that this method bypasses the polarity protection and also the polyfuse is not effective anymore. But if a reverse polarity situation can be prevented (e.g. by mechanical encoded connectors) this is working well. Reproducing the measurement with a voltage of 5.0 V applied to the pinhead connector gave a VUsbIn = 4.83V.
In general we recommend using good quality USB cables. Many of the low cost cables have AWG28 (American Wire Gauge) wire diameter what is sufficient for the two data wires. For the two power lines (VCC and GND) we recommend using at least AWG24 wires. A typical description of cables with this configuration is 28AWG/1P+24AWG/2C. Since the resistance of a cable increases linearly with its length it is clear that especially for longer cables the wire diameter on the power lines becomes relevant.
We made good experiences with these two cables:
Parts Data CU-20-BK
The USB ports of the Raspberry Pi 2 B have been improved and do not suffer from the current limitations of previous Raspberry Pi versions. Additionally, it provides 4 identical USB ports which work very reliable.
After analyzing some issues regarding the power supply we see that the quality of common mobile phone chargers is not sufficient for our applications. This was expected before and we are using industrial standard DIN-Rail 5 V power supplies. The USB supply voltage can also be improved by sourcing the Raspberry Pi via the pinhead connectors.
Additional attention needs the selection of the USB cable where we have shown that high quality cables with thicker wire diameters on the power lines should be chosen.
Our intention is using the Raspberry Pi as a device server sharing up to 4 of our LucidControl USB IO Modules via a network. This allows accessing our analog and digital data acquisition and control solution over the network building a decentralized monitoring and control system.