rasProject_01 / weSweetHome  R. 240
process control       /     RasPi software         by   weinert-automation
Loading...
Searching...
No Matches
weBatt.h File Reference

Common types and values for buffer battery handling. More...

#include "basicTyCo.h"

Macros

#define BAT_KEEP_PWM
 Battery keep alive PWM setting (LiFePo4). More...
 
#define BAT_LDBAL_TIM
 Maximum battery load as ballast time. More...
 
#define BAT_NOLD_PWM
 Battery no load no keep setting (LiFePo4). More...
 
#define BATkeepInhBalLoad
 Inhibit battery keep loading after ballast loading. More...
 
#define BATkeepInhByCmd
 Inhibit battery keep loading after battery Off command. More...
 
#define BATkeepInhContLoad
 Inhibit battery keep loading after ballast loading. More...
 
#define BATkeepInhUnload
 Inhibit battery keep loading after unload. More...
 
#define BATmaxUNLODtime
 Upper time limit to stop discharging (LiFePo4). More...
 
#define BATVOLT_IDLE_100
 Voltage 100% loaded (LiFePo4). More...
 
#define BATVOLT_IDLE_80
 Voltage 80% loaded (LiFePo4). More...
 
#define BATVOLT_IDLE_90
 Voltage 90% loaded (LiFePo4). More...
 
#define BATVOLT_LO_LIM_UNLD
 Voltage limit to start unload (LiFePo4). More...
 
#define BATVOLT_LO_STP_UNLD
 Lower voltage limit to stop discharging (LiFePo4). More...
 
#define BATVOLT_REDUC_BLST
 Upper voltage limit to reduce ballast loading (LiFePo4). More...
 
#define BATVOLT_UP_LIM_LOAD
 Upper voltage limit to stop loading (LiFePo4). More...
 
#define ESP_U_CORR
 Correction factor for ESP battery voltmeter. More...
 
#define SOLmxPOW4unload
 Maximum solar power to stop discharging. More...
 

Variables

uint16_t hundredsV
 The battery voltage in 0.01V units. More...
 

Detailed Description

Common types and values for buffer battery handling.

Copyright (c) 2018, 2024 Albrecht Weinert
weinert-automation.de a-weinert.de
/ / /\
/ /___ / \ |
\ /____\ /____\ | _|__
\ /\ / \ / \| |
\/ \/ \__/ \__/|_

Revision history

Rev. 268 15.10.2024
Rev. 159 04.07.2018 : new
Rev. 191 15.02.2019 : comment text changes; upper ballast limit reduced
Rev. 199 02.04.2019 : battery as ballast power and voltage reduced
Rev. 200 16.04.2019 : battery keep inhibit until low stress
Rev. 223 24.04.2020 : comment clarifications, voltage adjustments
Rev. 259 04.08.2022 : battery changed to ECO-WORTHY 12.8V 100Ah LiFePO4 accu
Rev. 260 06.08.2024 : correct LiFePO4 accumulator values (hopefully)
Rev. 261 24.08.2024 : unload / load limits widened
Rev. 263 06.10.2024 : lead acid put to include file, better LiFePo limits
Rev. 266 10.10.2024 : battery unload TO increased from 4 to 5h
Rev. 268 15.10.2024 : ESP_U_CORR introduced to correct ESP voltmeter
#define ESP_U_CORR
Correction factor for ESP battery voltmeter.
Definition: weBatt.h:97

In the smart home buffer batteries are used.

Originally, we had an array of parallel 12V 6 cell lead acid batteries. It summed up to about 12V 200Ah featuring a buffer for about 1 kWh. The usable buffer capacity of the batteries formerly used in cars and glider starting winches was much lower, due to the old age and the principal limits of lead acid accumulators.

Since August 2014 all were replaced by one 12,8V 100Ah LiPoFe accumulator. In consequence all loading, keeping and unloading procedures had to be changed; the adapting to the other battery technology is ongoing. At present we could switch between LiPoFe and lead acid by the macro BATT_TYPE. Probably we will drop that possibility as lead acid technology isn't suited for storage. The accumulators have to be kept loaded and can't wait long for surplus power.

Battery voltage is measured at the battery clamps by an own MQTT device (using this software mqttHome.h, sweetHome2.c). It uses WLAN and has a 12V supply. It just "lives" on the battery and needs no further installation.

Macro Definition Documentation

◆ SOLmxPOW4unload

#define SOLmxPOW4unload

Maximum solar power to stop discharging.

If the solar power generation is above this limit battery unloading is stopped respectively inhibited. The current value is 28 W.
Rationale: Battery unloading uses the same inverter as the smallest (mimiJoule) panel array. We will not have lighted panels disconnected (idle) nor switch them under load.
Note: If the two other panel arrays produce 30 W or less miniJoule produces nothing and the array's idle voltage is < 10V.

◆ ESP_U_CORR

#define ESP_U_CORR

Correction factor for ESP battery voltmeter.

Due to tolerances the value delivered via MQTT is a bit too low. This factor is a good average correction and should be pu into the ESP voltmeter some day.

◆ BATVOLT_IDLE_100

#define BATVOLT_IDLE_100

Voltage 100% loaded (LiFePo4).

When this voltage is measured while loading the battery is considered fully (100%) loaded. Not that this value exceeds the recommended load vcoltage. The value is taken from the LiFePo4 charging curve.

◆ BATVOLT_IDLE_90

#define BATVOLT_IDLE_90

Voltage 90% loaded (LiFePo4).

When this or higher voltage is measured while loading the battery is considered at least 90% loaded. The value is taken from the LiFePo4 charging curve.

