Advertisement

USB Power Testing With an Arduino Controlled Dummy Load Project

One part that I find myself using somewhat regularly in microcontroller-based experiments is the “USB power bank” that provides USB-standard 5-V DC output and offers some basic protection features. However, while fiddling with a recent project, I discovered that the power bank does not maintain its output stability very well. Even if the connected load draws current within safe limits, its output voltage often hiccups for no apparent reason. Because different products behave differently (not as advertised), I needed to examine how dissimilar USB power sources behave under different loads. Interested? Read on.

 

USB power catering and charging issues are astoundingly complex. Although it’s quite natural to assume that a USB port delivers a specified amount of power to a connected device, sometimes it tends to be unpredictable. To know what happens when a device draws a certain amount of power from a USB port, we need an adjustable dummy load that lets us set the amount of power that it draws. The first version (v1.0) of my USB Dummy Load circuit presented here is a cheap and cheerful solution for testing USB chargers and USB power banks/batteries. The simple design uses power resistors to insert a load on the USB power lines, imitating an external device drawing a delimited amount of power from the concerned USB port. This comes in handy when a USB power source does not meet the claimed specifications.

 

Project schematic

 

As seen in the above schematic, a 5-V DC supply from the USB connector (USB) is routed to two 10-Ω/5-W power resistors (R1 and R2) through an SPST switch (S1) followed by an SPDT switch (S2). Here, S1 is used as the master power on/off switch while S2 selects the rating of the dummy load; i.e., R1 alone for 500 mA and R1 and R2 (in parallel) for 1,000 mA. The circuit also holds a bi-color indicator (LED1) to signal the selected load (green light for 500 mA and red light for 1,000 mA). The next three-pin connector (J1) is for an external DC digital voltmeter (DC DVM). Aside from these, there’s nothing else — it’s a pretty straightforward design. If you replace the resistors R1 and R2 with 5-Ω power resistors, then you can set the current in 1,000 mA and 2,000 mA (remember that the limit for USB 2.0 is only 500 mA). Once connected to the USB port of the device under test, the power draw can be selected to record the voltage at each step. Also keep an eye on the self-consumption of the DC voltmeter used with the setup (for me, it’s around 20 mA).

 

It’s almost been six weeks since I’ve looked at an Arduino-based DC DVM concept, but having designed and constructed one recently, I didn’t want a repeat of the same. I suppose it would only be right for me to go and grab a “chinaware” one for myself. A quick trip to eBay (and a week later), I had a new, two-wire DC DVM (3.6 to 28 V) module to play with. Because there isn’t anything to tinker with, I just plugged it in to the three-pin connector (J1). Quite nice!

 

Warning! Many power resistors have a working temperature up to 300°C when loaded extremely. So do not touch the power resistors whenever the circuit is in an active state unless you really want to burn your fingers.

 

Try the Arduino!

The DC digital voltmeter (DC DVM) is one of the first things you need if you’re working with this project. But what if you are not in the position to buy one from eBay? If you have an Arduino lying around, you’ve got a simple digital voltmeter. The sketch (and the hardware setup) below turns your Arduino with a 16×2 (I2C) LCD into a single-channel digital DC voltmeter. The Atmega328 at the kernel of the Arduino has six analog inputs (10-bit ADC), but two of them are used for I2C support. That leaves four channels — plenty for most other intentions.

 

#include “LiquidCrystal_I2C.h”

#include “Wire.h”

#define LCDADDR 0x3F

#define LCDCOLS 16

#define LCDROWS 2

LiquidCrystal_I2C lcd(LCDADDR, LCDCOLS, LCDROWS);

float val = 0;



void setup() {

  lcd.begin();

  lcd.print(“Voltage Value:”);

}

void loop() {

val = analogRead(A0);

val = val/1024*5.0;



Serial.print(val);

Serial.print(“V”);

lcd.setCursor(6,1);



Serial.println( );

lcd.setCursor(6,1);



lcd.print(val);

lcd.print(“V”);

delay(100);

}

 

 

USB dummy load configuration

 

However, this Arduino DVM can also be used as a standalone 5-V DVM by slightly changing the hardware setup and powering the Arduino from an external power source like the common 9-V battery (see revised hardware setup).

 

Configured as a DVM with external power supply

 

I am sure there are plenty of ways to improve on this, but the result is good and the code is simple. Obviously, this “homemade digital voltmeter” concept needs some refinements. If you are really stuck, don’t hesitate to contact me for further inquiry. Just use the comment box below, and I promise I will get back to you promptly. Here is a random snap (proof-of-concept) of my initial test setup:

 

Project setup and running in the lab

3 Comments

Join the conversation!

Error! Please fill all fields.
  • Adam Carlson

    This looks very nice TK. Were you able to use it in the lab to figure out the issue you were ultimately having with the usb power supply that was giving you issues?

    • T.K.Hareendran

      @Adam: Yes, figured out ! Actually, my cheap power bank (from China) was lowering its output voltage (to around 4V) when the connected load demands current @ 1A. It’s surprising that the advertised maximum capacity of the power bank is 5V @ 2A +/- 5%. So I expected a rated value of 1A, but cheated!

    • Adam Carlson

      Interesting, though not surprising. Having cheap power supplies that are only ~50% capable of their stated rating is not too uncommon.

Looking for the latest from TI?