Battery Simulator

class Nets.Battery

Class for controlling power traces with a supply

setup_battery(
sim_mode=None,
soc=None,
voc=None,
voltage_full=None,
voltage_empty=None,
current_limit=None,
capacity=None,
model=None)

Setup battery output on trace. In Dynamic mode the battery will discharge or charge according to a modeled charge/discharge curve. In Static mode the battery will remain at its initial SOC.

from lager import Net, NetType, SimMode

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
v_bat.setup_battery(
    sim_mode=SimMode.Dynamic,
    soc=50,
    voc=None,
    voltage_full=4.2,
    voltage_empty=3.0,
    current_limit=1.0,
    capacity=1.5)
v_bat.enable()
Parameters:
  • sim_mode (SimMode) -- Simulation mode for battery output

  • soc (float) -- State of Charge of battery in Volts

  • voc (float) -- Open circuit battery voltage in Volts

  • voltage_full (float) -- Voltage at 100% SOC in Volts

  • voltage_empty (float) -- Voltage at 0% SOC in Volts

  • current_limit (float) -- Max charge/discharge current in Amps

  • capacity (float) -- Battery capacity in Ah

voltage()

Query real-time battery voltage

from lager import Net, NetType

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
voltage = v_bat.voltage()
print(voltage)
Returns:

real time battery voltage in Volts

Return type:

float

current()

Query real-time battery current

from lager import Net, NetType

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
current = v_bat.current()
print(current)
Returns:

real time battery current in Amps

Return type:

float

esr()

Query Equivalent Series Resistence

from lager import Net, NetType

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
esr = v_bat.esr()
print(esr)
Returns:

Equivlanet Series Resistance

Return type:

float

soc()

Query State Of Charge

from lager import Net, NetType

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
soc = v_bat.soc()
print(soc)
Returns:

State Of Charge

Return type:

float

capacity()

Query remaining battery capacity

from lager import Net, NetType

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
capacity = v_bat.capacity()
print(capacity)
Returns:

battery capacity

Return type:

float

capacity_limit()

Query remaining max battery capacity

from lager import Net, NetType

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
cap_limit = v_bat.capacity_limit()
print(cap_limit)
Returns:

battery capacity

Return type:

float

mode()

Query simulation mode.

from lager import Net, NetType

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
mode = v_bat.mode()
print(mode)
Returns:

simulation mode

Return type:

SimMode

model()

Get battery model in use.

from lager import Net, NetType

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
model = v_bat.model()
print(model)
Returns:

model

Return type:

str

voltage_full()

Get voltage at 100% charge.

from lager import Net, NetType

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
volt_full = v_bat.voltage_full()
print(volt_full)
Returns:

voltage

Return type:

float

voltage_empty()

Get voltage at 0% charge.

from lager import Net, NetType

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
volt_empty = v_bat.voltage_empty()
print(volt_empty)
Returns:

voltage

Return type:

float

current_limit()

Get maximum discharge current.

from lager import Net, NetType

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
curr = v_bat.current_limit()
print(curr)
Returns:

current

Return type:

float

terminal_voltage()

Get real-time terminal voltage.

from lager import Net, NetType

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
tvolt = v_bat.terminal_voltage()
print(tvolt)
Returns:

voltage

Return type:

float

set_over_current(over_current)

Set maximum over current on given net

from lager import Net, NetType

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
v_bat.set_over_current(0.8)
Parameters:

over_current (float) -- Maximum over current on net in Amps

set_over_voltage(over_voltage)

Set maximum over voltage on given net

from lager import Net, NetType

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
v_bat.set_over_voltage(4.4)
Parameters:

over_voltage (float) -- Maximum over voltage on net in Volts

ovp_level()

Get over voltage protection limit.

from lager import Net, NetType

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
ovp = v_bat.ovp_level()
print(ovp)
Returns:

voltage

Return type:

float

ocp_level()

Get over voltage protection limit.

from lager import Net, NetType

v_bat = Net.get('VBAT',
            type=NetType.Battery,
            setup_function=setup_net,
            teardown_function=teardown_net)
ocp = v_bat.ocp_level()
print(ocp)
Returns:

current

Return type:

float

class Nets.SimMode(enum)

Battery simulation modes.

Static
Dynamic