diff options
author | Keith Packard <keithp@keithp.com> | 2009-05-13 10:59:04 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2009-05-13 10:59:04 -0700 |
commit | 24fdda44ff8604e40510b196ead17564d8f8cd3d (patch) | |
tree | ea99e8825e0322e152c8b03c752196e58c6213fd | |
parent | 7a1aa3fdbc0d1fae5e7ee027bf8904598c6ebe41 (diff) |
Add velocity check for boost detect via accelerometer
Bumping the rocket can cause a brief period of high acceleration, which may
cause a mistaken boost detection. Require both a high acceleration and
reasonable velocity to trigger boost phase.
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | ao_flight.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ao_flight.c b/ao_flight.c index 3bc6b974..d50d37e3 100644 --- a/ao_flight.c +++ b/ao_flight.c @@ -83,6 +83,7 @@ __pdata int16_t ao_raw_accel, ao_raw_accel_prev, ao_raw_pres; #define ACCEL_VEL_MACH VEL_MPS_TO_COUNT(200) #define ACCEL_VEL_APOGEE VEL_MPS_TO_COUNT(2) #define ACCEL_VEL_MAIN VEL_MPS_TO_COUNT(100) +#define ACCEL_VEL_BOOST VEL_MPS_TO_COUNT(5) /* * Barometer calibration @@ -242,7 +243,7 @@ ao_flight(void) /* pad to boost: * - * accelerometer: > 2g + * accelerometer: > 2g AND velocity > 5m/s * OR * barometer: > 20m vertical motion * @@ -250,7 +251,8 @@ ao_flight(void) * the barometer, but we use both to make sure this * transition is detected */ - if (ao_flight_accel < ao_ground_accel - ACCEL_BOOST || + if ((ao_flight_accel < ao_ground_accel - ACCEL_BOOST && + ao_flight_vel > ACCEL_VEL_BOOST) || ao_flight_pres < ao_ground_pres - BARO_LAUNCH) { ao_flight_state = ao_flight_boost; |