Battery Management Service

group Battery Management Service

Monitors and controls the CubeSat battery pack.

The BMS is responsible for:

  • pack voltage/current monitoring

  • temperature and health estimation

  • charge state determination

  • enabling/disabling charging/balancing circuits

  • protection and failsafe behavior

  • telemetry collection for upstream consumption

  • error state management by notifying redundancy manager

group Structures

Structures used by the Battery Management Service.

Defines

BATTERY_SERVICE_UID

Service Unique Identifier (16-bit). Used to construct unique Event IDs. “BA77” = BATT.

BATTERY_EVENT_FAULT_DETECTED
BATTERY_EVENT_SELF_CHECK_PASSED
BATTERY_EVENT_SELF_CHECK_FAILED
BATTERY_EVENT_CRITICAL_LOW
BATTERY_EVENT_CHARGING_CHANGE
BATTERY_EVENT_FULLY_CHARGED
BATTERY_EVENT_TELEMETRY

Enums

enum battery_event_id_t

Values:

enumerator BATTERY_FAULT_DETECTED

Published when a critical fault is detected. Payload: battery_status_t (Snapshot at time of failure)

enumerator BATTERY_SELF_CHECK_PASSED

Published when the battery management service passes its self-check. Payload: NULL.

enumerator BATTERY_SELF_CHECK_FAILED

Published when the battery management service fails its self-check. Payload: failure mode.

enumerator BATTERY_CRITICAL_LOW

Published when voltage drops below critical threshold. Payload: float (Current Voltage)

enumerator BATTERY_CHARGING_CHANGE

Published when charging starts or stops. Payload: bool (true = charging started, false = stopped)

enumerator BATTERY_FULLY_CHARGED

Published when battery reaches 100% SoC. Payload: NULL.

enumerator BATTERY_TELEMETRY

Periodic telemetry broadcast (e.g., every 10s or 1 min). Payload: battery_status_t.

struct battery_status_t
#include <battery_management.h>

Snapshot of system battery state.

This structure is returned by ::battery_get_status and is used internally by the BMS to make decisions.

Public Members

float voltage

Current pack voltage in volts

float current

Pack current in amps (+ = charging, - = discharging)

float temperature

Average pack temperature in C

float soc

State of charge (0-100%)

float soh

State of health estimate (0-100%)

bool charging

True if charging is currently active

bool balancing

True if balancing circuits are enabled

bool protection

True if in battery protection mode (could be due to a fault, etc.)

struct battery_management_t
#include <battery_management.h>

The battery management service.

Public Members

battery_status_t battery_status

The battery status

bool initialized

True if the BMS is initialized

uint32_t tick_counter

Internal counter for update loop

uint32_t telemetry_tick_counter

Internal counter for telemetry

group Public API

External interface for interacting with the Battery Management Service.

Functions

void battery_init(battery_management_t *manager)

Initialize the Battery Management Service.

This must be called once at startup before any other BMS functions. Initializes internal state, and performs a startup self-check.

Note

If called more than once, the internal battery state will be reset.

Parameters:

manager[out] The battery manager

void battery_charge_control(battery_management_t *manager, bool enable)

Apply charge-control policy.

Enables or disables charging circuits based on SoC, temperature, EPS power budget, and safety limits.

Parameters:

manager[in] The battery manager

void battery_protect_mode(battery_management_t *manager)

Enter battery protection mode.

Used during overvoltage, deep discharge, or other critical conditions. May disable EPS rails or charging.

Parameters:

manager[in] The battery manager