From: Keith Packard Date: Sat, 15 Jan 2011 08:50:39 +0000 (-0800) Subject: altos: Add 5V reference computation for v1.1 boards. X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=e13337cfb536ff65979b655f1763d62ec0126c67;p=fw%2Faltos altos: Add 5V reference computation for v1.1 boards. This should compensate for changes in the 3.3V voltage. Signed-off-by: Keith Packard --- diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index 66954347..e345e5da 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -152,7 +152,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { class GPSLocked extends LaunchStatus { void show (AltosState state, int crc_errors) { value.setText(String.format("%4d sats", state.gps.nsat)); - lights.set(state.gps.locked); + lights.set(state.gps.locked && state.gps.nsat >= 4); } public GPSLocked (GridBagLayout layout, int y) { super (layout, y, "GPS Locked"); diff --git a/doc/telemetrum-outline.svg b/doc/telemetrum-outline.svg index 542df64c..d5e1700e 100644 --- a/doc/telemetrum-outline.svg +++ b/doc/telemetrum-outline.svg @@ -14,7 +14,7 @@ id="svg2" version="1.1" inkscape:version="0.47 r22583" - sodipodi:docname="telemetrum.svg"> + sodipodi:docname="telemetrum-outline.pdf"> > ADCCON2_SCH_SHIFT; - if (sequence == ADCCON3_ECH_TEMP) - sequence = 2; - a = (uint8_t __xdata *) (&ao_adc_ring[ao_adc_head].accel + sequence); +#if HAS_ACCEL_REF + if (sequence == 2) { + a = (uint8_t __xdata *) (&ao_accel_ref[ao_adc_head]); + sequence = 0; + } else +#endif + { + if (sequence == ADCCON3_ECH_TEMP) + sequence = 2; + a = (uint8_t __xdata *) (&ao_adc_ring[ao_adc_head].accel + sequence); + sequence++; + } a[0] = ADCL; a[1] = ADCH; - if (sequence < 5) { + if (sequence < 6) { #if HAS_EXTERNAL_TEMP == 0 /* start next channel conversion */ /* v0.2 replaces external temp sensor with internal one */ - if (sequence == 1) + if (sequence == 2) ADCCON3 = ADCCON3_EREF_1_25 | ADCCON3_EDIV_512 | ADCCON3_ECH_TEMP; else #endif - ADCCON3 = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | (sequence + 1); + ADCCON3 = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | sequence; } else { /* record this conversion series */ ao_adc_ring[ao_adc_head].tick = ao_time(); ao_adc_head = ao_adc_ring_next(ao_adc_head); - ao_wakeup(ao_adc_ring); + ao_wakeup(DATA_TO_XDATA(&ao_adc_head)); } } diff --git a/src/ao_config.c b/src/ao_config.c index e97b7eb1..bbee3b44 100644 --- a/src/ao_config.c +++ b/src/ao_config.c @@ -209,10 +209,10 @@ ao_config_accel_calibrate_auto(char *orientation) __reentrant puts("Calibrating..."); flush(); i = ACCEL_CALIBRATE_SAMPLES; accel_total = 0; - cal_adc_ring = ao_adc_head; + cal_adc_ring = ao_flight_adc; while (i) { - ao_sleep(&ao_adc_ring); - while (i && cal_adc_ring != ao_adc_head) { + ao_sleep(DATA_TO_XDATA(&ao_flight_adc)); + while (i && cal_adc_ring != ao_flight_adc) { accel_total += (int32_t) ao_adc_ring[cal_adc_ring].accel; cal_adc_ring = ao_adc_ring_next(cal_adc_ring); i--; diff --git a/src/ao_flight.c b/src/ao_flight.c index 7fe85cb1..8f856235 100644 --- a/src/ao_flight.c +++ b/src/ao_flight.c @@ -146,16 +146,24 @@ ao_flight(void) ao_raw_pres = 0; ao_flight_tick = 0; for (;;) { - ao_sleep(&ao_adc_ring); + ao_wakeup(DATA_TO_XDATA(&ao_flight_adc)); + ao_sleep(DATA_TO_XDATA(&ao_adc_head)); while (ao_flight_adc != ao_adc_head) { __pdata uint8_t ticks; __pdata int16_t ao_vel_change; + __xdata int16_t *ao_adc; ao_flight_prev_tick = ao_flight_tick; /* Capture a sample */ - ao_raw_accel = ao_adc_ring[ao_flight_adc].accel; - ao_raw_pres = ao_adc_ring[ao_flight_adc].pres; - ao_flight_tick = ao_adc_ring[ao_flight_adc].tick; + ao_adc = &ao_adc_ring[ao_flight_adc].tick; + ao_flight_tick = *ao_adc++; +#if HAS_ACCEL_REF + ao_raw_accel = (uint16_t) ((((uint32_t) *ao_adc << 16) / (ao_accel_ref[ao_flight_adc] << 1))) >> 1; + *ao_adc++ = ao_raw_accel; +#else + ao_raw_accel = *ao_adc++; +#endif + ao_raw_pres = *ao_adc++; ao_flight_accel -= ao_flight_accel >> 4; ao_flight_accel += ao_raw_accel >> 4; diff --git a/src/ao_ignite.c b/src/ao_ignite.c index f2b15dd2..603fcd25 100644 --- a/src/ao_ignite.c +++ b/src/ao_ignite.c @@ -52,7 +52,6 @@ ao_igniter_status(enum ao_igniter igniter) __xdata uint8_t request, firing, fired; __critical { - ao_adc_sleep(); ao_adc_get(&adc); request = ao_ignition[igniter].request; fired = ao_ignition[igniter].fired; diff --git a/src/ao_log.c b/src/ao_log.c index 8666482b..ea36da5e 100644 --- a/src/ao_log.c +++ b/src/ao_log.c @@ -99,10 +99,10 @@ ao_log(void) /* Write the whole contents of the ring to the log * when starting up. */ - ao_log_adc_pos = ao_adc_ring_next(ao_adc_head); + ao_log_adc_pos = ao_adc_ring_next(ao_flight_adc); for (;;) { /* Write samples to EEPROM */ - while (ao_log_adc_pos != ao_adc_head) { + while (ao_log_adc_pos != ao_flight_adc) { log.type = AO_LOG_SENSOR; log.tick = ao_adc_ring[ao_log_adc_pos].tick; log.u.sensor.accel = ao_adc_ring[ao_log_adc_pos].accel; diff --git a/src/ao_pins.h b/src/ao_pins.h index 9446964e..2c5b9db5 100644 --- a/src/ao_pins.h +++ b/src/ao_pins.h @@ -31,6 +31,7 @@ #define AO_LED_RED 1 #define LEDS_AVAILABLE (AO_LED_RED) #define HAS_EXTERNAL_TEMP 0 + #define HAS_ACCEL_REF 0 #endif #if defined(TELEMETRUM_V_1_1) @@ -46,6 +47,7 @@ #define AO_LED_RED 1 #define LEDS_AVAILABLE (AO_LED_RED) #define HAS_EXTERNAL_TEMP 0 + #define HAS_ACCEL_REF 1 #define SPI_CS_ON_P1 1 #define SPI_CS_ON_P0 0 #define M25_CS_MASK 0x02 /* CS0 is P1_1 */ @@ -81,6 +83,7 @@ #define AO_LED_GREEN 1 #define LEDS_AVAILABLE (AO_LED_RED|AO_LED_GREEN) #define HAS_EXTERNAL_TEMP 1 + #define HAS_ACCEL_REF 0 #define SPI_CS_ON_P1 1 #define SPI_CS_ON_P0 0 #endif