Skip to content

Commit cd765d6

Browse files
authored
max loop rate with pwm motor output fix (#194)
1 parent ae4af77 commit cd765d6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/Espfc/src/Model.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class Model
363363
// for synced and standard PWM limit loop rate and pwm pulse width
364364
if(config.output.protocol == ESC_PROTOCOL_PWM && state.loopRate > 500)
365365
{
366-
config.loopSync = std::max(config.loopSync, (int8_t)((state.loopRate + 499) / 500)); // align loop rate to lower than 500Hz
366+
config.loopSync = std::max(config.loopSync, (int8_t)((state.gyro.rate + 499) / 500)); // align loop rate to lower than 500Hz
367367
state.loopRate = state.gyro.rate / config.loopSync;
368368
if(state.loopRate > 480 && config.output.maxThrottle > 1940)
369369
{
@@ -373,7 +373,7 @@ class Model
373373
// for onshot125 limit loop rate to 2kHz
374374
if(config.output.protocol == ESC_PROTOCOL_ONESHOT125 && state.loopRate > 2000)
375375
{
376-
config.loopSync = std::max(config.loopSync, (int8_t)((state.loopRate + 1999) / 2000)); // align loop rate to lower than 2000Hz
376+
config.loopSync = std::max(config.loopSync, (int8_t)((state.gyro.rate + 1999) / 2000)); // align loop rate to lower than 2000Hz
377377
state.loopRate = state.gyro.rate / config.loopSync;
378378
}
379379
}

0 commit comments

Comments
 (0)