From b478d3c3569d2f9df50b0030197468d14af67688 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 21 Apr 2018 16:17:26 -0700 Subject: altos: Use max of 64 previous orient values when checking pyro limits Instead of checking just a single measurement to see if the orientation is outside of the desired limits, use the maximum of 64 previous values to that rapidly changing orientation won't accidentally enable a pyro channel if sampled at the 'wrong time'. Signed-off-by: Keith Packard --- src/kernel/ao_pyro.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/kernel/ao_pyro.c') diff --git a/src/kernel/ao_pyro.c b/src/kernel/ao_pyro.c index e5c30eec..5a556d59 100644 --- a/src/kernel/ao_pyro.c +++ b/src/kernel/ao_pyro.c @@ -81,6 +81,19 @@ int pyro_dbg; #define DBG(...) #endif +static angle_t +ao_sample_max_orient(void) +{ + uint8_t i; + angle_t max = ao_sample_orients[0]; + + for (i = 1; i < AO_NUM_ORIENT; i++) { + angle_t a = ao_sample_orients[i]; + if (a > max) + max = a; + } + return max; +} /* * Given a pyro structure, figure out * if the current flight state satisfies all @@ -90,6 +103,9 @@ static uint8_t ao_pyro_ready(struct ao_pyro *pyro) { enum ao_pyro_flag flag, flags; +#if HAS_GYRO + angle_t max_orient; +#endif flags = pyro->flags; while (flags != ao_pyro_none) { @@ -130,14 +146,16 @@ ao_pyro_ready(struct ao_pyro *pyro) #if HAS_GYRO case ao_pyro_orient_less: - if (ao_sample_orient <= pyro->orient_less) + max_orient = ao_sample_max_orient(); + if (max_orient <= pyro->orient_less) continue; - DBG("orient %d > %d\n", ao_sample_orient, pyro->orient_less); + DBG("orient %d > %d\n", max_orient, pyro->orient_less); break; case ao_pyro_orient_greater: - if (ao_sample_orient >= pyro->orient_greater) + max_orient = ao_sample_max_orient(); + if (max_orient >= pyro->orient_greater) continue; - DBG("orient %d < %d\n", ao_sample_orient, pyro->orient_greater); + DBG("orient %d < %d\n", max_orient, pyro->orient_greater); break; #endif -- cgit v1.2.3 From 327b765962d397efd4c45b6209c9225a4d23ba1d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 5 Aug 2018 08:44:04 +0800 Subject: altos: Change 'after motor' pyro check to be >= instead of == This makes after motor stay valid even if further motors burn. Signed-off-by: Keith Packard --- doc/pyro-channels.inc | 4 +++- src/kernel/ao_pyro.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/kernel/ao_pyro.c') diff --git a/doc/pyro-channels.inc b/doc/pyro-channels.inc index 7fd06412..68bbf910 100644 --- a/doc/pyro-channels.inc +++ b/doc/pyro-channels.inc @@ -57,7 +57,9 @@ cleared and must be reconfigured by the user. After Motor:: The flight software counts each time the rocket starts accelerating and then decelerating (presumably due to a motor or motors burning). Use this value for multi-staged or multi-airstart -launches. +launches. As of version 1.8.6 firmware, this checks to make sure at +least this many motors have burned. Before version 1.8.6, this checked +to make sure that exactly this many motors had burned. Delay:: Once the other parameters all become true, a timer is started for the specified amount of time. While the timer is running, diff --git a/src/kernel/ao_pyro.c b/src/kernel/ao_pyro.c index 5a556d59..3c872354 100644 --- a/src/kernel/ao_pyro.c +++ b/src/kernel/ao_pyro.c @@ -182,7 +182,7 @@ ao_pyro_ready(struct ao_pyro *pyro) break; case ao_pyro_after_motor: - if (ao_motor_number == pyro->motor) + if (ao_motor_number >= pyro->motor) continue; DBG("motor %d != %d\n", ao_motor_number, pyro->motor); break; -- cgit v1.2.3 From 0d57c78dde3c6e61576a4769b0e0fae7e88c107d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 5 Aug 2018 11:09:34 +0800 Subject: 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 --- altoslib/AltosPyro.java | 4 ++-- altosui/AltosConfigFCUI.java | 2 +- doc/config-device.inc | 8 +++++++- doc/pyro-channels.inc | 10 +++++++--- src/kernel/ao_flight.c | 7 ++++--- src/kernel/ao_flight.h | 1 + src/kernel/ao_pyro.c | 8 ++++---- 7 files changed, 26 insertions(+), 14 deletions(-) (limited to 'src/kernel/ao_pyro.c') diff --git a/altoslib/AltosPyro.java b/altoslib/AltosPyro.java index 18f0da56..fea4fd59 100644 --- a/altoslib/AltosPyro.java +++ b/altoslib/AltosPyro.java @@ -61,8 +61,8 @@ public class AltosPyro { public static final int pyro_time_greater = 0x00000200; public static final String pyro_time_less_string = "t<"; public static final String pyro_time_greater_string = "t>"; - public static final String pyro_time_less_name = "Time since boost less than (s)"; - public static final String pyro_time_greater_name = "Time since boost greater than (s)"; + public static final String pyro_time_less_name = "Time since launch less than (s)"; + public static final String pyro_time_greater_name = "Time since launch greater than (s)"; public static final double pyro_time_scale = 100.0; public static final int pyro_ascending = 0x00000400; diff --git a/altosui/AltosConfigFCUI.java b/altosui/AltosConfigFCUI.java index 1e875dec..9bd265f0 100644 --- a/altosui/AltosConfigFCUI.java +++ b/altosui/AltosConfigFCUI.java @@ -440,7 +440,7 @@ public class AltosConfigFCUI apogee_lockout_value.setEditable(true); apogee_lockout_value.addItemListener(this); pane.add(apogee_lockout_value, c); - apogee_lockout_value.setToolTipText("Time after boost while apogee detection is locked out"); + apogee_lockout_value.setToolTipText("Time after launch while apogee detection is locked out"); row++; /* Frequency */ diff --git a/doc/config-device.inc b/doc/config-device.inc index 99d5c008..0ca6afff 100644 --- a/doc/config-device.inc +++ b/doc/config-device.inc @@ -23,7 +23,7 @@ ifdef::altusmetrum[] ==== Apogee Lockout - Apogee lockout is the number of seconds after boost + Apogee lockout is the number of seconds after launch where the flight computer will not fire the apogee charge, even if the rocket appears to be at apogee. This is often called 'Mach Delay', as it is @@ -35,6 +35,12 @@ ifdef::altusmetrum[] pressure increase, and so this setting should be left at the default value of zero to disable it. + [WARNING] + Firmware versions older than 1.8.6 have a + bug which resets the time since launch to zero each + time a motor starts burning. Update firmware to get + the correct behavior. + endif::altusmetrum[] ifdef::radio[] diff --git a/doc/pyro-channels.inc b/doc/pyro-channels.inc index 68bbf910..ab5baef0 100644 --- a/doc/pyro-channels.inc +++ b/doc/pyro-channels.inc @@ -42,9 +42,13 @@ launch pad and initialize the system. of less than that value. ==== -Flight Time:: Time since boost was detected. Select a value and choose -whether to activate the pyro channel before or after that amount of -time. +Flight Time:: Time since launch. Select a value and choose whether to +activate the pyro channel before or after that amount of time. + +[WARNING] +Firmware versions older than 1.8.6 have a bug which resets the time +since launch to zero each time a motor starts burning. Update firmware +to get the correct behavior. Ascending:: A deprecated configuration value which was the same as setting Ascent rate > 0. Existing configurations using this will be diff --git a/src/kernel/ao_flight.c b/src/kernel/ao_flight.c index 7b3cb9fa..c2700d20 100644 --- a/src/kernel/ao_flight.c +++ b/src/kernel/ao_flight.c @@ -48,7 +48,8 @@ /* Main flight thread. */ __pdata enum ao_flight_state ao_flight_state; /* current flight state */ -__pdata uint16_t ao_boost_tick; /* time of launch detect */ +__pdata uint16_t ao_boost_tick; /* time of most recent boost detect */ +__pdata uint16_t ao_launch_tick; /* time of first boost detect */ __pdata uint16_t ao_motor_number; /* number of motors burned so far */ #if HAS_SENSOR_ERRORS @@ -199,7 +200,7 @@ ao_flight(void) ) { ao_flight_state = ao_flight_boost; - ao_boost_tick = ao_sample_tick; + ao_launch_tick = ao_boost_tick = ao_sample_tick; /* start logging data */ ao_log_start(); @@ -269,7 +270,7 @@ ao_flight(void) * number of seconds. */ if (ao_config.apogee_lockout) { - if ((int16_t) (ao_sample_tick - ao_boost_tick) < + if ((int16_t) (ao_sample_tick - ao_launch_tick) < AO_SEC_TO_TICKS(ao_config.apogee_lockout)) break; } diff --git a/src/kernel/ao_flight.h b/src/kernel/ao_flight.h index 6894fe59..005c7e84 100644 --- a/src/kernel/ao_flight.h +++ b/src/kernel/ao_flight.h @@ -40,6 +40,7 @@ enum ao_flight_state { extern __pdata enum ao_flight_state ao_flight_state; extern __pdata uint16_t ao_boost_tick; +extern __pdata uint16_t ao_launch_tick; extern __pdata uint16_t ao_motor_number; #if HAS_IMU || HAS_MMA655X diff --git a/src/kernel/ao_pyro.c b/src/kernel/ao_pyro.c index 3c872354..527112ac 100644 --- a/src/kernel/ao_pyro.c +++ b/src/kernel/ao_pyro.c @@ -160,14 +160,14 @@ ao_pyro_ready(struct ao_pyro *pyro) #endif case ao_pyro_time_less: - if ((int16_t) (ao_time() - ao_boost_tick) <= pyro->time_less) + if ((int16_t) (ao_time() - ao_launch_tick) <= pyro->time_less) continue; - DBG("time %d > %d\n", (int16_t)(ao_time() - ao_boost_tick), pyro->time_less); + DBG("time %d > %d\n", (int16_t)(ao_time() - ao_launch_tick), pyro->time_less); break; case ao_pyro_time_greater: - if ((int16_t) (ao_time() - ao_boost_tick) >= pyro->time_greater) + if ((int16_t) (ao_time() - ao_launch_tick) >= pyro->time_greater) continue; - DBG("time %d < %d\n", (int16_t)(ao_time() - ao_boost_tick), pyro->time_greater); + DBG("time %d < %d\n", (int16_t)(ao_time() - ao_launch_tick), pyro->time_greater); break; case ao_pyro_ascending: -- cgit v1.2.3