diff --git a/conf/airframes/examples/MentorEnergy.xml b/conf/airframes/examples/MentorEnergy.xml index 39c98a1283..9416ac28b8 100644 --- a/conf/airframes/examples/MentorEnergy.xml +++ b/conf/airframes/examples/MentorEnergy.xml @@ -9,7 +9,6 @@ - @@ -27,7 +26,6 @@ - - + diff --git a/conf/airframes/examples/quadshot_asp21_spektrum.xml b/conf/airframes/examples/quadshot_asp21_spektrum.xml index 8f583e899b..1c3262b131 100644 --- a/conf/airframes/examples/quadshot_asp21_spektrum.xml +++ b/conf/airframes/examples/quadshot_asp21_spektrum.xml @@ -246,7 +246,7 @@ More information on the Quadshot can be found at transition-robotics.com --> - + diff --git a/conf/airframes/flixr_discovery.xml b/conf/airframes/flixr_discovery.xml index c19b65dddd..84cc1f6305 100644 --- a/conf/airframes/flixr_discovery.xml +++ b/conf/airframes/flixr_discovery.xml @@ -67,7 +67,7 @@ diff --git a/conf/airframes/obsolete/mm/fixed-wing/slowfast2.xml b/conf/airframes/obsolete/mm/fixed-wing/slowfast2.xml index ce6d0b7f49..8a0c6e8042 100644 --- a/conf/airframes/obsolete/mm/fixed-wing/slowfast2.xml +++ b/conf/airframes/obsolete/mm/fixed-wing/slowfast2.xml @@ -36,7 +36,7 @@ - + diff --git a/conf/modules/airspeed_ets.xml b/conf/modules/airspeed_ets.xml index de10d509a9..07cf003315 100644 --- a/conf/modules/airspeed_ets.xml +++ b/conf/modules/airspeed_ets.xml @@ -17,11 +17,12 @@ - Yellow wire: SDA - Brown wire: SCL - - - + + + + - +
diff --git a/conf/modules/baro_ets.xml b/conf/modules/baro_ets.xml index 48b79418a0..0b59c2a45b 100644 --- a/conf/modules/baro_ets.xml +++ b/conf/modules/baro_ets.xml @@ -2,10 +2,26 @@ - Baro ETS (I2C) - - - + + Baro ETS (I2C). + Driver for the EagleTree Systems Baro Sensor. + Has only been tested with V3 of the sensor hardware. + + Notes: + Connect directly to TWOG/Tiny I2C port. Multiple sensors can be chained together. + Sensor should be in the proprietary mode (default) and not in 3rd party mode. + + Sensor module wire assignments: + - Red wire: 5V + - White wire: Ground + - Yellow wire: SDA + - Brown wire: SCL + + + + + +
diff --git a/sw/airborne/modules/sensors/airspeed_ets.c b/sw/airborne/modules/sensors/airspeed_ets.c index 92930f2495..a6c78cd08b 100644 --- a/sw/airborne/modules/sensors/airspeed_ets.c +++ b/sw/airborne/modules/sensors/airspeed_ets.c @@ -42,13 +42,14 @@ #include "state.h" #include "mcu_periph/i2c.h" #include "mcu_periph/uart.h" +#include "mcu_periph/sys_time.h" #include "messages.h" #include "subsystems/datalink/downlink.h" #include #if !USE_AIRSPEED -#ifndef SENSOR_SYNC_SEND -#warning either set USE_AIRSPEED or SENSOR_SYNC_SEND to use ets_airspeed +#ifndef AIRSPEED_ETS_SYNC_SEND +#warning either set USE_AIRSPEED or AIRSPEED_ETS_SYNC_SEND to use ets_airspeed #endif #endif @@ -68,6 +69,13 @@ #ifndef AIRSPEED_ETS_I2C_DEV #define AIRSPEED_ETS_I2C_DEV i2c0 #endif +PRINT_CONFIG_VAR(AIRSPEED_ETS_I2C_DEV) + +/** delay in seconds until sensor is read after startup */ +#ifndef AIRSPEED_ETS_START_DELAY +#define AIRSPEED_ETS_START_DELAY 0.2 +#endif +PRINT_CONFIG_VAR(AIRSPEED_ETS_START_DELAY) #ifndef DOWNLINK_DEVICE #define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE @@ -88,6 +96,8 @@ volatile bool_t airspeed_ets_i2c_done; bool_t airspeed_ets_offset_init; uint32_t airspeed_ets_offset_tmp; uint16_t airspeed_ets_cnt; +uint32_t airspeed_ets_delay_time; +bool_t airspeed_ets_delay_done; void airspeed_ets_init( void ) { int n; @@ -96,7 +106,7 @@ void airspeed_ets_init( void ) { airspeed_ets_offset = 0; airspeed_ets_offset_tmp = 0; airspeed_ets_i2c_done = TRUE; - airspeed_ets_valid = TRUE; + airspeed_ets_valid = FALSE; airspeed_ets_offset_init = FALSE; airspeed_ets_cnt = AIRSPEED_ETS_OFFSET_NBSAMPLES_INIT + AIRSPEED_ETS_OFFSET_NBSAMPLES_AVRG; @@ -105,10 +115,17 @@ void airspeed_ets_init( void ) { airspeed_ets_buffer[n] = 0.0; airspeed_ets_i2c_trans.status = I2CTransDone; + + airspeed_ets_delay_done = FALSE; + SysTimeTimerStart(airspeed_ets_delay_time); } void airspeed_ets_read_periodic( void ) { #ifndef SITL + if (!airspeed_ets_delay_done) { + if (SysTimeTimer(airspeed_ets_delay_time) < USEC_OF_SEC(AIRSPEED_ETS_START_DELAY)) return; + else airspeed_ets_delay_done = TRUE; + } if (airspeed_ets_i2c_trans.status == I2CTransDone) i2c_receive(&AIRSPEED_ETS_I2C_DEV, &airspeed_ets_i2c_trans, AIRSPEED_ETS_ADDR, 2); #else // SITL @@ -173,7 +190,7 @@ void airspeed_ets_read_event( void ) { #if USE_AIRSPEED stateSetAirspeed_f(&airspeed_ets); #endif -#ifdef SENSOR_SYNC_SEND +#ifdef AIRSPEED_ETS_SYNC_SEND DOWNLINK_SEND_AIRSPEED_ETS(DefaultChannel, DefaultDevice, &airspeed_ets_raw, &airspeed_ets_offset, &airspeed_ets); #endif } else { diff --git a/sw/airborne/modules/sensors/baro_ets.c b/sw/airborne/modules/sensors/baro_ets.c index 3f2e7fa1d6..e545e6d2a2 100644 --- a/sw/airborne/modules/sensors/baro_ets.c +++ b/sw/airborne/modules/sensors/baro_ets.c @@ -43,6 +43,7 @@ #include "mcu_periph/i2c.h" #include "state.h" #include +#include "mcu_periph/sys_time.h" #include "subsystems/nav.h" @@ -50,7 +51,7 @@ #include "subsystems/gps.h" #endif -#ifdef BARO_ETS_TELEMETRY +#ifdef BARO_ETS_SYNC_SEND #ifndef DOWNLINK_DEVICE #define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE #endif @@ -58,7 +59,7 @@ #include "mcu_periph/uart.h" #include "messages.h" #include "subsystems/datalink/downlink.h" -#endif //BARO_ETS_TELEMETRY +#endif //BARO_ETS_SYNC_SEND #define BARO_ETS_ADDR 0xE8 #define BARO_ETS_REG 0x07 @@ -75,6 +76,13 @@ #ifndef BARO_ETS_I2C_DEV #define BARO_ETS_I2C_DEV i2c0 #endif +PRINT_CONFIG_VAR(BARO_ETS_I2C_DEV) + +/** delay in seconds until sensor is read after startup */ +#ifndef BARO_ETS_START_DELAY +#define BARO_ETS_START_DELAY 0.2 +#endif +PRINT_CONFIG_VAR(BARO_ETS_START_DELAY) // Global variables uint16_t baro_ets_adc; @@ -88,16 +96,18 @@ float baro_ets_sigma2; struct i2c_transaction baro_ets_i2c_trans; // Local variables -bool_t baro_ets_offset_init; +bool_t baro_ets_offset_init; uint32_t baro_ets_offset_tmp; uint16_t baro_ets_cnt; +uint32_t baro_ets_delay_time; +bool_t baro_ets_delay_done; void baro_ets_init( void ) { baro_ets_adc = 0; baro_ets_altitude = 0.0; baro_ets_offset = 0; baro_ets_offset_tmp = 0; - baro_ets_valid = TRUE; + baro_ets_valid = FALSE; baro_ets_offset_init = FALSE; baro_ets_enabled = TRUE; baro_ets_cnt = BARO_ETS_OFFSET_NBSAMPLES_INIT + BARO_ETS_OFFSET_NBSAMPLES_AVRG; @@ -105,15 +115,22 @@ void baro_ets_init( void ) { baro_ets_sigma2 = BARO_ETS_SIGMA2; baro_ets_i2c_trans.status = I2CTransDone; + + baro_ets_delay_done = FALSE; + SysTimeTimerStart(baro_ets_delay_time); } void baro_ets_read_periodic( void ) { // Initiate next read #ifndef SITL + if (!baro_ets_delay_done) { + if (SysTimeTimer(baro_ets_delay_time) < USEC_OF_SEC(BARO_ETS_START_DELAY)) return; + else baro_ets_delay_done = TRUE; + } if (baro_ets_i2c_trans.status == I2CTransDone) i2c_receive(&BARO_ETS_I2C_DEV, &baro_ets_i2c_trans, BARO_ETS_ADDR, 2); #else // SITL - /* fake an offset so sim works for under hmsl as well */ + /* fake an offset so sim works as well */ if (!baro_ets_offset_init) { baro_ets_offset = 12400; baro_ets_offset_init = TRUE; @@ -123,7 +140,7 @@ void baro_ets_read_periodic( void ) { baro_ets_valid = TRUE; #endif -#ifdef BARO_ETS_TELEMETRY +#ifdef BARO_ETS_SYNC_SEND DOWNLINK_SEND_BARO_ETS(DefaultChannel, DefaultDevice, &baro_ets_adc, &baro_ets_offset, &baro_ets_altitude); #endif } @@ -161,7 +178,7 @@ void baro_ets_read_event( void ) { if (baro_ets_offset_init) { baro_ets_altitude = ground_alt + BARO_ETS_SCALE * (float)(baro_ets_offset-baro_ets_adc); // New value available -#ifdef BARO_ETS_TELEMETRY +#ifdef BARO_ETS_SYNC_SEND DOWNLINK_SEND_BARO_ETS(DefaultChannel, DefaultDevice, &baro_ets_adc, &baro_ets_offset, &baro_ets_altitude); #endif } else {