void
ao_flight(void)
{
- __pdata static uint8_t nsamples = 0;
+ __pdata static uint16_t nsamples = 0;
ao_flight_adc = ao_adc_head;
ao_raw_accel_prev = 0;
/* startup state:
*
- * Collect 100 samples of acceleration and pressure
+ * Collect 1000 samples of acceleration and pressure
* data and average them to find the resting values
*/
- if (nsamples < 100) {
+ if (nsamples < 1000) {
ao_raw_accel_sum += ao_raw_accel;
ao_raw_pres_sum += ao_raw_pres;
++nsamples;
/* Turn on telemetry system
*/
ao_rdf_set(1);
- ao_telemetry_set_interval(AO_TELEMETRY_INTERVAL_FLIGHT);
+ ao_telemetry_set_interval(AO_TELEMETRY_INTERVAL_PAD);
ao_flight_state = ao_flight_launchpad;
ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
/* start logging data */
ao_log_start();
+ /* Increase telemetry rate */
+ ao_telemetry_set_interval(AO_TELEMETRY_INTERVAL_FLIGHT);
+
/* disable RDF beacon */
ao_rdf_set(0);
/* set min velocity to current velocity for
* apogee detect
*/
- ao_min_vel = ao_flight_vel;
+ ao_min_vel = abs(ao_flight_vel);
ao_flight_state = ao_flight_apogee;
ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
}
/* Enable RDF beacon */
ao_rdf_set(1);
+ /*
+ * Start recording min/max accel and pres for a while
+ * to figure out when the rocket has landed
+ */
+ /* Set the 'last' limits to max range to prevent
+ * early resting detection
+ */
+ ao_interval_min_accel = 0;
+ ao_interval_max_accel = 0x7fff;
+ ao_interval_min_pres = 0;
+ ao_interval_max_pres = 0x7fff;
+
+ /* initialize interval values */
+ ao_interval_end = ao_flight_tick + AO_INTERVAL_TICKS;
+
+ ao_interval_cur_min_pres = ao_interval_cur_max_pres = ao_flight_pres;
+ ao_interval_cur_min_accel = ao_interval_cur_max_accel = ao_flight_accel;
+
+ /* and enter drogue state */
ao_flight_state = ao_flight_drogue;
ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
}
- /*
- * Start recording min/max accel and pres for a while
- * to figure out when the rocket has landed
- */
- /* Set the 'last' limits to max range to prevent
- * early resting detection
- */
- ao_interval_min_accel = 0;
- ao_interval_max_accel = 0x7fff;
- ao_interval_min_pres = 0;
- ao_interval_max_pres = 0x7fff;
-
- /* initialize interval values */
- ao_interval_end = ao_flight_tick + AO_INTERVAL_TICKS;
-
- ao_interval_cur_min_pres = ao_interval_cur_max_pres = ao_flight_pres;
- ao_interval_cur_min_accel = ao_interval_cur_max_accel = ao_flight_accel;
break;
case ao_flight_drogue: