chargertestbench

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 2 Imported by: 0

README

chargertestbench

The measurement maths behind charger and power bank bench testing: turning raw meter samples into figures worth publishing, and rejecting runs that are not valid.

Install

go get github.com/taysirco/chargertestbench

Usage

import "github.com/taysirco/chargertestbench"

run := chargertestbench.Run{
    RatedWatts:     65,
    AmbientCelsius: 24,
    Samples: []chargertestbench.Sample{
        {Seconds: 10,   Volts: 20,   Amps: 3.25},
        {Seconds: 700,  Volts: 19.8, Amps: 2.6},
        {Seconds: 1200, Volts: 19.8, Amps: 2.55},
    },
}

run.PeakWatts()        // 65 — what a short test would report
run.SustainedWatts()   // ~50.5 — what the charger actually holds
run.ThrottlePercent()  // ~22%
run.MeetsRating(10)    // false
run.Valid()            // true — soaked and ambient recorded

Peak is not the number that matters

A charger measured cold will report its rating. The same unit after ten minutes under load often will not. SustainedWatts takes the median after thermal soak, which is the figure that describes real use — charging a laptop for an hour, not for ten seconds.

The gap between the two is ThrottlePercent, and it is the single most useful number a bench test produces. A unit that peaks at 65 W and settles at 50 W is a 50 W charger with a good first impression.

Why runs get rejected

Two conditions make a measurement uncomparable, and the package refuses to treat them as publishable:

  • No thermal soak. Numbers from a cold unit overstate sustained capability.
  • No ambient temperature recorded. Thermal behaviour is meaningless without knowing the room it was measured in — the same charger throttles differently at 20 °C and 35 °C.

Voltage ripple is also measured only after soak, since a device's own regulator has to absorb whatever variation the charger produces under real thermal load.

License

MIT

Documentation

Overview

Package chargertestbench provides the measurement maths behind charger and power bank bench testing: converting raw meter samples into the figures worth publishing, and rejecting runs that are not valid.

A single wattage reading proves very little. What matters is sustained output after thermal soak, ripple under load, and whether the test conditions were controlled enough for the number to mean anything.

Index

Constants

View Source
const ThermalSoakSeconds = 600

ThermalSoakSeconds is how long a charger must run before its output is considered settled. Measurements before this reflect a cold unit and overstate sustained capability.

Variables

This section is empty.

Functions

This section is empty.

Types

type Run

type Run struct {
	RatedWatts float64
	Samples    []Sample
	// AmbientCelsius is the room temperature the run was conducted at.
	AmbientCelsius float64
}

Run is a complete bench test.

func (Run) MeetsRating

func (r Run) MeetsRating(tolerancePercent float64) bool

MeetsRating reports whether sustained output is within tolerance of the rating.

func (Run) PeakWatts

func (r Run) PeakWatts() float64

PeakWatts is the highest instantaneous power in the run.

func (Run) SustainedWatts

func (r Run) SustainedWatts() float64

SustainedWatts is the median power after thermal soak — the figure that actually describes what a charger delivers in use.

func (Run) ThrottlePercent

func (r Run) ThrottlePercent() float64

ThrottlePercent is how much output falls from peak to sustained. A large gap means the charger cannot hold its rating once warm.

func (Run) Valid

func (r Run) Valid() bool

Valid reports whether the run is long enough and controlled enough to publish. Runs that never reached thermal soak, or that lack an ambient reference, produce numbers that cannot be compared against anything.

func (Run) VoltageRipplePercent

func (r Run) VoltageRipplePercent() float64

VoltageRipplePercent is peak-to-peak voltage variation after soak, relative to mean voltage. High ripple stresses a device's own regulator.

type Sample

type Sample struct {
	// Seconds since the load was applied.
	Seconds float64
	Volts   float64
	Amps    float64
	// CelsiusCase is the charger's external case temperature, if instrumented.
	CelsiusCase float64
}

Sample is one reading from an inline USB power meter.

func (Sample) Watts

func (s Sample) Watts() float64

Watts is instantaneous power for the sample.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL