Add Timer to pidResetErrorGyro

init with zero

pid_at_min_throttle as delay for reset Iterm
This commit is contained in:
borisbstyle 2015-10-28 20:55:02 +01:00
parent e7ce0193ce
commit 784c5fdbec
2 changed files with 15 additions and 2 deletions

View File

@ -429,7 +429,7 @@ const clivalue_t valueTable[] = {
{ "yaw_control_direction", VAR_INT8 | MASTER_VALUE, &masterConfig.yaw_control_direction, -1, 1 }, { "yaw_control_direction", VAR_INT8 | MASTER_VALUE, &masterConfig.yaw_control_direction, -1, 1 },
{ "pid_at_min_throttle", VAR_UINT8 | MASTER_VALUE, &masterConfig.mixerConfig.pid_at_min_throttle, 0, 1 }, { "pid_at_min_throttle", VAR_UINT8 | MASTER_VALUE, &masterConfig.mixerConfig.pid_at_min_throttle, 0, 5 },
{ "yaw_motor_direction", VAR_INT8 | MASTER_VALUE, &masterConfig.mixerConfig.yaw_motor_direction, -1, 1 }, { "yaw_motor_direction", VAR_INT8 | MASTER_VALUE, &masterConfig.mixerConfig.yaw_motor_direction, -1, 1 },
{ "yaw_jump_prevention_limit", VAR_UINT16 | MASTER_VALUE, &masterConfig.mixerConfig.yaw_jump_prevention_limit, YAW_JUMP_PREVENTION_LIMIT_LOW, YAW_JUMP_PREVENTION_LIMIT_HIGH }, { "yaw_jump_prevention_limit", VAR_UINT16 | MASTER_VALUE, &masterConfig.mixerConfig.yaw_jump_prevention_limit, YAW_JUMP_PREVENTION_LIMIT_LOW, YAW_JUMP_PREVENTION_LIMIT_HIGH },
#ifdef USE_SERVOS #ifdef USE_SERVOS

View File

@ -539,6 +539,7 @@ void executePeriodicTasks(bool skipBaroUpdate)
void processRx(void) void processRx(void)
{ {
static bool armedBeeperOn = false; static bool armedBeeperOn = false;
static uint32_t pidResetErrorGyroTimeout = 0;
calculateRxChannelsAndUpdateFailsafe(currentTime); calculateRxChannelsAndUpdateFailsafe(currentTime);
@ -563,7 +564,19 @@ void processRx(void)
if (throttleStatus == THROTTLE_LOW) { if (throttleStatus == THROTTLE_LOW) {
pidResetErrorAngle(); pidResetErrorAngle();
pidResetErrorGyro(); /*
* Additional code to prevent Iterm reset below min_check. pid_at_min_throttle higher than 1 will
* activate the feature. Experimental yet. Minimum configuration is 2 sec and maxx is 5seconds.
*/
if (masterConfig.mixerConfig.pid_at_min_throttle > 1) {
if (pidResetErrorGyroTimeout < millis()) {
pidResetErrorGyro();
} else {
pidResetErrorGyroTimeout = millis() + (masterConfig.mixerConfig.pid_at_min_throttle * 1000);
}
} else {
pidResetErrorGyro();
}
} }
// When armed and motors aren't spinning, do beeps and then disarm // When armed and motors aren't spinning, do beeps and then disarm