Add coulomb counter for accurate SoC estimation independent of load: - New coulomb_counter module: integrate current over time to track Ah consumed * coulomb_counter_init(capacity_mah) initializes with battery capacity * coulomb_counter_accumulate(current_ma) integrates current at 100 Hz * coulomb_counter_get_soc_pct() returns SoC 0-100% (255 = invalid) * coulomb_counter_reset() for charge-complete reset - Battery module integration: * battery_accumulate_coulombs() reads motor INA219 currents and accumulates * battery_get_soc_coulomb() returns coulomb-based SoC with fallback to voltage * Initialize coulomb counter at startup with DEFAULT_BATTERY_CAPACITY_MAH - Telemetry updates: * JLink STATUS: use coulomb SoC if available, fallback to voltage-based * CRSF battery frame: now includes remaining capacity in mAh (from coulomb counter) * CRSF capacity field was always 0; now reflects actual remaining mAh - Mainloop integration: * Call battery_accumulate_coulombs() every tick for continuous integration * INA219 motor currents + 200 mA subsystem baseline = total battery draw Motor current sources (INA219 addresses 0x40/0x41) provide most power draw; Jetson ROS2 battery_node already prioritizes coulomb-based soc_pct from STATUS frame. Default capacity: 2200 mAh (typical lab 3S LiPo); configurable via firmware parameter. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
6.9 KiB
6.9 KiB