From 490955dbeaaaf016bcad0814adffaad3f2b21851 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Fri, 3 Aug 2012 11:34:05 -0500 Subject: [PATCH] Use cos_lookup instead of sin_looup(x+90) --- flight/Modules/Stabilization/relay_tuning.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flight/Modules/Stabilization/relay_tuning.c b/flight/Modules/Stabilization/relay_tuning.c index 16b4351fd..5dc538b4a 100644 --- a/flight/Modules/Stabilization/relay_tuning.c +++ b/flight/Modules/Stabilization/relay_tuning.c @@ -100,12 +100,12 @@ int stabilization_relay_rate(float error, float *output, int axis, bool reinit) // Project the error onto a sine and cosine of the same frequency // to accumulate the average amplitude - int dT = thisTime - lastHighTime; - uint32_t phase = 360 * dT / relay.Period[axis]; + int32_t dT = thisTime - lastHighTime; + int32_t phase = (360 * dT) / relay.Period[axis]; if(phase >= 360) - phase = 1; + phase = 0; accum_sin += sin_lookup_deg(phase) * error; - accum_cos += sin_lookup_deg(phase + 90) * error; + accum_cos += cos_lookup_deg(phase) * error; accumulated ++; // Make sure we've had enough time since last transition then check for a change in the output