aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--hw/hank/emisar-d3aa/hwdef.c24
-rw-r--r--hw/hank/emisar-d3aa/hwdef.h5
2 files changed, 17 insertions, 12 deletions
diff --git a/hw/hank/emisar-d3aa/hwdef.c b/hw/hank/emisar-d3aa/hwdef.c
index d6cb2fd..8aaa893 100644
--- a/hw/hank/emisar-d3aa/hwdef.c
+++ b/hw/hank/emisar-d3aa/hwdef.c
@@ -138,22 +138,26 @@ void detect_weak_battery() {
//resting = voltage_raw2cooked(adc_smooth[0]); // probably not settled yet
resting = quick_volt_measurement();
+ // set thresholds per cell type
+ uint8_t sag_limit, crit_voltage;
+ if (resting > DUAL_VOLTAGE_FLOOR) {
+ sag_limit = WEAK_BATTERY_SAG_THRESHOLD_LIION;
+ crit_voltage = VOLTAGE_LOW;
+ } else {
+ sag_limit = WEAK_BATTERY_SAG_THRESHOLD_AA;
+ crit_voltage = DUAL_VOLTAGE_LOW_LOW;
+ }
+
// progressively turn up the power until sag threshold is hit,
// or critical voltage, or max testing level is reached
for (uint8_t l=1; l<WEAK_BATTERY_TEST_MAX_LEVEL; l++) {
set_level(l);
loaded = quick_volt_measurement();
int16_t sag = resting - loaded;
- if (
- // AA/NiMH critical voltage
- (loaded <= DUAL_VOLTAGE_LOW_LOW) ||
- // weak battery chemistry, can't handle much power
- (sag > WEAK_BATTERY_SAG_THRESHOLD) ||
- // Li-ion critical voltage
- ((resting > VOLTAGE_LOW) && (loaded < VOLTAGE_LOW))
- ) {
- ramp_level_hard_limit = l;
- break;
+ if ( (loaded <= crit_voltage) || (sag > sag_limit) ) {
+ // battery empty or weak
+ ramp_level_hard_limit = l;
+ break;
}
}
set_level(0);
diff --git a/hw/hank/emisar-d3aa/hwdef.h b/hw/hank/emisar-d3aa/hwdef.h
index 7cd2849..7fbffbe 100644
--- a/hw/hank/emisar-d3aa/hwdef.h
+++ b/hw/hank/emisar-d3aa/hwdef.h
@@ -119,8 +119,9 @@ enum CHANNEL_MODES {
// (also helps protect firmware flashing adapters from overload)
#define USE_RAMP_LEVEL_HARD_LIMIT
#define USE_WEAK_BATTERY_PROTECTION
-#define WEAK_BATTERY_TEST_MAX_LEVEL 75 // about 300 mA
-#define WEAK_BATTERY_SAG_THRESHOLD (5*4) // 0.5 V
+#define WEAK_BATTERY_TEST_MAX_LEVEL 75 // about 300 mA
+#define WEAK_BATTERY_SAG_THRESHOLD_AA (3*4) // 0.3 V
+#define WEAK_BATTERY_SAG_THRESHOLD_LIION (6*4) // 0.6 V
// average drop across diode on this hardware
#ifndef VOLTAGE_FUDGE_FACTOR
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.