From 7ea14ecc22fa0dac3155f9bbb06209d5ae255d04 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Wed, 1 Aug 2012 01:21:57 -0500 Subject: [PATCH] Track the output gain instead of amplitude so the measured values are consistent if the settings are changed afterwards. --- flight/Modules/Autotune/autotune.c | 5 +---- shared/uavobjectdefinition/relaytuning.xml | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/flight/Modules/Autotune/autotune.c b/flight/Modules/Autotune/autotune.c index 754136b83..41e8a9542 100644 --- a/flight/Modules/Autotune/autotune.c +++ b/flight/Modules/Autotune/autotune.c @@ -254,16 +254,13 @@ static void update_stabilization_settings() const float gain_ratio_p = 1.0f / 5.0f; const float zero_ratio_p = 1.0f / 5.0f; - float input = relaySettings.Amplitude * 4.0f / M_PI; // amplitude of input (fundamental component of fourier series for the square wave) - // For now just run over roll and pitch for (uint i = 0; i < 2; i++) { - float output = relayTuning.Amplitude[i]; // amplitude of sinusoidal oscillation in output float wu = 1000.0f * 2 * M_PI / relayTuning.Period[i]; // ultimate freq = output osc freq (rad/s) float wc = wu * gain_ratio_r; // target openloop crossover frequency (rad/s) float zc = wc * zero_ratio_r; // controller zero location (rad/s) - float kpu = input / output; // ultimate gain, i.e. the proportional gain for instablity + float kpu = 4.0f / M_PI / relayTuning.Gain[i]; // ultimate gain, i.e. the proportional gain for instablity float kp = kpu * gain_ratio_r; // proportional gain float ki = zc * kp; // integral gain diff --git a/shared/uavobjectdefinition/relaytuning.xml b/shared/uavobjectdefinition/relaytuning.xml index 297b44686..d781e45ca 100644 --- a/shared/uavobjectdefinition/relaytuning.xml +++ b/shared/uavobjectdefinition/relaytuning.xml @@ -2,7 +2,7 @@ The input to the relay tuning. - +