mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 06:15:16 +03:00
Display ESC telemetry as real RPM in the OSD
The telemetry data provides eRPM/100. Added a `motor_poles` parameter (defaulting to 14) that is used to calculate the physical RPM. RPM = (telemetry_rpm * 100) / (motor_poles / 2) Most motors we commonly use are 14 poles, but the user can adjust if needed for their setup. Also calculate actual RPM for DEBUG_ESC_SENSOR_RPM, but to fit with in int16 the log value will be RPM/10.
This commit is contained in:
parent
49f2308fd6
commit
063f3829d4
5 changed files with 6 additions and 2 deletions
|
@ -110,6 +110,8 @@ void pgResetFn_motorConfig(motorConfig_t *motorConfig)
|
||||||
motorIndex++;
|
motorIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
motorConfig->motorPolesCount = 14; // Most brushes motors that we use are 14 poles
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_REGISTER_ARRAY(motorMixer_t, MAX_SUPPORTED_MOTORS, customMotorMixer, PG_MOTOR_MIXER, 0);
|
PG_REGISTER_ARRAY(motorMixer_t, MAX_SUPPORTED_MOTORS, customMotorMixer, PG_MOTOR_MIXER, 0);
|
||||||
|
|
|
@ -101,6 +101,7 @@ typedef struct motorConfig_s {
|
||||||
uint16_t minthrottle; // Set the minimum throttle command sent to the ESC (Electronic Speed Controller). This is the minimum value that allow motors to run at a idle speed.
|
uint16_t minthrottle; // Set the minimum throttle command sent to the ESC (Electronic Speed Controller). This is the minimum value that allow motors to run at a idle speed.
|
||||||
uint16_t maxthrottle; // This is the maximum value for the ESCs at full power this value can be increased up to 2000
|
uint16_t maxthrottle; // This is the maximum value for the ESCs at full power this value can be increased up to 2000
|
||||||
uint16_t mincommand; // This is the value for the ESCs when they are not armed. In some cases, this value must be lowered down to 900 for some specific ESCs
|
uint16_t mincommand; // This is the value for the ESCs when they are not armed. In some cases, this value must be lowered down to 900 for some specific ESCs
|
||||||
|
uint8_t motorPolesCount; // Magnetic poles in the motors for calculating actual RPM from eRPM provided by ESC telemetry
|
||||||
} motorConfig_t;
|
} motorConfig_t;
|
||||||
|
|
||||||
PG_DECLARE(motorConfig_t, motorConfig);
|
PG_DECLARE(motorConfig_t, motorConfig);
|
||||||
|
|
|
@ -554,6 +554,7 @@ const clivalue_t valueTable[] = {
|
||||||
{ "motor_pwm_protocol", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_MOTOR_PWM_PROTOCOL }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.motorPwmProtocol) },
|
{ "motor_pwm_protocol", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_MOTOR_PWM_PROTOCOL }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.motorPwmProtocol) },
|
||||||
{ "motor_pwm_rate", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 200, 32000 }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.motorPwmRate) },
|
{ "motor_pwm_rate", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 200, 32000 }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.motorPwmRate) },
|
||||||
{ "motor_pwm_inversion", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.motorPwmInversion) },
|
{ "motor_pwm_inversion", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, dev.motorPwmInversion) },
|
||||||
|
{ "motor_poles", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 4, 32 }, PG_MOTOR_CONFIG, offsetof(motorConfig_t, motorPolesCount) },
|
||||||
|
|
||||||
// PG_THROTTLE_CORRECTION_CONFIG
|
// PG_THROTTLE_CORRECTION_CONFIG
|
||||||
{ "thr_corr_value", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 150 }, PG_THROTTLE_CORRECTION_CONFIG, offsetof(throttleCorrectionConfig_t, throttle_correction_value) },
|
{ "thr_corr_value", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 150 }, PG_THROTTLE_CORRECTION_CONFIG, offsetof(throttleCorrectionConfig_t, throttle_correction_value) },
|
||||||
|
|
|
@ -820,7 +820,7 @@ static bool osdDrawSingleElement(uint8_t item)
|
||||||
|
|
||||||
case OSD_ESC_RPM:
|
case OSD_ESC_RPM:
|
||||||
if (feature(FEATURE_ESC_SENSOR)) {
|
if (feature(FEATURE_ESC_SENSOR)) {
|
||||||
tfp_sprintf(buff, "%5d", escDataCombined == NULL ? 0 : escDataCombined->rpm);
|
tfp_sprintf(buff, "%5d", escDataCombined == NULL ? 0 : (escDataCombined->rpm * 100) / (motorConfig()->motorPolesCount / 2));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -264,7 +264,7 @@ static uint8_t decodeEscFrame(void)
|
||||||
|
|
||||||
frameStatus = ESC_SENSOR_FRAME_COMPLETE;
|
frameStatus = ESC_SENSOR_FRAME_COMPLETE;
|
||||||
|
|
||||||
DEBUG_SET(DEBUG_ESC_SENSOR_RPM, escSensorMotor, escSensorData[escSensorMotor].rpm);
|
DEBUG_SET(DEBUG_ESC_SENSOR_RPM, escSensorMotor, (escSensorData[escSensorMotor].rpm * 10) / (motorConfig()->motorPolesCount / 2)); // output actual rpm/10 to fit in 16bit signed.
|
||||||
DEBUG_SET(DEBUG_ESC_SENSOR_TMP, escSensorMotor, escSensorData[escSensorMotor].temperature);
|
DEBUG_SET(DEBUG_ESC_SENSOR_TMP, escSensorMotor, escSensorData[escSensorMotor].temperature);
|
||||||
} else {
|
} else {
|
||||||
frameStatus = ESC_SENSOR_FRAME_FAILED;
|
frameStatus = ESC_SENSOR_FRAME_FAILED;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue