From daceb2db9a61d0df3fd86ec17490182107831fd6 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Mon, 2 Mar 2015 00:12:01 +0100 Subject: [PATCH] Fix G-Tune for LuxFloat PID controller G-Tune documentation fix --- docs/Gtune.md | 2 +- src/main/flight/gtune.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/Gtune.md b/docs/Gtune.md index 3fff96aa43..a581003255 100644 --- a/docs/Gtune.md +++ b/docs/Gtune.md @@ -19,7 +19,7 @@ The easiest way to tune all axes at once is to do some air-jumps with the copter You can set a too high P for the axes as default in the GUI, when the copter starts shaking the wobbles will be detected and P tuned down (be careful with the strength setting though - see below). Yaw tune is disabled in any copter with less than 4 motors (like tricopters). G-Tune in Horizon or Level mode will just affect Yaw axis (if more than 3 motors...) -You will see the results in the GUI - the the tuning results will only be saved if you disable G-Tune mode while the copter is disarmed or you save the configuration in an alternative way (like hitting save button in the GUI, casting an eepromwrite with trimming, acc calibration etc.) +You will see the results in the GUI - the tuning results will only be saved if you disable G-Tune mode while the copter is disarmed or you save the configuration in an alternative way (like hitting save button in the GUI, casting an eepromwrite with trimming, acc calibration etc.) TPA and G-Tune: It is not tested and will most likely not result into something good. However G-Tune might be able to replace TPA for you. ## Parameters and their function: diff --git a/src/main/flight/gtune.c b/src/main/flight/gtune.c index b0011d2e50..b3236a3ef0 100644 --- a/src/main/flight/gtune.c +++ b/src/main/flight/gtune.c @@ -103,7 +103,7 @@ void init_Gtune(pidProfile_t *pidProfileToTune) if ((pidProfile->gtune_hilimP[i] && pidProfile->gtune_lolimP[i] > pidProfile->gtune_hilimP[i]) || // User config error disable axisis for tuning (motorCount < 4 && i == FD_YAW)) pidProfile->gtune_hilimP[i] = 0; // Disable Yawtuning for everything below a quadcopter if (floatPID) { - if(pidProfile->P_f[i] < pidProfile->gtune_lolimP[i]) pidProfile->P_f[i] = pidProfile->gtune_lolimP[i]; + if((pidProfile->P_f[i] * 10) < pidProfile->gtune_lolimP[i]) pidProfile->P_f[i] = (float)(pidProfile->gtune_lolimP[i] / 10); result_P64[i] = (int16_t)pidProfile->P_f[i] << 6; // 6 bit extra resolution for P. } else { if(pidProfile->P8[i] < pidProfile->gtune_lolimP[i]) pidProfile->P8[i] = pidProfile->gtune_lolimP[i]; @@ -152,7 +152,7 @@ void calculate_Gtune(uint8_t axis) if (ABS(diff_G) > threshP && axis != FD_YAW) result_P64[axis] -= 32; // Don't use antiwobble for YAW } result_P64[axis] = constrain(result_P64[axis], (int16_t)pidProfile->gtune_lolimP[axis] << 6, (int16_t)pidProfile->gtune_hilimP[axis] << 6); - if (floatPID) pidProfile->P_f[axis] = (float)(result_P64[axis] >> 6); // new P value for float PID + if (floatPID) pidProfile->P_f[axis] = (float)((result_P64[axis] >> 6) / 10); // new P value for float PID else pidProfile->P8[axis] = result_P64[axis] >> 6; // new P value } OldError[axis] = error;