1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 04:45:24 +03:00

Refactor dshot command output scheduling logic

Change to a state machine that tracks the progress of each dshot command in the queue as it moves through the various phases. Simplifies the code to make it easier to understand and maintain.

Transition to timing based on motor output cycle counts calculated from desired delays instead of using direct time comparisons. Since the output timing is always based on the motor update schedule, there were cases where if the time between motor updates was a significant percentage of the desired dshot command timing, then the output could get irregular and skip cycles (for example trying to use 2K pid loop with 500us timing conflicting with 1ms timing between dshot command outputs).
This commit is contained in:
Bruce Luckcuck 2019-04-06 17:44:24 -04:00
parent 616b476bb9
commit e2b5fc24bd
5 changed files with 103 additions and 48 deletions

View file

@ -34,6 +34,7 @@
#include "config/config_reset.h"
#include "drivers/pwm_output.h"
#include "drivers/sound_beeper.h"
#include "drivers/time.h"
@ -223,6 +224,9 @@ static void pidSetTargetLooptime(uint32_t pidLooptime)
targetPidLooptime = pidLooptime;
dT = targetPidLooptime * 1e-6f;
pidFrequency = 1.0f / dT;
#ifdef USE_DSHOT
setDshotPidLoopTime(targetPidLooptime);
#endif
}
static FAST_RAM float itermAccelerator = 1.0f;