diff --git a/src/main/config/config.c b/src/main/config/config.c index fae35a7075..9462910668 100755 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -169,6 +169,7 @@ static void resetPidProfile(pidProfile_t *pidProfile) pidProfile->D8[PIDVEL] = 75; pidProfile->yaw_p_limit = YAW_P_LIMIT_MAX; + pidProfile->pidSumLimit = PIDSUM_LIMIT; pidProfile->yaw_lpf_hz = 0; pidProfile->rollPitchItermIgnoreRate = 130; pidProfile->yawItermIgnoreRate = 32; diff --git a/src/main/flight/pid.h b/src/main/flight/pid.h index 1daa2c3895..464989b8d3 100644 --- a/src/main/flight/pid.h +++ b/src/main/flight/pid.h @@ -22,6 +22,7 @@ #define YAW_P_LIMIT_MAX 500 // Maximum value for yaw P limiter #define YAW_JUMP_PREVENTION_LIMIT_LOW 80 #define YAW_JUMP_PREVENTION_LIMIT_HIGH 400 +#define PIDSUM_LIMIT 700 #define DYNAMIC_PTERM_STICK_THRESHOLD 400 @@ -83,6 +84,7 @@ typedef struct pidProfile_s { uint16_t rollPitchItermIgnoreRate; // Experimental threshold for resetting iterm for pitch and roll on certain rates uint16_t yawItermIgnoreRate; // Experimental threshold for resetting iterm for yaw on certain rates uint16_t yaw_p_limit; + uint16_t pidSumLimit; uint8_t dterm_average_count; // Configurable delta count for dterm uint8_t vbatPidCompensation; // Scale PIDsum to battery voltage uint8_t pidAtMinThrottle; // Disable/Enable pids on zero throttle. Normally even without airmode P and D would be active. diff --git a/src/main/flight/pid_betaflight.c b/src/main/flight/pid_betaflight.c index 436f3431c3..05cfdc483e 100644 --- a/src/main/flight/pid_betaflight.c +++ b/src/main/flight/pid_betaflight.c @@ -220,7 +220,7 @@ void pidBetaflight(const pidProfile_t *pidProfile, uint16_t max_angle_inclinatio DTerm = Kd[axis] * delta * tpaFactor; // -----calculate total PID output - axisPID[axis] = constrain(lrintf(PTerm + ITerm + DTerm), -800, 800); + axisPID[axis] = constrain(lrintf(PTerm + ITerm + DTerm), -pidProfile->pidSumLimit, pidProfile->pidSumLimit); } else { if (pidProfile->yaw_lpf_hz) PTerm = pt1FilterApply4(&yawFilter, PTerm, pidProfile->yaw_lpf_hz, getdT()); diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index b1eb9dc4b8..7c5ef485d1 100755 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -815,7 +815,7 @@ const clivalue_t valueTable[] = { { "yaw_motor_direction", VAR_INT8 | MASTER_VALUE, &masterConfig.mixerConfig.yaw_motor_direction, .config.minmax = { -1, 1 } }, { "yaw_p_limit", VAR_UINT16 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.yaw_p_limit, .config.minmax = { YAW_P_LIMIT_MIN, YAW_P_LIMIT_MAX } }, - + { "pidsum_limit", VAR_UINT16 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.pidSumLimit, .config.minmax = { 100, 1000 } }, #ifdef USE_SERVOS { "servo_center_pulse", VAR_UINT16 | MASTER_VALUE, &masterConfig.servoConfig.servoCenterPulse, .config.minmax = { PWM_RANGE_ZERO, PWM_RANGE_MAX } }, { "tri_unarmed_servo", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.mixerConfig.tri_unarmed_servo, .config.lookup = { TABLE_OFF_ON } },