Skip to main content
Simulate battery behavior to test your DUT’s response to various charge levels, voltages, and protection events.

Import

Methods

The Net-based API provides methods that can either get or set values. When called without a value parameter, methods read and print the current value. When called with a value, they set it.

Method Reference

Net.get(name, type=NetType.Battery)

Get a battery simulation net by name.
Parameters: Returns: Battery simulation Net instance

set_mode_battery()

Initialize the instrument for battery simulation mode.

mode(mode_type=None)

Set or read the battery simulation mode.
Parameters:

soc(value=None)

Set or read the state of charge.
Parameters:

voc(value=None)

Set or read the open-circuit voltage.
Parameters:

voltage_full(value=None) / voltage_empty(value=None)

Set or read the full/empty battery voltages.

capacity(value=None)

Set or read the battery capacity. Must be greater than 0. The instrument can clamp the value to its supported range. It prints a warning when the applied value differs from the requested value.

current_limit(value=None)

Set or read the maximum charge/discharge current. Range: 0.001 A to 6.0 A (Keithley 2281S).

ovp(value=None) / ocp(value=None)

Set or read protection thresholds.

model(partnumber=None)

Set or read the battery model.
Keithley 2281S Battery Models: The Keithley 2281S stores battery models in memory slots (0-9): Note: If a slot is empty, the call raises an error. The error tells you to use 'discharge', or to save a model first from the instrument front panel or with define_model() below. Use 'discharge' for basic battery simulation that works on all instruments.

model_catalog()

List the battery models available on the instrument. Returns a list covering the numbered memory slots plus any firmware built-in models. Read-only — assembling the catalog does not change instrument state.
On the Keithley 2281S, slots 1-9 are reported when a model occupies the slot. The five firmware built-in models are listed without a slot. Discharge mode is not listed, because it is front-panel-only and has no SCPI recall form on current firmware.

read_model(slot)

Read a saved model’s curve points out of a memory slot. Returns a dict. Read-only — exporting a model does not change which model is active.
On the Keithley 2281S, slots 1-9 hold saved models, and there is no exportable slot 0. Each model is 101 points per element, for both VOC and resistance. A read of an empty slot is rejected, with a pointer to model_catalog().

define_model(slot, voc, resistance)

Write a custom battery model into a memory slot, creating or overwriting it. A model is two curves indexed by state of charge: voc (non-decreasing) and resistance.
A save to an occupied slot overwrites it silently. You cannot afterwards delete or empty a slot, because the Keithley 2281S has no SCPI command for it. A slot can only be overwritten. Gate overwrites behind an explicit confirmation in your own code. Valid target slots are 1-9.

enable() / disable()

Enable or disable battery simulation output.

clear_ovp() / clear_ocp()

Clear protection faults.
Print comprehensive battery simulator state.

terminal_voltage() / current() / esr()

Read measurements (return values, don’t print).
Returns: float - Measurement value

Examples

Basic Battery Simulation

Simulate Battery Discharge

With Protection Monitoring

Supported Hardware

Notes

  • Call set_mode_battery() before using other battery methods
  • Methods like soc(), voc(), etc. can get or set values depending on whether a value is passed
  • soc() values are rounded to the nearest integer before being sent to the instrument
  • Use mode('static') for fixed parameters, mode('dynamic') for evolving behavior
  • Always call disable() when finished
  • terminal_voltage(), current(), and esr() return values (for use in code)
  • print_state() prints values (for debugging)
  • Protection thresholds help prevent damage to your DUT
  • Keithley 2281S limits: 0-20 V output, 0.001-6.0 A current, capacity must be > 0
  • OVP range: 0-60 V; OCP range: 0.001-6.0 A