ao_flight: ao_interval_end type was too small, could cause premature landing state ao_interval_end is used to provide a window of time during which the max/min values for sensors are measured. After that time expires, those bounds are compared to see if the airframe has been stable and should be moved to landing state. With a type that is too small, that could happen immediately after transitioning to main (for baro-enabled devices) or coast (for accel-only devices). For baro devices, this would disable any redundant main firing events. For accel-only devices, this could disable all events occuring after coast, including firing separation charges or motor igniters. There are also a couple of additional changes to reduce -Wconversion messages. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Switch all tick variables to AO_TICK_TYPE/AO_TICK_SIGNED Instead of trying to pick and choose which work as 16-bit values, change everything that doesn't affect external values (log, companion, radio) to AO_TICK_TYPE. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Fix up HAS_FLIGHT_DEBUG Some printf formats weren't right. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: De-bias height/speed data while on pad Save speed/height values from 64 samples ago and subtract them from the current value. This reduces the effect of systematic accelerometer error causing these values to slowly creep when there's no barometric sensor to keep them in check. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Use state transitions to directly drive igniters Instead of a separate igniter API, have the igniter code monitor flight state changes to trigger igniter events. This simplifes the code while allowing further changes in the igniter code. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Fix HAS_FLIGHT_DEBUG for easytimer Remove baro-specific bits of the debug output when there's no barometer. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Allow accel-only flight code EasyTimer won't have a baro sensor, so we need some way to track at least the ascent part of a flight. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Make HAS_ACCEL_DEBUG build again Need to not use ao_error_h_sq_avg without HAS_ACCEL Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Remove 8051 address space specifiers Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Remove *_TO_DATA macros Now that we don't support 8051, we don't need these Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Add separate 'ao_launch_tick'. Use in pyro and lockout. Prior to this, there was only ao_boost_tick, which got reset at each motor burn start. That meant there wasn't any way to measure total flight time for pyro channels and 'apogee lockout' was based on time since most recent motor start instead of total flight time. Now pyro channels and apogee lockout both use total flight time, while motor burn length still uses time since most recent motor burn start (as it should). Docs and UI updated to use 'launch' instead of 'boost' to try and make the change clear. Signed-off-by: Keith Packard <keithp@keithp.com>
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 <keithp@keithp.com>
altos/kernel: MPU9250 support Use MPU9250 for accel, gyro and mag data in logging, telemetry and flight status computations. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Don't eliminate baro above mach speed, just trust it less Instead of completely eliminating the baro sensor above mach speed, just derate it a bit so that the accel will dominate for speed computation and keep the device from false-triggering across mach transitions. When we completely ignored the baro sensor above mach, and the flight spent considerable time in that speed range, then the estimated height could be far from the real value. When the estimated speed dropped back down and the baro values were brought back into the computation, then the resulting rapid shift in estimated speed could trigger accidental apogee detection. By mixing in a bit of baro data even above mach, we keep the estimated height closer to the baro value and prevent this error, at least in flights measured so far. The flight known to have this problem is: 2015-09-26-serial-2093-flight-0012.eeprom Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Perform time comparisons using 16-bit arithmetic to handle wrap Subtracting two 16-bit unsigned values to perform time comparisons yields mystic results unless we carefully cast that to int16_t. Signed-off-by: Keith Packard <keithp@keithp.com>
Switch from GPLv2 to GPLv2+ Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Leave USB enabled in flight with -DDEBUG=1 This leaves the command line available for diagnostics when debugging. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Allow for flight hardware without any ADC values Detherm has no ADC connections, so we don't need to disable the ADC when going to landed state. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Use 32-bits for flight state data (alt/speed/accel) Stores 32-bits for all of the flight parameters. Uses 64-bit intermediates for kalman computation. Signed-off-by: Keith Packard <keithp@keithp.com>
altos: Fake flight code changes in kernel and stm Redirects data input from local sensors to USB sourced data, leaving USB enabled when the computer goes into pad mode. Signed-off-by: Keith Packard <keithp@keithp.com>