mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 13:25:30 +03:00
Added offset parameter to ESC sensor current calculation to compensate for non-ESC consumption.
This commit is contained in:
parent
b2f7aa3c36
commit
670cd49bd6
3 changed files with 6 additions and 3 deletions
|
@ -618,7 +618,7 @@ const clivalue_t valueTable[] = {
|
||||||
// PG_CURRENT_SENSOR_ADC_CONFIG
|
// PG_CURRENT_SENSOR_ADC_CONFIG
|
||||||
#ifdef USE_VIRTUAL_CURRENT_METER
|
#ifdef USE_VIRTUAL_CURRENT_METER
|
||||||
{ "ibatv_scale", VAR_INT16 | MASTER_VALUE, .config.minmax = { -16000, 16000 }, PG_CURRENT_SENSOR_VIRTUAL_CONFIG, offsetof(currentSensorVirtualConfig_t, scale) },
|
{ "ibatv_scale", VAR_INT16 | MASTER_VALUE, .config.minmax = { -16000, 16000 }, PG_CURRENT_SENSOR_VIRTUAL_CONFIG, offsetof(currentSensorVirtualConfig_t, scale) },
|
||||||
{ "ibatv_offset", VAR_INT16 | MASTER_VALUE, .config.minmax = { -16000, 16000 }, PG_CURRENT_SENSOR_VIRTUAL_CONFIG, offsetof(currentSensorVirtualConfig_t, offset) },
|
{ "ibatv_offset", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, 16000 }, PG_CURRENT_SENSOR_VIRTUAL_CONFIG, offsetof(currentSensorVirtualConfig_t, offset) },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_BEEPER
|
#ifdef USE_BEEPER
|
||||||
|
@ -974,6 +974,7 @@ const clivalue_t valueTable[] = {
|
||||||
|
|
||||||
#ifdef USE_ESC_SENSOR
|
#ifdef USE_ESC_SENSOR
|
||||||
{ "esc_sensor_halfduplex", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_ESC_SENSOR_CONFIG, offsetof(escSensorConfig_t, halfDuplex) },
|
{ "esc_sensor_halfduplex", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_ESC_SENSOR_CONFIG, offsetof(escSensorConfig_t, halfDuplex) },
|
||||||
|
{ "esc_sensor_offset", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, 16000 }, PG_ESC_SENSOR_CONFIG, offsetof(escSensorConfig_t, offset) },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_RX_FRSKY_SPI
|
#ifdef USE_RX_FRSKY_SPI
|
||||||
|
|
|
@ -222,8 +222,8 @@ void currentMeterESCRefresh(int32_t lastUpdateAt)
|
||||||
|
|
||||||
escSensorData_t *escData = getEscSensorData(ESC_SENSOR_COMBINED);
|
escSensorData_t *escData = getEscSensorData(ESC_SENSOR_COMBINED);
|
||||||
if (escData && escData->dataAge <= ESC_BATTERY_AGE_MAX) {
|
if (escData && escData->dataAge <= ESC_BATTERY_AGE_MAX) {
|
||||||
currentMeterESCState.amperage = escData->current;
|
currentMeterESCState.amperage = escData->current + escSensorConfig()->offset / 10;
|
||||||
currentMeterESCState.mAhDrawn = escData->consumption;
|
currentMeterESCState.mAhDrawn = escData->consumption + escSensorConfig()->offset * millis() / (1000.0f * 3600);
|
||||||
} else {
|
} else {
|
||||||
currentMeterESCState.amperage = 0;
|
currentMeterESCState.amperage = 0;
|
||||||
currentMeterESCState.mAhDrawn = 0;
|
currentMeterESCState.mAhDrawn = 0;
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
typedef struct escSensorConfig_s {
|
typedef struct escSensorConfig_s {
|
||||||
uint8_t halfDuplex; // Set to false to listen on the TX pin for telemetry data
|
uint8_t halfDuplex; // Set to false to listen on the TX pin for telemetry data
|
||||||
|
uint16_t offset; // offset consumed by the flight controller / VTX / cam / ... in milliampere
|
||||||
|
|
||||||
} escSensorConfig_t;
|
} escSensorConfig_t;
|
||||||
|
|
||||||
PG_DECLARE(escSensorConfig_t, escSensorConfig);
|
PG_DECLARE(escSensorConfig_t, escSensorConfig);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue