mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 15:25:36 +03:00
motor output scale
First draft Change method to percentage compensation fast sag filter with fast battery updates Renaming, moving factors to init where possible Names changed, display update frequency reverted to 50hz as it was 50Hz ESC Voltage sampling, battery sag lowpass for PID compensation. increment PG_PID_PROFILE, element added to end of batteryConfig_t all HZ_TO_INTERVALs set back to 200 to match battery task frequency of 200hz. Add a flag to control vbat comp Flag vbat_sag_comp_enabled allows battery compensation to be enabled or disabled from the CLI. When disabled the battery voltage task is run at 50Hz and the battery compensation code is not run. When enabled the voltage task is run at 200Hz and the compensation code runs. Constants for the fast and slow rates are added to tasks.h. The default value for vbat_sag_compensation is changed to 100 as we no longer need to use it to disable the feature. Fixed variable task frequency setting. Added config validation to disable sag compensation unless ADC is used as the voltage data source. Added conditionals, fixed naming. Fixed build.
This commit is contained in:
parent
9c3d4603b7
commit
d63ba914c6
12 changed files with 158 additions and 50 deletions
|
@ -229,6 +229,12 @@ void tasksInit(void)
|
|||
|
||||
const bool useBatteryVoltage = batteryConfig()->voltageMeterSource != VOLTAGE_METER_NONE;
|
||||
setTaskEnabled(TASK_BATTERY_VOLTAGE, useBatteryVoltage);
|
||||
|
||||
#if defined(USE_BATTERY_VOLTAGE_SAG_COMPENSATION)
|
||||
// If vbat motor output compensation is used, use fast vbat samplingTime
|
||||
rescheduleTask(TASK_BATTERY_VOLTAGE, TASK_PERIOD_HZ(getBatteryVoltageTaskFrequencyHz()));
|
||||
#endif
|
||||
|
||||
const bool useBatteryCurrent = batteryConfig()->currentMeterSource != CURRENT_METER_NONE;
|
||||
setTaskEnabled(TASK_BATTERY_CURRENT, useBatteryCurrent);
|
||||
const bool useBatteryAlerts = batteryConfig()->useVBatAlerts || batteryConfig()->useConsumptionAlerts || featureIsEnabled(FEATURE_OSD);
|
||||
|
@ -378,7 +384,7 @@ task_t tasks[TASK_COUNT] = {
|
|||
[TASK_MAIN] = DEFINE_TASK("SYSTEM", "UPDATE", NULL, taskMain, TASK_PERIOD_HZ(1000), TASK_PRIORITY_MEDIUM_HIGH),
|
||||
[TASK_SERIAL] = DEFINE_TASK("SERIAL", NULL, NULL, taskHandleSerial, TASK_PERIOD_HZ(100), TASK_PRIORITY_LOW), // 100 Hz should be enough to flush up to 115 bytes @ 115200 baud
|
||||
[TASK_BATTERY_ALERTS] = DEFINE_TASK("BATTERY_ALERTS", NULL, NULL, taskBatteryAlerts, TASK_PERIOD_HZ(5), TASK_PRIORITY_MEDIUM),
|
||||
[TASK_BATTERY_VOLTAGE] = DEFINE_TASK("BATTERY_VOLTAGE", NULL, NULL, batteryUpdateVoltage, TASK_PERIOD_HZ(50), TASK_PRIORITY_MEDIUM),
|
||||
[TASK_BATTERY_VOLTAGE] = DEFINE_TASK("BATTERY_VOLTAGE", NULL, NULL, batteryUpdateVoltage, TASK_PERIOD_HZ(SLOW_VOLTAGE_TASK_FREQ_HZ), TASK_PRIORITY_MEDIUM), // Freq may be updated in tasksInit
|
||||
[TASK_BATTERY_CURRENT] = DEFINE_TASK("BATTERY_CURRENT", NULL, NULL, batteryUpdateCurrentMeter, TASK_PERIOD_HZ(50), TASK_PRIORITY_MEDIUM),
|
||||
|
||||
#ifdef USE_TRANSPONDER
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue