mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 22:35:23 +03:00
Fix ESC-Sensor RPM (#13286)
* Fix ESC-Sensor RPM * Fixes per review from KarateBrot * Fixes per review from NerdCopter * Forgot to add init.c
This commit is contained in:
parent
3e5d96158b
commit
90ab9f374b
2 changed files with 10 additions and 7 deletions
|
@ -152,16 +152,19 @@ FAST_DATA_ZERO_INIT static float dshotRpm[MAX_SUPPORTED_MOTORS];
|
|||
void initDshotTelemetry(const timeUs_t looptimeUs)
|
||||
{
|
||||
// if bidirectional DShot is not available
|
||||
if (!motorConfig()->dev.useDshotTelemetry) {
|
||||
if (!motorConfig()->dev.useDshotTelemetry && !featureIsEnabled(FEATURE_ESC_SENSOR)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// init LPFs for RPM data
|
||||
for (int i = 0; i < getMotorCount(); i++) {
|
||||
pt1FilterInit(&motorFreqLpf[i], pt1FilterGain(rpmFilterConfig()->rpm_filter_lpf_hz, looptimeUs * 1e-6f));
|
||||
}
|
||||
|
||||
// erpmToHz is used by bidir dshot and ESC telemetry
|
||||
erpmToHz = ERPM_PER_LSB / SECONDS_PER_MINUTE / (motorConfig()->motorPoleCount / 2.0f);
|
||||
|
||||
if (motorConfig()->dev.useDshotTelemetry) {
|
||||
// init LPFs for RPM data
|
||||
for (int i = 0; i < getMotorCount(); i++) {
|
||||
pt1FilterInit(&motorFreqLpf[i], pt1FilterGain(rpmFilterConfig()->rpm_filter_lpf_hz, looptimeUs * 1e-6f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t dshot_decode_eRPM_telemetry_value(uint16_t value)
|
||||
|
|
|
@ -694,7 +694,7 @@ void init(void)
|
|||
// Now reset the targetLooptime as it's possible for the validation to change the pid_process_denom
|
||||
gyroSetTargetLooptime(pidConfig()->pid_process_denom);
|
||||
|
||||
#ifdef USE_DSHOT_TELEMETRY
|
||||
#if defined(USE_DSHOT_TELEMETRY) || defined(USE_ESC_SENSOR)
|
||||
// Initialize the motor frequency filter now that we have a target looptime
|
||||
initDshotTelemetry(gyro.targetLooptime);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue