diff --git a/documents/README/Charging_logic.md b/documents/README/Charging_logic.md index 30aa605..fd2f5a9 100644 --- a/documents/README/Charging_logic.md +++ b/documents/README/Charging_logic.md @@ -28,6 +28,20 @@ While no BMS is combined (boot, reboot, OTA update, RS485 or BLE dropout), the c When a BMS is combined again, the logic resumes from the kept status, and the usual rebulk rules apply: if the battery was discharged during the dropout, `Rebulk voltage`, `Rebulk SoC` or `Rebulk days` start a new `Bulk`. +## Charging blocked (Wait) + +While at least one BMS is combined, the `Charging Status` goes to `Wait` when charging is not allowed: + +- without `bms_options_charging_logic.yaml`: when the `Charging` switch is off, or when no combined BMS allows charging (protection, charge switch off); +- with `bms_options_charging_logic.yaml`: only when the `Charging` switch is off. In that mode YamBMS turns the BMS charge switch off itself at Cut-Off, and that block must not change the status. + +In `Wait` the `Charging Instruction` is `Stop`. + +When charging is allowed again: + +- a battery that was in `Float` or `EOC` goes back there, unless a rebulk rule applies (`Rebulk voltage`, `Rebulk SoC`, `Rebulk days`, `Force Bulk` or `Request Force Charge`), in which case a new `Bulk` starts; +- any other status (`Init`, `Bulk`, `Cut-Off`, `Balancing`) goes to `Bulk`. + ## Cut-Off Charging Logic Equation Source: [Charging Marine Lithium Battery Banks](https://nordkyndesign.com/charging-marine-lithium-battery-banks) diff --git a/packages/yambms/yambms_core.yaml b/packages/yambms/yambms_core.yaml index dfe2857..9269b8b 100644 --- a/packages/yambms/yambms_core.yaml +++ b/packages/yambms/yambms_core.yaml @@ -243,6 +243,11 @@ globals: type: std::string restore_value: no initial_value: '"Init"' + # Charge status before Wait, restored if it was Float or EOC + - id: yambms${yambms_id}_var_charge_status_before_wait + type: std::string + restore_value: no + initial_value: '"Init"' # Inverter links: one slot per declared CAN/RS485 link, filled by the link # package itself. The n-th element of the four vectors describes the same # link, so an unresolved link writes "None" and never an empty string. @@ -926,6 +931,17 @@ interval: } } + // +-----------------------------------------------+ + // | Charging allowed again after Wait | + // +-----------------------------------------------+ + // A battery that was in Float or EOC goes back there, and the rebulk rules + // below decide whether a new Bulk is needed. Any other status (Init, Bulk, + // Cut-Off, Balancing) goes to Bulk through the Init / Wait rule. + if ((id(yambms${yambms_id}_var_charge_status) == "Wait") && + ((id(yambms${yambms_id}_var_charge_status_before_wait) == "Float") || + (id(yambms${yambms_id}_var_charge_status_before_wait) == "EOC"))) + id(yambms${yambms_id}_var_charge_status) = id(yambms${yambms_id}_var_charge_status_before_wait); + // +-----------------------------------------------+ // | Force Bulk Logic | // +-----------------------------------------------+ @@ -1100,14 +1116,23 @@ interval: } } // Charging not allowed (BMS or YamBMS) + // The status before Wait is kept, to go back to Float or EOC when charging + // is allowed again (see "Charging allowed again after Wait"). else if (id(yambms${yambms_id}_var_bms_charging_logic) == true) { ESP_LOGD("yambms_debug", "Charging not allowed !"); - if (!id(yambms${yambms_id}_switch_charging).state) id(yambms${yambms_id}_var_charge_status) = "Wait"; + if (!id(yambms${yambms_id}_switch_charging).state) + { + if (id(yambms${yambms_id}_var_charge_status) != "Wait") + id(yambms${yambms_id}_var_charge_status_before_wait) = id(yambms${yambms_id}_var_charge_status); + id(yambms${yambms_id}_var_charge_status) = "Wait"; + } } else { ESP_LOGD("yambms_debug", "Charging not allowed !"); + if (id(yambms${yambms_id}_var_charge_status) != "Wait") + id(yambms${yambms_id}_var_charge_status_before_wait) = id(yambms${yambms_id}_var_charge_status); id(yambms${yambms_id}_var_charge_status) = "Wait"; }