See also
BATVOLT_IDLE_100

◆ BATVOLT_IDLE_80

#define BATVOLT_IDLE_80

Voltage 80% loaded (LiFePo4).

When this or higher voltage is measured while loading the battery is considered at least 90% loaded. The value is taken from the LiFePo4 charging curve.

See also
BATVOLT_IDLE_100

◆ BATVOLT_LO_LIM_UNLD

#define BATVOLT_LO_LIM_UNLD

Voltage limit to start unload (LiFePo4).

This is the absolute minimal voltage, measured under 1% cap load, to start an unload sequence for providing buffer capacity needed.
The value is taken from the LiFePo4 discharge curve.

See also
BATVOLT_IDLE_100

◆ BATVOLT_LO_STP_UNLD

#define BATVOLT_LO_STP_UNLD

Lower voltage limit to stop discharging (LiFePo4).

This is the minimal voltage, measured under 5..10% cap unload, to stop a running unload sequence for providing buffer capacity needed.

This is a critical value. To allow for permanent loads without being forced to load within the next 24 hours we stop about 30%.

Choosing a value too high reduces the usable buffer capacity (the battery's purpose in life). A value too low endangers the battery.

The value is taken from the LiFePo4 discharge curve.

See also
BATVOLT_LO_LIM_UNLD BAT_KEEP_PWM

◆ BATmaxUNLODtime

#define BATmaxUNLODtime

Upper time limit to stop discharging (LiFePo4).

The normal discharge end condition in the unload SFC would be battery voltage (BATVOLT_LO_STP_UNLD). Additionally there is this time limit of currently 3.5h.
Rationale for value: This is a safety backup for the step up converters unkown temperature as well as other faults that could lead to overcharging. On the other hand LiPoFe4's battery management would prevent this. also.

◆ BATVOLT_UP_LIM_LOAD

#define BATVOLT_UP_LIM_LOAD

Upper voltage limit to stop loading (LiFePo4).

The battery loading SFCs would stop when this voltage is reached. Full loading would require 14.6 V and for safety reasons one should be more below, perhaps. On the other hand EcoWorth's LiFePo4 12V 100Ah has a built in battery management system (BSM), which would cut of at overvoltage.

See also
BAT_LDMX_PWM BAT_LDMX_PWM

◆ BATVOLT_REDUC_BLST

#define BATVOLT_REDUC_BLST

Upper voltage limit to reduce ballast loading (LiFePo4).

The ballast (surplus power driven) battery loading SFC would reduce the loader voltage by one step in every cycle when this voltage is reached.
Note: With suitable load current measurements and Ri knowledge this value could be made flexibly higher. The highest value used in the setup was 14.59 V (until 14.08.2018).
Note 2: On the other hand, since having water heating ballast load there's no need to stress the battery with surplus power. Note 3: This feature may senseless (09.08.2024).

◆ BATkeepInhUnload

#define BATkeepInhUnload

Inhibit battery keep loading after unload.

The current value is 3 hours. The timer would be set unconditionally to now + 3h at the end of the unload SFC.

◆ BATkeepInhBalLoad

#define BATkeepInhBalLoad

Inhibit battery keep loading after ballast loading.

The current value is 4 h from now.

◆ BATkeepInhContLoad

#define BATkeepInhContLoad

Inhibit battery keep loading after ballast loading.

The current value is 8 hours.

◆ BATkeepInhByCmd

#define BATkeepInhByCmd

Inhibit battery keep loading after battery Off command.

The current value is 1 hours from now. If the inhibit timer is running already its end time will eventually be prolonged but not shortened.

◆ BAT_LDBAL_TIM

#define BAT_LDBAL_TIM

Maximum battery load as ballast time.

Value: 4h

◆ BAT_KEEP_PWM

#define BAT_KEEP_PWM

Battery keep alive PWM setting (LiFePo4).

This is the PWM setting for the battery load module, see loadModUlookup, for permanently keeping the battery at live by preventing self discharge and feeding low permanent loads.
Value since 07.08.2024 for LiFePo4: pwm to keep at 30% or 13,21V

◆ BAT_NOLD_PWM

#define BAT_NOLD_PWM

Battery no load no keep setting (LiFePo4).

This is the PWM setting for neither charging nor loading. Until August 2024 it was 0 for the array of old lead acid starter batteries.

"LiFePO4 battery cells have a maximum discharge depth of 98% to 100%. This is longer than any other battery technology currently in the market. This means that you can safely discharge these batteries to their full capacity. However, most manufacturers recommend still using a 80% depth of discharge for these batteries to prolong their lifespan. Even if you occasionally use 100% of the battery capacity, the battery will not get harmed." cited from [https://ecotreelithium.co.uk/news/lifepo4-battery-depth-of-discharge/]

For neither keeping or loading we permanently back the battery with 12.8V lest it will not fall under 20% capacity by the 12V consumers.

Value since 07.08.2024 for LiFePo4: 20% or 12.8V

Variable Documentation

◆ hundredsV

uint16_t hundredsV
extern

The battery voltage in 0.01V units.

This is just an integer value consistent to the last valid battery voltage measurement valFilVal.batVolt. Contrary to valFilVal.batVolt which is set to -0.9 to indicate invalidity after 2.4s without new (MQTT) measurements, this value will be kept (forever).
It is preset with 1289 (12.89 V) lest have battery low before the first valid MQTT measurement / message.
Receiving a good MQTT message from the battery voltmeter will set valFilVal.batVolt, batVoltValid and this value.
Use formFixed16(&textStart, hundredsV, 2) to format as "12.89" without trailing zero.

See also
formFixed16 valFilVal batVoltValid