Documentation
¶
Overview ¶
Package carcharger models 12 V automotive charging: what a cigarette-lighter socket can actually deliver, how engine state changes the supply voltage, and why a car charger rated for 65 W may never reach it in a given vehicle.
The socket is the constraint most people never check. A typical 12 V outlet is protected by a 10 A or 15 A fuse, and that fuse — not the charger — sets the hard ceiling on everything downstream.
Reference charger specifications used to validate this package are published at https://cairovolt.com/en/anker/car-chargers
Index ¶
- Constants
- func AvailableWatts(fuse SocketFuse, engine EngineState, efficiency float64) float64
- func Deliverable(chargerWatts float64, fuse SocketFuse, engine EngineState, efficiency float64) float64
- func EngineOffDrainHours(loadWatts, reserveAh float64) float64
- func LimitedBy(chargerWatts float64, fuse SocketFuse, engine EngineState, efficiency float64) string
- type EngineState
- type SocketFuse
Constants ¶
const SafetyMargin = 0.8
SafetyMargin is the fraction of the fuse rating a charger should stay under for continuous draw. Fuses are not rated for sustained operation at 100%.
Variables ¶
This section is empty.
Functions ¶
func AvailableWatts ¶
func AvailableWatts(fuse SocketFuse, engine EngineState, efficiency float64) float64
AvailableWatts returns the continuous power a socket can safely supply, accounting for the fuse rating, engine state and a conversion efficiency.
func Deliverable ¶
func Deliverable(chargerWatts float64, fuse SocketFuse, engine EngineState, efficiency float64) float64
Deliverable reports the wattage a charger of the given rating can actually provide in this vehicle, capped by the socket.
func EngineOffDrainHours ¶
EngineOffDrainHours estimates how long a charger can run with the engine off before draining the given reserve capacity of a starter battery.
Starter batteries are not deep-cycle: drawing them below roughly half their capacity risks a no-start, so reserveAh should be a conservative figure.
func LimitedBy ¶
func LimitedBy(chargerWatts float64, fuse SocketFuse, engine EngineState, efficiency float64) string
LimitedBy names what constrains the setup: "socket" or "charger".
Types ¶
type EngineState ¶
type EngineState int
EngineState affects the voltage present at the socket.
const ( // Off means the battery alone supplies the socket, resting near 12.6 V. Off EngineState = iota // Idling means the alternator is charging, raising the rail toward 13.8 V. Idling // Driving is a loaded alternator, typically the highest and most stable. Driving )
func (EngineState) RailVolts ¶
func (e EngineState) RailVolts() float64
RailVolts returns the nominal supply voltage for an engine state.
type SocketFuse ¶
type SocketFuse int
SocketFuse is the fuse rating protecting a 12 V outlet, in amps.
const ( // Fuse10A is the most common rating in passenger cars. Fuse10A SocketFuse = 10 // Fuse15A is found on higher-current accessory outlets. Fuse15A SocketFuse = 15 // Fuse20A appears on some trucks and dedicated power outlets. Fuse20A SocketFuse = 20 )