USB Insight Hub

A USB interfacing tool for developers & tech enthusiasts

Available for pre-order

View Purchasing Options
Dec 11, 2024

Project update 6 of 6

Our Current & Voltage Metering Implementations

by David S

In this update, we will explore our current- and voltage-metering implementation and give it the credit it deserves as a very important feature of USB Insight Hub. There are still a couple of days until the campaign ends, so don’t miss this chance to secure your Insight Hub at the discounted campaign price!

Current and Voltage Monitoring Wish List

From the start, the Hub was expected to have current and voltage monitoring, similar to single channel “USB meters”. This feature is very useful as it provides vital information about the operational behavior of a downstream USB device: for instance, if its current is within nominal values or whether it has entered sleep mode. The basic current and voltage metering requirements are:

The Central Piece: Microchip’s PAC1943

There are many possible implementations and solutions to perform this task and initially it was going to be implemented using a microcontroller (see Update 3), but in the end the best option was to use Microchip’s PAC1943 as the analog powerhouse of the system. This little chip packs a lot of functionality and is suitable to monitor current and voltage in three channels (side note, this looks to be custom made for this project: one, two, or four channels are fairly common in analog or digital chips, but three is somehow a rarity. In any case, thanks Microchip for this option). These are the most important features of the PAC1943 used directly in the USB Insight Hub:

Hardware Implementation

The shunt resistor value is a tradeoff of the current reading resolution, the full-scale range, the ADC resolution of the meter, and how much voltage drop we are willing to accept. A value of 0.02 Ohms provides a good tradeoff between these factors:

You see the resolution is quite higher than the specified published 1 mA, right? Why not go to a resolution of 0.1 mA? The reason is that the error at very low voltage drop in the current sense shunt is exponentially higher. A 0.1 mA current running through the 0.02 Ohm creates a 2 µV voltage drop, that translates to more than 20% error (as specified by the PAC1943 datasheet). Conversely a 1 mA current has a specified error of 4%.

The current flow direction is reversed according to the sense pins on the PAC1943; the reason is that the voltage monitoring is performed on the positive side and not the negative one. This is a small detail, but important: the voltage you observe in the USB Insight Hub display is the value after the current sense resistor. In this way, you get the most accurate voltage reading applied to the downstream USB device. As the current reading is bidirectional, there is no problem inverting the reading sign.

From a layout perspective, the current sense voltages are routed in differential lines to the chip to reduce common mode noise and insure even trace impedance, although the high input impedance of sense +/- from the PAC1943 reduces significantly this effect.

Voltage monitoring is straightforward: it is unipolar with a full scale of 0 V to 9 V which provides a resolution of 0.137 mV (9000 mV/2¹⁶). The displayed value is at 1 mV resolution, enough for most applications.

The Alert output is routed to a pin in the ESP32 to notify for under- and over-current conditions and take actions within a few milliseconds. A more comprehensive explanation is presented in Update 2.

Software Implementation

There were no Arduino drivers for PAC1943 (though maybe now there are) when the project started, so it was necessary to adapt libraries from other power meters from Microchip to implement the low-level I2C communication. The result was a compact Arduino driver for USB Insight Hub.

The PAC1943 is configured to use an 8-samples, rolling average filter which reduces offset and noise effects. From the ESP32 side, it reads the three channels every 40 ms (25 Hz) and applies a 10-samples average filter. This provides smoother reading in the displays.

Further Enhancements

To monitor current and voltage, the system works well, but that in no way means it is perfect. Additional optimizations in the digital filtering process can be implemented to improve the value visibility on screen. The good part, though, comes with the possible addition of power monitoring features: PAC1943 calculates and accumulates power readings at a high rate of 1024 SPS without microcontroller intervention. This is useful to evaluate total power consumption or measure the real battery capacity of a device.

Also, the exposure of current, voltage, and power through the serial API (and a REST-API within the Web Server) could allow USB Insight Hub to act as a data logger for USB devices. The hardware is capable, so we hope there is time before the shipment of the hardware to develop and add these features; in the worst case, a future firmware upgrade can do the job.

I’d love to hear your comments or questions via the campaign contact form.

Regards,
David S


Sign up to receive future updates for USB Insight Hub.

Subscribe to the Crowd Supply newsletter, highlighting the latest creators and projects