Mercurial > public > ostc4
annotate Small_CPU/Inc/batteryGasGauge.h @ 224:ceecabfddb57 div-fixes-3
Bugfix, deco: fix 2 (small) problems with calculated ceiling
This fixes 1 trivial, and 1 not really trivial bug in the calculation
of the ceiling. When simulating a bounce dive to 80m, things become
clear (tried this on a CCR dive, fixed setpoint 1.2bar, about 15 minutes
of bottom time). Closely watch the behavior of the ceiling data. At some
point during the ascent, the ceiling begins to decrease in 10cm steps.
Then suddenly (while still ascending), the ceiling increases again with 1m,
does not change for some time, and then suddenly steps 1.1m less deep.
While not very relevant to real deco diving, it is simply wrong.
The reason for this is subtle. The algorithm used to find the ceiling
is a sort of linear search, stepping down a meter, overshoot the depth, and
search back in 10cm steps. It seems some numerical instability. Fixing
this, was a bit more computational intensive search by stepping up down in
equal steps of 10cm. But, I'm pretty sure that things can be speeded up here, as a
ceiling does not change fast, so it should be not that difficult to limit
the search space, or use a binary search algorithm instead.
The trivial second problem fixed, is that the ceiling ends at the surface
and not at 1m depth. This small issue became visible after changing the step
down size above.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Sun, 31 Mar 2019 19:35:51 +0200 |
parents | 5f11787b4f42 |
children | 2defc8cd93ce |
rev | line source |
---|---|
38 | 1 /** |
2 ****************************************************************************** | |
3 * @file batteryGasGauge.h | |
4 * @author heinrichs weikamp gmbh | |
5 * @version V0.0.1 | |
6 * @date 09-Dec-2014 | |
7 * @brief LTC2942 | |
8 * | |
9 @verbatim | |
10 ============================================================================== | |
11 ##### How to use ##### | |
12 ============================================================================== | |
13 @endverbatim | |
14 ****************************************************************************** | |
15 * @attention | |
16 * | |
17 * <h2><center>© COPYRIGHT(c) 2014 heinrichs weikamp</center></h2> | |
18 * | |
19 ****************************************************************************** | |
20 */ | |
21 | |
22 /* Define to prevent recursive inclusion -------------------------------------*/ | |
23 #ifndef BATTERY_GAS_GAUGE_H | |
24 #define BATTERY_GAS_GAUGE_H | |
25 | |
26 #ifdef __cplusplus | |
27 extern "C" { | |
28 #endif | |
29 | |
30 /* Includes ------------------------------------------------------------------*/ | |
31 | |
32 void init_battery_gas_gauge(void); | |
33 | |
34 float get_voltage(void); | |
35 float get_charge(void); | |
36 | |
37 void battery_gas_gauge_get_data(void); | |
38 void battery_gas_gauge_set_charge_full(void); | |
39 void battery_gas_gauge_set(float percentage); | |
40 | |
41 #ifdef __cplusplus | |
42 } | |
43 #endif | |
44 | |
45 #endif /* BATTERY_GAS_GAUGE_H */ | |
46 | |
47 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ |