Skip to content

Commit b203c79

Browse files
authored
Fix loop sync in PWM mode (#175)
1 parent 120a1a6 commit b203c79

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

docs/calculations.ods

1.14 KB
Binary file not shown.

lib/Espfc/src/Model.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ class Model
359359
// for synced and standard PWM limit loop rate and pwm pulse width
360360
if(config.output.protocol == ESC_PROTOCOL_PWM && state.loopRate > 500)
361361
{
362-
config.loopSync = std::max(config.loopSync, (int8_t)((state.loopRate + 499) / 500)); // align loop rate to lower than 500Hz
362+
config.loopSync = std::max(config.loopSync, (int8_t)((state.gyroRate + 499) / 500)); // align loop rate to lower than 500Hz
363363
state.loopRate = state.gyroRate / config.loopSync;
364364
if(state.loopRate > 480 && config.output.maxThrottle > 1940)
365365
{
@@ -369,7 +369,7 @@ class Model
369369
// for onshot125 limit loop rate to 2kHz
370370
if(config.output.protocol == ESC_PROTOCOL_ONESHOT125 && state.loopRate > 2000)
371371
{
372-
config.loopSync = std::max(config.loopSync, (int8_t)((state.loopRate + 1999) / 2000)); // align loop rate to lower than 2000Hz
372+
config.loopSync = std::max(config.loopSync, (int8_t)((state.gyroRate + 1999) / 2000)); // align loop rate to lower than 2000Hz
373373
state.loopRate = state.gyroRate / config.loopSync;
374374
}
375375
}

0 commit comments

Comments
 (0)