Present a programmable battery to your DUT: set capacity, open-circuit voltage and
state of charge, then watch how firmware behaves as the pack drains.
Handle
Methods
Types
BatteryMode
Static holds the state of charge where you set it. Dynamic lets it evolve with
the load current, which is what you want when testing a real discharge curve.
BatteryState
Method Reference
init_battery_mode() -> Result<()>
Put the instrument into battery-simulator mode.
Call this first, before any other battery method, on an instrument that also
serves a power-supply net. A Keithley 2281S is a supply until told otherwise, and
the battery setters have nothing to act on until it is switched over.
set_soc(percent: f64) -> Result<()>
Set state of charge, 0 to 100.
set_voc(volts: f64), set_volt_full(volts: f64), set_volt_empty(volts: f64)
Open-circuit voltage, and the voltages the model treats as full and empty.
set_capacity(amp_hours: f64) -> Result<()>
Pack capacity in amp-hours.
set_current_limit(amps: f64) -> Result<()>
Output current limit.
set_model(partnumber: &str) -> Result<()>
Load one of the instrument’s predefined battery models.
set_mode(mode: BatteryMode) -> Result<()>
Switch between Static and Dynamic.
enable() -> Result<()> and disable() -> Result<()>
Turn the simulated pack’s output on or off. Disable in teardown.
state() -> Result<BatteryState>
Everything in one transaction. As with a supply, there are no individual getters.
Examples
Check the low-battery warning fires at the right threshold
Supported Hardware
Notes
set_voc() is a request, not an assignment. The instrument derives terminal
voltage from the loaded model and the state of charge. On a Keithley 2281S with the
LI_ION4_2 model, setting SOC to 50 moved voc to about 4.007 V regardless of an
earlier set_voc(3.7). Read state() to learn what the pack is actually presenting.
- A battery net and a power-supply net can share one physical instrument. Switching
to battery mode changes what that instrument is for both, and the box serializes
them under a single per-instrument lock.
state() returning Ok does not mean the instrument answered — check error,
which is populated when the gather itself failed.
esr is the model’s equivalent series resistance, which is what makes terminal
voltage sag under load rather than tracking open-circuit voltage exactly.