altos: Add separate 'ao_launch_tick'. Use in pyro and lockout.
authorKeith Packard <keithp@keithp.com>
Sun, 5 Aug 2018 03:09:34 +0000 (11:09 +0800)
committerKeith Packard <keithp@keithp.com>
Sun, 5 Aug 2018 03:13:42 +0000 (11:13 +0800)
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>
altoslib/AltosPyro.java
altosui/AltosConfigFCUI.java
doc/config-device.inc
doc/pyro-channels.inc
src/kernel/ao_flight.c
src/kernel/ao_flight.h
src/kernel/ao_pyro.c

index 18f0da56c35ea56baea6c208971d6ecfe569d5ce..fea4fd5955f7f03d87aa926034b8f294b7df90b2 100644 (file)
@@ -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;
index 1e875dec1aa9b490622fd0d2d371f306b43f0936..9bd265f096f92c67900b47d454c1b18454972434 100644 (file)
@@ -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 */
index 99d5c008861fd4e48abfe589c0641448b87e4fa1..0ca6afff10e296d89e035402e67baf41e3d9ac18 100644 (file)
@@ -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[]
index 68bbf9103d8d66119a79e9cbdbce98c47d41a83f..ab5baef0e37cc68d7bca8c24e59a22c28d9bd0a1 100644 (file)
@@ -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
index 7b3cb9fa6411055667c4fb82844c6582029a4c1b..c2700d20bddb41801bacb0d560291a50aaad4bb0 100644 (file)
@@ -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;
                        }
index 6894fe59815a0fa01edb9b4edba123bc7ecfa2e9..005c7e8459ad0be8a6bf2f909ce64aa7f7cac03b 100644 (file)
@@ -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
index 3c872354ba5fa7ccb1b7c7dca29be32cb40fc23d..527112acfbfcbc1332464966f95ed5c47cbfac54 100644 (file)
@@ -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: