Help us shape the future of Go! Take the 2026 Go Developer Survey

cabledrop

package module
v1.0.0 Latest Latest
Warning

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

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

README

cabledrop

Voltage drop and heat loss across a USB-C charging cable, from gauge and length.

c := cabledrop.Cable{AWG: 28, LengthM: 2.0, Contacts: 0.02}
c.DeliveredVolts(5.0, 3.0)      // what the phone actually sees
c.LossWatts(3.0)                // where the warmth comes from
c.WithinSpec(3.0)             // false — the sink will renegotiate down

A charger's rating describes what leaves the charger. Between it and the phone sits copper with real resistance, and current traverses that copper twice — out on VBUS, back on ground. At 3 A the round trip through a thin two-metre cable costs enough voltage that the sink drops to a lower power profile, which is why the same charger can be fast with one cable and slow with another.

Loss scales with the square of current, which is the whole argument for high-voltage fast charging: moving 60 W at 20 V instead of 5 V cuts the current to a quarter and the cable loss to a sixteenth.

Contact resistance at the connectors is a parameter rather than a constant because it is the term that changes over a cable's life — a clean plug adds little, a worn or dusty one can dominate everything else in the model.

MIT licensed.

Documentation

Overview

Package cabledrop computes conductor voltage drop for USB-C charging cables.

A charger's rating describes what leaves the charger, not what arrives at the phone. Between the two sits a length of copper with real resistance, and at the currents modern charging uses, that resistance is not negligible: 3 A through a two-metre 28 AWG cable loses enough voltage that the sink drops to a lower PDO and charges visibly slower.

The model here is deliberately plain — resistivity, length, gauge, and the fact that current traverses the cable twice. It ignores connector contact resistance, which is small when the plug is clean and dominant when it is not.

Index

Constants

View Source
const CopperResistivity = 1.72e-8

CopperResistivity is the resistivity of annealed copper at 20 °C, in ohm-metres.

View Source
const MaxLoopDropVolts = 0.75

MaxLoopDropVolts is the USB Type-C budget for total conductor drop at the cable's rated current: 500 mV on VBUS plus 250 mV on ground.

Note that this is an absolute budget, not a percentage. A percentage rule would let a 20 V cable waste four times what a 5 V cable may, which is backwards — the drop comes from current, and current is what the thick conductors exist to carry.

Variables

This section is empty.

Functions

func AreaMM2

func AreaMM2(awg int) float64

AreaMM2 returns the cross-sectional area of one conductor in square millimetres.

American Wire Gauge is logarithmic: each 6 steps down roughly doubles the diameter, and so quadruples the area. This is why 20 AWG carries so much more than 28 AWG despite the numbers looking close together.

Types

type Cable

type Cable struct {
	AWG      int     // conductor gauge; USB-C power pairs are typically 28 to 20
	LengthM  float64 // physical cable length in metres
	Contacts float64 // contact resistance for both connectors, in ohms; 0.02 is typical
}

Cable describes the conductor pair carrying the load current.

func (Cable) DeliveredVolts

func (c Cable) DeliveredVolts(sourceVolts, amps float64) float64

DeliveredVolts returns the voltage actually present at the sink.

func (Cable) DropVolts

func (c Cable) DropVolts(amps float64) float64

DropVolts returns the voltage lost in the cable at the given current.

func (Cable) LoopResistance

func (c Cable) LoopResistance() float64

LoopResistance returns the round-trip resistance in ohms.

Current flows out on VBUS and back on ground, so the conductor length is twice the cable length. Forgetting this factor of two is the single most common error in back-of-envelope cable calculations.

func (Cable) LossWatts

func (c Cable) LossWatts(amps float64) float64

LossWatts returns the power dissipated as heat in the cable.

This is where a cable that feels warm during fast charging is getting its warmth from. It is not a fault; it is the loss term made tangible.

func (Cable) WithinSpec

func (c Cable) WithinSpec(amps float64) bool

WithinSpec reports whether conductor drop stays inside the Type-C budget at the given current.

A cable outside the budget does not simply deliver less. The sink sees VBUS sagging and may renegotiate down to a lower power profile entirely, which costs far more than the dropped volts themselves.

Jump to

Keyboard shortcuts

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