mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-20 14:55:21 +03:00
Added the dynamic idle throttle offset to the blackbox header to fix the motor output display.
This commit is contained in:
parent
ae62f46958
commit
6c1cb60784
5 changed files with 15 additions and 6 deletions
|
@ -1474,6 +1474,10 @@ static bool blackboxWriteSysinfo(void)
|
|||
BLACKBOX_PRINT_HEADER_LINE("vbat_sag_compensation", "%d", currentPidProfile->vbat_sag_compensation);
|
||||
#endif
|
||||
|
||||
#if defined(USE_DYN_IDLE)
|
||||
BLACKBOX_PRINT_HEADER_LINE("dynamic_idle_offset", "%d", currentPidProfile->idle_min_rpm ? lrintf(getDynamicIdleOffset()) : 0);
|
||||
#endif
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -65,8 +65,6 @@
|
|||
#define DYN_LPF_THROTTLE_STEPS 100
|
||||
#define DYN_LPF_THROTTLE_UPDATE_DELAY_US 5000 // minimum of 5ms between updates
|
||||
|
||||
#define RC_COMMAND_THROTTLE_RANGE (PWM_RANGE_MAX - PWM_RANGE_MIN)
|
||||
|
||||
static FAST_DATA_ZERO_INIT float motorMixRange;
|
||||
|
||||
float FAST_DATA_ZERO_INIT motor[MAX_SUPPORTED_MOTORS];
|
||||
|
@ -227,7 +225,7 @@ static void calculateThrottleAndCurrentMotorEndpoints(timeUs_t currentTimeUs)
|
|||
const float pidSum = constrainf(mixerRuntime.idleP * error, -currentPidProfile->idle_pid_limit, currentPidProfile->idle_pid_limit);
|
||||
motorRangeMinIncrease = constrainf(motorRangeMinIncrease + pidSum * pidGetDT(), 0.0f, maxIncrease);
|
||||
mixerRuntime.oldMinRps = minRps;
|
||||
throttle += mixerRuntime.idleThrottleOffset * RC_COMMAND_THROTTLE_RANGE;
|
||||
throttle += mixerRuntime.idleThrottleOffset;
|
||||
|
||||
DEBUG_SET(DEBUG_DYN_IDLE, 0, motorRangeMinIncrease * 1000);
|
||||
DEBUG_SET(DEBUG_DYN_IDLE, 1, targetRpsChangeRate);
|
||||
|
@ -254,7 +252,7 @@ static void calculateThrottleAndCurrentMotorEndpoints(timeUs_t currentTimeUs)
|
|||
motorRangeMax = mixerRuntime.motorOutputHigh;
|
||||
#endif
|
||||
|
||||
currentThrottleInputRange = RC_COMMAND_THROTTLE_RANGE;
|
||||
currentThrottleInputRange = PWM_RANGE;
|
||||
motorRangeMin = mixerRuntime.motorOutputLow + motorRangeMinIncrease * (mixerRuntime.motorOutputHigh - mixerRuntime.motorOutputLow);
|
||||
motorOutputMin = motorRangeMin;
|
||||
motorOutputRange = motorRangeMax - motorRangeMin;
|
||||
|
|
|
@ -117,3 +117,4 @@ bool isFixedWing(void);
|
|||
|
||||
float getMotorOutputLow(void);
|
||||
float getMotorOutputHigh(void);
|
||||
float getDynamicIdleOffset(void);
|
||||
|
|
|
@ -396,6 +396,11 @@ static void mixerConfigureOutput(void)
|
|||
}
|
||||
#endif // USE_QUAD_MIXER_ONLY
|
||||
|
||||
float getDynamicIdleOffset(void)
|
||||
{
|
||||
return motorConfig()->digitalIdleOffsetValue * 0.0001f * PWM_RANGE;
|
||||
}
|
||||
|
||||
void mixerInit(mixerMode_e mixerMode)
|
||||
{
|
||||
currentMixerMode = mixerMode;
|
||||
|
@ -410,7 +415,7 @@ void mixerInit(mixerMode_e mixerMode)
|
|||
#endif
|
||||
|
||||
#ifdef USE_DYN_IDLE
|
||||
mixerRuntime.idleThrottleOffset = motorConfig()->digitalIdleOffsetValue * 0.0001f;
|
||||
mixerRuntime.idleThrottleOffset = getDynamicIdleOffset();
|
||||
#endif
|
||||
|
||||
mixerConfigureOutput();
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
|
||||
#define PWM_RANGE_MIN 1000
|
||||
#define PWM_RANGE_MAX 2000
|
||||
#define PWM_RANGE_MIDDLE (PWM_RANGE_MIN + ((PWM_RANGE_MAX - PWM_RANGE_MIN) / 2))
|
||||
#define PWM_RANGE (PWM_RANGE_MAX - PWM_RANGE_MIN)
|
||||
#define PWM_RANGE_MIDDLE (PWM_RANGE_MIN + (PWM_RANGE / 2))
|
||||
|
||||
#define PWM_PULSE_MIN 750 // minimum PWM pulse width which is considered valid
|
||||
#define PWM_PULSE_MAX 2250 // maximum PWM pulse width which is considered valid
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue