diff options
| author | Selene ToyKeeper | 2024-03-27 07:13:26 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2024-03-27 07:13:26 -0600 |
| commit | 7b49797be1da97f54e9df3a1b0342ab20d7f02d5 (patch) | |
| tree | 1aab20b6979c781419fc61c8be73facf332ad8e2 /fsm/adc.h | |
| parent | fixed inaccurate comment (thanks to xikteny for spotting it) (diff) | |
| download | anduril-7b49797be1da97f54e9df3a1b0342ab20d7f02d5.tar.gz anduril-7b49797be1da97f54e9df3a1b0342ab20d7f02d5.tar.bz2 anduril-7b49797be1da97f54e9df3a1b0342ab20d7f02d5.zip | |
increased voltage precision from 0.025V to 0.02V
(so 0 to 255 now goes from 0.00V to 5.10V)
Diffstat (limited to '')
| -rw-r--r-- | fsm/adc.h | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -4,6 +4,10 @@ #pragma once +// voltage is 0.00V to 5.10V in 0.02V steps, from 0 to 255 +// so one deci-Volt is 5 steps +#define dV 5 + #if defined(USE_LVP) || defined(USE_THERMAL_REGULATION) // use raw value instead of lowpassed value for the next N measurements // (2 = 1 for voltage + 1 for temperature) @@ -15,13 +19,13 @@ volatile uint8_t adc_reset = 2; #ifndef VOLTAGE_WARNING_SECONDS #define VOLTAGE_WARNING_SECONDS 5 #endif -// low-battery threshold in volts * 40 +// low-battery threshold in volts * 50 #ifndef VOLTAGE_LOW -#define VOLTAGE_LOW (4*29) +#define VOLTAGE_LOW (29*dV) #endif // battery is low but not critical #ifndef VOLTAGE_RED -#define VOLTAGE_RED (4*33) +#define VOLTAGE_RED (33*dV) #endif // MCU sees voltage 0.X volts lower than actual, add X/2 to readings #ifndef VOLTAGE_FUDGE_FACTOR |
