From ea3291c40496fd68263ec5fc69dd5dce0245b986 Mon Sep 17 00:00:00 2001 From: mikeller Date: Tue, 8 Nov 2016 22:38:30 +1300 Subject: [PATCH] Changed scaling of axisPID to be local to mixer only, since the servos need unscaled axisPID. --- src/main/flight/mixer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index aea7b68adc..e023eed8af 100755 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -452,9 +452,10 @@ void mixTable(pidProfile_t *pidProfile) throttle = constrainf((throttle - rxConfig->mincheck) / rcCommandThrottleRange, 0.0f, 1.0f); throttleRange = motorOutputMax - motorOutputMin; + float scaledAxisPIDf[3]; // Limit the PIDsum for (int axis = 0; axis < 3; axis++) - axisPIDf[axis] = constrainf(axisPIDf[axis] / PID_MIXER_SCALING, -pidProfile->pidSumLimit, pidProfile->pidSumLimit); + scaledAxisPIDf[axis] = constrainf(axisPIDf[axis] / PID_MIXER_SCALING, -pidProfile->pidSumLimit, pidProfile->pidSumLimit); // Calculate voltage compensation if (batteryConfig && pidProfile->vbatPidCompensation) vbatCompensationFactor = calculateVbatPidCompensation(); @@ -462,9 +463,9 @@ void mixTable(pidProfile_t *pidProfile) // Find roll/pitch/yaw desired output for (i = 0; i < motorCount; i++) { motorMix[i] = - axisPIDf[PITCH] * currentMixer[i].pitch + - axisPIDf[ROLL] * currentMixer[i].roll + - -mixerConfig->yaw_motor_direction * axisPIDf[YAW] * currentMixer[i].yaw; + scaledAxisPIDf[PITCH] * currentMixer[i].pitch + + scaledAxisPIDf[ROLL] * currentMixer[i].roll + + -mixerConfig->yaw_motor_direction * scaledAxisPIDf[YAW] * currentMixer[i].yaw; if (vbatCompensationFactor > 1.0f) motorMix[i] *= vbatCompensationFactor; // Add voltage compensation