The internal layout of all USB-PD sniffers is quite similar. A microcontroller acts as the control center (interfacing with the data monitoring host and tapping into the CC lines). Power monitoring ADCs (TI INA family in most cases) are placed on the VBUS and VCONN lines after placing a shunt resistor in the path. These INA chips interface with the microcontroller over an I2C bus. The schematic for the Twonkie 2.0 (a Twinkie clone with updated components that is easier to prepare for DIY folks) is reproduced below.
Twonkie 2.0 Schematic - STM32F072 + 2x INA237 + 2x 12 mOhm Shunt Resistors
The Google Twinkie / USBC-TKEY differs only slightly from the above schematic, with 2x INA231 power monitoring ADCs in place of the 2x INA237. There are multiple resistors in the CC observation path, and these enable the placement and removal of the Rp / Ra / Rd from the Twinkie's CLI. The STM32F072 microcontroller has a Cortex-M0 CPU running at 48 MHz, 128KB of flash memory, and a 16KB SRAM.
The ChargerLAB KM003C's structure is likely to be similar to the above. Based on the photograph of the KM002C's PCB (the KM003C is an updated version with a larger screen, gravity sensor, and a supercapacitor), the main differences appear to be the use of a Huada HDSC HC32F460 microcontroller, multiple INA228 ADCs, and 20 mOhm shunt resistors.
KM002C PCB, with the TI INA228 ADC boxed in red
The HC32F460 is a highly advanced microcontroller compared to the STM32F072. It has a Cortex-M4 CPU (with floating point support) running at 200 MHz, 512KB of flash memory, and 192KB of SRAM. This allows the implementation of a fairly complicated user interface with built-in real-time graphing capabilities - features that are not present in the original Twinkie design. We believe that the KM003C includes at least 5 ADCs in order to measure the voltage on both CC lines as well as the D+ and D- lines (in addition to the VBUS). Voltage measurement on the D+ / D- pins is apparently necessary in order to detect and support custom fast-charging protocols, as indicated in the table below from the KM003C's user manual.
One of the bugs in the KM003C hardware design that has been acknowledged by ChargerLAB is the absence of support for USB 2.0 data passthrough. It is likely that the voltage monitoring on these lines for fast charging protocol detection purposes is breaking the data lines for normal operation. It is an unfortunate side-effect that hopefully gets fixed by ChargerLAB in the next hardware iteration.
On-Device Interface
Moving on to the external hardware aspects, the KM003C is equipped with a vibrant 240 x 240 1.54" IPS screen and four physical push buttons. These allow the user to navigate through the various on-screen options for activation of different features, and also include special signals to modify certain settings quickly (such as a long press on the 'Confirm' button to alter the sampling rate when the dashboard screen is active). The gallery below presents the various features available via the device screen.
After power up (and showing an optional startup image set up through the PC software), the screen lights up with the dashboard that provides important information at a glance - the voltage, current, and power consumption inferred from the parameters on the VBUS line, the charging protocol (if applicable), and voltages on the CC and D+/D- lines. The next interface is the application screen from which the charging protocol support detection can be triggered. This involves ensuring stable power supply through the HID port and connecting the Type-C male port to the power supply of interest. The female port should be left unconnected. Under this option in the interface, it is possible to trigger cable simulation (by selecting 'No e-marker'), request for a specific PD type (after selecting 'Auto'), and scan for different charging protocols support. Yet another option under the application screen is 'Modules'. Under this, various value-adds such as USB-C cable e-marker reading, and Apple charger genuineness checking are currently available. ChargerLAB plans to add testing for cable resistance also in the future.
Under the Settings screen, the display brightness and startup screen can be adjusted. Storage management options are also available. Language settings (Chinese or English) and device information, as well as the option to reset all settings to default can all be accessed from the same screen.
The real-time curves interface allows the user to view the voltage / current on the VBUS line, or the voltages on the D+ / D- lines, or the voltages on the CC1 / CC2 lines as a function of time. The screen also helpfully notes the sampling rate on the top left corner. The data storage interface records the charge and energy values from the INA ADC chip for the VBUS line. The save interval is configurable and the starting and stopping of the recording can be triggered based on the current in the line. Up to 40 different data sets of 10000 points each can be stored in the 4MB of memory available in the device.
PC Software Features
ChargerLAB provides a Windows application that can be used to manage multiple USB power testers from a single pane. Our evaluation was with a single KM003C in the list, which is displayed on the left in the interface. The application starts up with a 'Data Recorder' view. The top part of this view has all the parameters present in the on-device screen's dashboard interface, while the bottom part has a real-time chart (with the available parameters on either side of the title). On the right side, a button to trigger the chart updates is available. The sampling rate can also be adjusted. Available rates are 1, 10, 50, and 1000 samples per second. The cache depth on the PC side is also configurable.
The software interface language can be modified from the triangular drop down on the top right near the window controls. However, some options continue to remain in Chinese even after the language is set to English. However, the software is intuitive enough for that to not be too much of a concern. The device firmware, as well as the application itself, can be updated from within the program. The 'PD Analyzer' view shows a real-time view of the various voltages and currents, along with a tabular view of the PD handshake process. Various other options such as saving graphs, recording data to a CSV or SQLite DB on the PC, etc. are available, as shown in the gallery above.
Open APIs
The Windows application is closed-source, but ChargerLAB provides some documentation in their HID Demo archive. The document is in Chinese, but I used Google Translate to get an inkling of the contents. From previous reviews, I have found that links often go stale. In order to avoid that with the KM003C API description, a screenshot of the translated version is provided below.
Click for a higher-resolution version of the API document
It is possible that ChargerLAB might update the APIs in the future. In that case, the latest version can be obtained from the FAQ section on their support page. ChargerLAB states there are three interfaces available - as a WinUSB (vendor specific interface) device, a HID device, or a virtual serial port (CDC). The next couple of sections take a look at how these interfaces can be taken advantage of in different operating systems.
ncG1vNJzZmivp6x7orrAp5utnZOde6S7zGiqoaenZH55hZNtZq6rkph6sbvWnqlmpZWpsrO1zaBksKGknXq1tMRmmqGZopyys7jAm2SkpWBlgKR5wGaeqKeXobJuwNaipaShlWKurcDEq6WarJmrsnB%2B