From: Keith Packard Date: Mon, 7 May 2018 15:51:36 +0000 (-0700) Subject: altos: Eliminate height requirement for coast detect X-Git-Tag: 1.8.6~1^2~63 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=cc83d57454ed07e4828b4413e5af6ae2ecfe2e5a altos: Eliminate height requirement for coast detect We had required a minimum altitude of 100m to transition from boost to coast. With small motors in a heavy multi-staged rocket, this can fail to detect coast in time to light the second motor. Also, this would fail to deploy recovery systems if the flight failed before reaching 100m. Signed-off-by: Keith Packard --- diff --git a/src/kernel/ao_flight.c b/src/kernel/ao_flight.c index cb02c454..7b3cb9fa 100644 --- a/src/kernel/ao_flight.c +++ b/src/kernel/ao_flight.c @@ -233,7 +233,7 @@ ao_flight(void) * deceleration, or by waiting until the maximum burn duration * (15 seconds) has past. */ - if ((ao_accel < AO_MSS_TO_ACCEL(-2.5) && ao_height > AO_M_TO_HEIGHT(100)) || + if ((ao_accel < AO_MSS_TO_ACCEL(-2.5)) || (int16_t) (ao_sample_tick - ao_boost_tick) > BOOST_TICKS_MAX) { #if HAS_ACCEL @@ -310,7 +310,7 @@ ao_flight(void) #if HAS_ACCEL else { check_re_boost: - ao_coast_avg_accel = ao_coast_avg_accel - (ao_coast_avg_accel >> 6) + (ao_accel >> 6); + ao_coast_avg_accel = ao_coast_avg_accel + ((ao_accel - ao_coast_avg_accel) >> 5); if (ao_coast_avg_accel > AO_MSS_TO_ACCEL(20)) { ao_boost_tick = ao_sample_tick; ao_flight_state = ao_flight_boost;