# PowerChecker-KM003C

[日本語](README.md) · [Open the web app](https://pd240lab.com/km003c/?lang=en)

PowerChecker reads advertised USB-PD capabilities and records voltage/current using a POWER-Z KM003C. It creates shareable reports and supports PD voltage requests and PPS / AVS sweeps. Browser mode needs no CLI, Python or local server installation.

## Language

Use **日本語 / English** at the top of the page. The first visit follows your browser language; your selection is saved and shared with the USB PD EPR 240W Lab homepage on the same origin. You can also link to `?lang=ja` or `?lang=en`.

Switching language does not disconnect the device, reset the selected PDO, change the test confirmation, send commands or resume a paused sweep. UI messages and PNG / Markdown / HTML reports use the selected language. User-entered names and notes, device commands, raw communication logs, JSON backup data and CLI-compatible CSV column names are preserved.

## Direct browser connection

1. Open the HTTPS app in a browser supporting WebUSB, Web Serial and/or WebHID, such as desktop Chrome or Edge. Local development pages can use localhost.
2. Connect the KM003C to the PC using its PC-side USB connection. Turn your external electronic load off or set a low current before querying PDOs.
3. Press **Connect KM003C and query PDOs + numbers** and select its USB interface. Press **Continue** and select the Serial port belonging to the same KM003C.
4. The app initializes PD over Serial while recording USB. It waits for two matching Serial PDO lists and matches actual USB Source Capabilities before assigning object numbers.
5. Check **Observed PDOs**. If matching fails, Serial capabilities are still displayed; object numbers are never inferred from displayed row order. Retry the normal query or inspect the saved raw response and communication log.

Manual HID / USB / Serial selection is under advanced settings. HID supports measurement. USB supports PD packets, object numbers and voltage/current on the device clock. Serial supports initialization, PDO replies and PD control. Windows may require WinUSB for vendor interface 0 to use USB logging; HID measurement and Serial control use separate interfaces.

## Recording and importing

**Record PD protocol + voltage/current** records USB PD traffic together with voltage/current on the same device clock. **Measure voltage/current** uses the selected measurement interface. Choose a duration (1–120 seconds) or **Continue until Stop is pressed**. These choices apply to recording and measurement, not to PDO queries or sweeps.

Recordings stop at 200,000 PD events or measurement samples. Interrupted or failed acquisitions can still be exported as partial data. Reconnect the charger while recording to help capture Source Capabilities. Physically connect or disconnect other ports to observe power allocation changes.

Import supported CLI PD CSV, scope CSV, live-status CSV, records.jsonl, or a PowerChecker JSON backup. PD CSV and scope CSV from the same session can be imported together. Separately acquired host-clock and PD-clock measurements cannot be correlated. JSON backups are imported individually. Total import size is limited to 25 MB.

## PD control and EPR

Use a test setup with cables, connected devices and a load rated for the requested voltage. The **Shared PD control confirmation** is required for actual voltage/current requests and sweeps. For sweeps, verify the entire voltage range. Changing request or sweep settings clears confirmation and requires checking it again. Command previews do not require confirmation.

1. Query PDOs on the current connection. Imported logs cannot supply control capabilities.
2. Start with **Preview commands without sending** enabled. Select a Fixed, PPS, SPR AVS or EPR PDO and inspect the command.
3. For actual operation, disable command preview and confirm the test setup. The app reinitializes PD and rechecks advertised capabilities before requesting voltage.

Enable **EPR (up to 48 V)** to show acquired EPR PDOs. Before actual sending, acquire capabilities using the EPR profile or use **Configure EPR (PD 3.1)**. USB-acquired EPR PDOs retain their verified object numbers; EPR reserved slots are not compacted. Never leave ordinary 5 V-only devices connected when requesting high voltage.

For Serial-only capabilities, enter an object number independently verified on the KM003C display or in USB logs. The displayed row number is not necessarily the object number.

Requested current is a negotiation value, not a setting for your external electronic load. A successful send or an `ok` reply does not establish negotiated voltage or actual output. Verify VBUS by measurement. Unchecking EPR does not restore voltage. When finished, reset the trigger or close PDM and verify the voltage.

## PPS / AVS sweeps and load preparation

Select a PPS / AVS PDO and specify start voltage, end voltage, step and hold time. The sweep uses the requested current above and validates every point against the PDO’s voltage/current limits, including SPR AVS current bands and EPR AVS PDP. The step must divide the range exactly; at most 500 points are allowed, including the return trip.

**Request start voltage and wait for load preparation** is enabled by default, equivalent to CLI `--pause-before-sweep`. The app first requests the start voltage, then waits. Verify actual VBUS, set the external load, and press **Load is ready — continue sweep**. No sweep points run until you continue. Stop is available while waiting. Disable the option only when preparation waiting is unnecessary.

Optional measurement uses HID / USB. With USB connected, PD traffic can be recorded during the sweep. The app does not change external load current. On completion, cancellation or failure, it ends recording, resets the trigger and closes PDM. Inspect cleanup replies and voltage. A successful single voltage request maintains its requested state until you reset or close PDM.

## Reports, CSV and transition analysis

PD control provides the same shared equipment/load confirmation immediately before both voltage requests and sweeps. Changing the PDO, voltage, current, sweep settings or connections clears all copies and shows a reason beside the action. Confirm again there without returning to the top. Confirmation cannot be changed while an operation is running or waiting for load preparation.

The automatic **Analyze PPS / AVS voltage transitions after recording** setting is in the **Voltage transition analysis** results panel, linked from recording and sweep controls. It runs after PD recording or a sweep with PD recording ends; existing logs use **Analyze this recording**. The decoder supports SPR PPS, SPR AVS and EPR AVS and requires PD traffic and voltage samples on the same device clock. SPR requests are resolved against preceding Source Capabilities, including SPR PDOs in completed extended/chunked EPR capabilities. Missing PDO context is reported, never guessed using future capabilities or control selections.


Enter the charger name, this port’s rated output, port name (default C1), cable/load/other-port notes, and VBUS-drop threshold. The app compares a single port’s advertised capabilities with that port’s rating, not a charger’s combined multiport rating. Save states to compare the latest acquired capability sets.

PNG / Markdown / HTML reports include conditions, observations, PDOs, VBUS drops and unassessed items. Synthetic demo reports are clearly marked. JSON is a backup of source data and state. User text is escaped in HTML and Markdown exports.

PD CSV uses the CLI’s 15 Utility-compatible columns. Its historical `Vbus(V)` column stores integer mV. Scope CSV uses the CLI’s 19 columns. Device timestamps and raw measurements are retained. Unavailable CRC/EOP verdicts, duration and delta remain blank. The visible PD table shows the last 200 messages; CSV contains all messages, including hidden GoodCRC.

USB PD recording and its paired scope CSV share a device clock. Sweep ADC samples use a relative host clock and must not be mixed with USB PD timestamps as if they shared a clock.

PPS / AVS transition analysis requires PD and voltage/current from the same USB recording. Analyze after recording, or enable automatic analysis on completion. Criteria match CLI `capture --scope --analyze-transitions`: target settling uses ±1% for 80 ms; observed-plateau settling uses ±0.5% for 80 ms. Movement requires two consecutive changes of at least 50 mV or six times noise MAD. Plateau detection requires 400 ms and at least six samples. Gaps over 100 ms prevent settling across the gap. Results are sampled estimates without interpolation. Fixed, Battery and Variable supplies are excluded. SPR support extends the Web analyzer; the CLI itself remains unchanged. Correlation stops at any subsequent REQUEST/EPR_REQUEST, reset or rejection. Existing detailed/summary CSV columns retain their order, with request kind, PDO number and Raw PDO appended (the detail CSV also adds the analysis window end).

Select a transition above the results table to plot measured VBUS, target ±1% and plateau ±0.5% bands, with request, ACCEPT, movement, PS_RDY and both settling markers. Switch between the transition detail and full analysis window without changing analysis results. **Transition plot PNG** exports the selected transition and range. Lines never bridge sample gaps over 100 ms. Short holds or small voltage changes may leave movement or plateau indeterminate. Browser recordings, paired PD + scope CSV imports and local CLI recordings use the same Web analysis. Host-clock sweep ADC CSV alone is insufficient.

Advertised capability is not verified output under load. Lower PPS current than fixed-PDO current alone does not establish a standards violation. This tool does not assess high-frequency ripple, disconnected-CC VBUS, safety, compatibility with specific devices or USB-PD compliance; those require separate measurements.

## Optional local CLI mode

Download **both** components:

1. The entire [KM003C-CLI repository](https://github.com/inuchanbt/KM003C-CLI), including `km003c_cli.py`, `km003c_modules/` and requirements. Follow its setup instructions.
2. The [PowerChecker local connection kit](https://pd240lab.com/downloads/PowerChecker-KM003C.zip), containing the web app, bridge and helpers. Extract it.

From the extracted `PowerChecker-KM003C` folder, run:

```powershell
python km003c/bridge.py --cli D:\KM003C\km003c_cli.py
```

Set `--cli` to your actual CLI path. Open the local URL shown, normally `http://127.0.0.1:8765/km003c/`, and select **Local CLI**. The CLI’s `.venv` interpreter is used automatically if available. The bridge itself uses only Python’s standard library; device dependencies and drivers belong to the CLI installation.

Leave the CDC port blank for automatic detection when one matching device is present. Specify a COM port or serial number for multiple devices. Your KM003C may use a different COM number than someone else’s device.

For a browser-only local preview, run `python -m http.server 8765 --bind 127.0.0.1` from the extracted folder. This static server does not provide CLI control; stop it before starting the bridge on the same port.
## Sweep CSV analysis

### Integrated stability, PD negotiation and hysteresis

Open a sweep CSV or an earlier analysis ZIP containing `normalized.csv`. Then choose **Add PD + scope from the same measurement** and select both paired CSVs, or a JSON backup containing the PD recording. Opening another sweep clears the association. New browser sweeps with PD recording attach their own recording automatically. Analysis stays in the browser and never sends device commands.

Early/late voltage means and drift (late minus early) use the first/last 20% of samples, at least two each. Fewer than four samples is unavailable. Monotonic elapsed time follows acquisition order; otherwise file order is used. Sample standard deviation includes drift, rather than representing random noise alone. A single ADC sample does not produce standard deviation or drift.

Set **Sweep PD request current mA** beside the sweep parameters. It shares its value with the voltage/current request field; changing either clears setup confirmation. Configure the external load separately. Signed current is retained; measured magnitude above `request + max(0.05 A, 5% of request)` triggers a warning. Lower load current is normal. This analysis threshold is not a USB PD compliance verdict.

Raw `request_status=sent_unverified` remains unchanged. Separate `pd_status` values are `confirmed` (corresponding Source ACCEPT followed by PS_RDY), `unconfirmed`, `rejected` (REJECT / NOT_SUPPORTED), and `deferred` (WAIT). Serial ready text and measured voltage alone do not establish negotiation. Replies cannot cross the next request/reset boundary. Identical re-requests within 50 ms with no earlier reply are grouped, using only the final transaction's own replies.

New browser CSVs retain a recording key and PD row bounds. Legacy CSVs use an explicitly supplied recording only when the complete ordered PDO kind/index, voltage and requested-current sequence matches uniquely (also checking raw PDO when recorded). Ambiguous matches and mismatched recording keys remain unconfirmed. No host/device clock offset is guessed. PD-only logs can verify replies, but steady statistics require scope samples on the same native device clock.

The native steady window starts after confirmed negotiation and plateau settling (observed voltage ±0.5% for 80 ms) plus 80 ms, and ends at the next request/reset boundary. Windows containing sample gaps over 100 ms are excluded. Mean, sample standard deviation, min/max, early/late means and drift are separate from sweep ADC statistics. The integrated table includes REQUEST Sno/device time, ACCEPT/PS_RDY delays and target/observed-plateau settling times. Plateau settling does not establish reaching the requested voltage.

Hysteresis pairs matching run, PDO, requested current, voltage, external-load conditions and round-trip cycle, plotting `return mean − outbound mean`. Both native steady means are used when available; otherwise both sweep ADC means are used, with the source shown as a separate series. Missing pass metadata does not produce a guessed cycle; a missing turning-point counterpart is not invented. Heating or other causes are not inferred.

HTML reports embed the integrated table and every applicable graph. ZIPs also contain `pd_checks.csv` and `hysteresis.csv`; JSON backups retain explicitly attached PD/scope data. Summary CSV exports all integrated columns. Tables show the first 500 points. ZIP input is capped at 100 MB; normalized.csv at 25 MB with CRC verification.

Results are readable directly on the page. All applicable graphs appear in a gallery; **View larger** selects a graph in the full-size view above. A formatted report with measurement conditions, statistics, errors and unmeasured items stays visible without opening a preview. **Analysis demo** shows clearly labeled synthetic data without connecting to a device or sending requests. Demo reports also carry the synthetic-data notice.

The **Sweep CSV analysis** panel ports the statistics from KM003C-CLI's `analyze_sweep_csv.py` 1.0.0 to the browser. Browser and local CLI sweeps are analyzed automatically when they finish. Use **Open sweep CSV** to inspect earlier KM003C or ASD-PD31 files without connecting a device or installing a CLI. Files are processed locally, without uploading them. The main log importer also recognizes sweep CSVs.

The analysis includes per-point mean/min/max, sample voltage standard deviation (n−1), voltage error and percentage error, current and signed power. Runs, modes, PDOs, requested PD currents and outbound/return legs remain independent. Failed/interrupted requests, rows with errors and missing/nonfinite measurements are excluded. The default filter prefers primary sweep modes and omits preconditioning/settling. Advanced settings select phases, comma-separated modes (including `avs`, `pps`, `hold` families) and an initial sample count to discard per group. If a phase/mode matches nothing, all valid rows are used with a visible warning, matching the Python fallback.

Voltage, external load-current and elapsed-time hold/AVS-sequence axes are recognized from CSV columns. Legacy ASD-PD31 column aliases and headerless files are supported. When measured ripple exists, the panel adds ripple averages, changes, voltage-normalized ripple and a largest-change candidate. Recorded module temperature adds temperature and ripple-vs-temperature plots. External thermocouple columns remain in normalized CSVs and reports. PD request current is not treated as a load setting. High-frequency ripple is never inferred from ADC scatter. Errors and ripple changes are observations, not compliance verdicts.

Export summary CSV, normalized CSV (the rows remaining after analysis filters), TXT/Markdown/HTML reports, or the selected plot as PNG. **Reports and all plots ZIP** includes Japanese and English TXT reports, HTML, both CSVs and every applicable plot PNG. JSON backups also save and restore the loaded sweep CSV and analysis settings.

Differences from Python: ripple-change candidates never bridge different runs, PDOs or requested currents; additional raw CSV columns are retained; entirely unmeasured plots are omitted. The table displays the first 500 grouped points. Graphs display up to 50 series and 2,000 points per series; CSVs retain all analyzed points. Limits: 25 MB and 200,000 CSV rows. Sweeps without ADC measurements cannot be analyzed.

New browser sweep CSVs include run, PDO and outbound/return metadata. Missing leg metadata in older CSVs is not reconstructed by guessing. Restart the updated `bridge.py` for local mode. The upstream MIT notice is included in `sweep-LICENSE.txt`.

Validation uses 12 independently generated Python reference cases, comparing statistics and selected rows. Browser tests use synthetic CSVs and mocked hardware, without real voltage requests. Regenerate references with `python tools/sweep_reference.py D:/KM003C/analyze_sweep_csv.py`; run statistics checks with `node --test km003c/tests/sweep.test.js`.

RDO fields were cross-checked against the [Linux USB PD header](https://kernel.googlesource.com/pub/scm/linux/kernel/git/gregkh/usb/+/5d5fd841c34649f1b09220fe58e59dffd61c447d/include/linux/usb/pd.h). Validation retains all 65 EPR reference cases and adds independently built SPR rising/falling waveforms, PDO updates, missing context, resets, rejection, extended capability chunks and sample gaps. Browser tests cover automatic analysis, CSV import, per-transition plots, PNG, language switching and mobile layout with mocked hardware only.

## PD-Interpreter: log conversion and live conversations

Open PD CSV / records.jsonl in the PD-Interpreter panel to read charger and device conversations. USB PD + voltage/current recording updates the conversation while measuring; HID voltage/current measurements alone contain no PD packets. The 240W conversation demo is synthetic.

Six speaking styles, GoodCRC receipts, EPR keep-alive stamps, and standalone HTML / Markdown export are available. Conversion runs on your device, without Python or an API key. Exports retain all original packets. The Web decoder covers power negotiation; detailed Python field decoders are not all ported, and unsupported messages retain their originals. Missing KM003C integrity verdicts stay unreported.

Include `interpreter.js`, `interpreter-ui.js`, `interpreter-voice.js`, and `interpreter.css` alongside the other km003c assets when hosting.

For a simpler start, open the [standalone PD-Interpreter page](../pd-interpreter/). Demo, log import and live USB capture work without the full workbench. Original packets and receipts are hidden by default.

## Cable identity (SOP’)

**Read cable identity again** updates only the cable result, preserving previously acquired charger capabilities (including EPR) and measurement samples. The charger table is labelled as previously acquired; refresh charger information after changing connections. SPR capabilities and initialization samples from the cable query stay in a separate communication record rather than entering the charging measurement. JSON backups and saved sessions retain this distinction. Captive and other cables may not return identity information; missing identity does not establish a fault.

Click **Read cable identity** in the connection panel. Select USB, then click again to select Serial on the same KM003C. The query disables cable emulation (`em=0`), enters SPR PD, sends SOP’ Discover Identity (PD3 / SVDM2, with PD2 fallback), and always attempts `reset` → `pdm close`. Turn off the external load. The selected cable path must have VCONN power; reception depends on the connection and firmware.

The panel displays VID/PID, XID, bcdDevice, passive/active type, current rating, maximum VBUS voltage, EPR advertisement, USB speed and raw VDOs. Reserved/unknown layouts stay unknown. EPR is decoded for passive PD3 cable VDOs; active/legacy layouts retain raw VDOs and show unknown EPR. No reply, NAK, BUSY and incomplete identity are separate states. These are cable claims, not a load test or certification. USB logs and imported PD logs are decoded too; save JSON to retain the evidence.

CLI (updated KM003C-CLI):
```powershell
python D:\KM003C\km003c_cli.py cable --port COM3 --json-file cable.json
python D:\KM003C\km003c_cli.py cable --dry-run
```
The PowerChecker kit also works with an older CLI through the included adapter:
```powershell
python km003c/cable_cli.py D:\KM003C\km003c_cli.py --port COM3 --json-file cable.json
```
`--serial` selects the same device for USB and CDC. `--json-file` refuses existing files unless `--force` is supplied. The bridge calls this adapter, and keeps its one-operation-at-a-time and stop behavior.

## Autosaved sessions, Wh / mAh and low-current stop

Use the recording panel to name sessions. Browser PD capture / voltage-current measurements and local CLI recordings save incremental IndexedDB checkpoints about once per second by default. Open saved sessions to restore committed PD events, samples, test metadata and integration settings after reloads or unclean shutdowns. Unfinished sessions are labelled as partial and reopening them sends no device commands. Native USB frames and CLI raw files still use the existing raw-data download controls.

Storage belongs to this browser and site origin: the public HTTPS site and localhost do not share archives. Clearing site data or closing a private-browsing session may remove them. Export session JSON for long-term storage. A quota error or unavailable IndexedDB is shown explicitly; measurement can continue. Checkpoint timing is best effort and the latest uncommitted interval is not guaranteed.

Wh integrates sampled voltage times signed current; mAh integrates signed current. The trapezoidal rule operates on adjacent valid samples in acquisition order. Positive and negative flows are also reported separately; zero crossings are split. Intervals beyond the configured maximum gap (default 1 second), invalid readings, duplicate/reversed timestamps and clock changes are excluded. Integrated / excluded time and discontinuity counts are shown. Zero or one sample produces unavailable totals. Missing samples are never treated as zero. These measured-path totals do not establish internal battery capacity, charge completion or compliance.

Low-current stop defaults to OFF. Select below 5 / 10 / 50 / 100 mA and a hold duration. Only continuous valid samples with absolute current below the threshold and at least 4 V advance the timer. Gaps, invalid readings, clock changes, increased current and reduced VBUS reset it. Duration, manual stop or low-current stop ends the recording, whichever occurs first. It does not change power or the external load and does not apply to PDO acquisition, requests or sweeps.

Duration presets are 10 seconds, 1 minute, 15 minutes, 1 hour, 6 hours and 12 hours; custom durations accept 1–43200 seconds. Each recording stops at 200,000 PD events or 200,000 samples, including long recordings. The local CLI bridge monitors cutoff independently of the browser and writes raw files plus recording-summary.json under captures. Only incremental batches are sent to the page. Restart the bridge using bridge.py from the updated kit. Standalone CLI invocations do not automatically use these browser settings.

Session JSON and JSON backups can be imported individually up to 100MB. Other logs retain the combined 25MB limit. The 200,000-record bounds remain in place.

### PD search, field inspection and charging conditions

- Search the entire PD record, filter Control / Data / Extended / events and SOP, and browse 200 messages per page. CSV export is independent of filters.
- Select a message for header bits, Objects, extended headers, recorded wire bytes and original JSON. Cable SOP bits are not displayed as SOP roles. Missing CRC verdicts and raw bytes stay unknown.
- “Check charging conditions” offers “Is power cutting out?” and “Why is charging slow?” The conclusion, charger capability, recorded average power and next steps appear first. Detailed values, evidence and record/time selection are collapsible. Diagnostic evidence can be exported as JSON. Viewing diagnostics sends no device commands.
- Reading charger/cable information is distinguished from recording actual charging. An information query shows “Charging has not been measured yet”; voltage changes during initialization are not presented as charging problems. The recording shortcut only opens the controls and starts no acquisition. Record about 10 seconds while actually supplying power.
- Stability needs about 10 seconds (at least 9.5 seconds allowing endpoint sampling), 20 samples and 9 covered seconds. Missing data, reversed time and acquisition errors are disclosed. Variation above 5% and adjacent changes above max(0.25 V, 5% of the previous voltage) are review heuristics, not standards or high-frequency ripple tests.
- Sample mean / peak power and the maximum of the last PDO set in the same record are separate evidence. PDO capability does not establish requested power, battery state, temperature, load limits or charging speed. Host ADC and device PD timestamps are not aligned.

### Entry points, connection wizard and workspace modes

The initial page offers three entry points: connect a KM003C, explore a demo, or open a saved log. Relevant results appear when data becomes available. Demo data loads only when chosen and is explicitly marked as synthetic.

- Follow the wiring diagram: charger → test cable → IN, HID / PC port → PC, OUT empty and external load off. Click Allow USB, Allow Serial for the same meter, then Acquire PDOs + cable. Permissions alone do not start acquisition.
- “3. Read charger + cable information” queries PD 3.1 / EPR PDOs then SOP’ Discover Identity. The cable query stays a separate recording; original identity timestamps remain in source_timestamp_us and are not aligned with the PDO query clock. PDO results remain available when cable ACK is missing.
- Quick diagnosis is the default. It hides and blocks manual voltage requests, manual EPR operations and sweeps. PDO queries use PD 3.1 / EPR. PDO and cable acquisition initialize PD and exchange messages, so this is not a passive-only mode. Keep the external load off.
- Pro control & sweeps exposes EPR queries, manual requests, sweeps, detailed PD logs and transition analysis. Changing modes clears send confirmation and EPR opt-in and restores command preview. Modes cannot change during an operation; reloading returns to Quick diagnosis.
- Algorithms, missing-data handling and advertised-value limitations remain in “ⓘ Criteria & specifications.” Recording names, storage settings and low-current conditions are in “Adjust recording storage and stop conditions.” Operation guides, errors and Stop remain visible.

With no load, PDO acquisition waits up to 15 seconds beyond the initial ready response for additional EPR PDOs instead of stopping at the SPR menu. Two consecutive matching menus confirm stability. If replies stop at the deadline, ordinary acquisition retains the last confirmed menu with a warning; control revalidation does not use that fallback. Missing EPR does not establish lack of support. Advertised 28–48 V PDOs are capabilities, not voltage requests. EPR initialization uses the CLI settings type=2, em=2, sink=1; actual cable identity is queried separately through SOP’ with em=0.
