From 751e1ae44470d4d1ed581a89eb0501df4e778ab0 Mon Sep 17 00:00:00 2001 From: Tony Cabello Date: Mon, 26 Aug 2019 15:10:52 +0200 Subject: [PATCH] BugFix: time to first fix was sometimes abnormally high due to improper configuration of Ublox GPS --- src/main/io/gps.c | 50 +++++++++++++++++++++++++++++++---------------- src/main/io/gps.h | 2 ++ 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/main/io/gps.c b/src/main/io/gps.c index 5ae82e5bb..acf1e96ba 100644 --- a/src/main/io/gps.c +++ b/src/main/io/gps.c @@ -127,27 +127,11 @@ static const gpsInitData_t gpsInitData[] = { #ifdef USE_GPS_UBLOX static const uint8_t ubloxInit[] = { //Preprocessor Pedestrian Dynamic Platform Model Option - #if defined(GPS_UBLOX_MODE_PEDESTRIAN) 0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, 0x03, 0x03, 0x00, // CFG-NAV5 - Set engine settings 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x05, 0x00, 0xFA, 0x00, // Collected by resetting a GPS unit to defaults. Changing mode to Pedistrian and 0xFA, 0x00, 0x64, 0x00, 0x2C, 0x01, 0x00, 0x3C, 0x00, 0x00, 0x00, // capturing the data from the U-Center binary console. 0x00, 0xC8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0xC2, - //Preprocessor Airborne_1g Dynamic Platform Model Option - #elif defined(GPS_UBLOX_MODE_AIRBORNE_1G) - 0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, 0x06, 0x03, 0x00, // CFG-NAV5 - Set engine settings - 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x05, 0x00, 0xFA, 0x00, // Collected by resetting a GPS unit to defaults. Changing mode to Airborne with - 0xFA, 0x00, 0x64, 0x00, 0x2C, 0x01, 0x00, 0x3C, 0x00, 0x00, 0x00, // <1g acceleration and capturing the data from the U-Center binary console. - 0x00, 0xC8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x28, - - //Default Airborne_4g Dynamic Platform Model - #else - 0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, 0x08, 0x03, 0x00, // CFG-NAV5 - Set engine settings - 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x05, 0x00, 0xFA, 0x00, // Collected by resetting a GPS unit to defaults. Changing mode to Airborne with - 0xFA, 0x00, 0x64, 0x00, 0x2C, 0x01, 0x00, 0x3C, 0x00, 0x00, 0x00, // <4g acceleration and capturing the data from the U-Center binary console. - 0x00, 0xC8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x6C, - #endif - // DISABLE NMEA messages 0xB5, 0x62, 0x06, 0x01, 0x03, 0x00, 0xF0, 0x05, 0x00, 0xFF, 0x19, // VGS: Course over ground and Ground speed 0xB5, 0x62, 0x06, 0x01, 0x03, 0x00, 0xF0, 0x03, 0x00, 0xFD, 0x15, // GSV: GNSS Satellites in View @@ -167,6 +151,23 @@ static const uint8_t ubloxInit[] = { 0xB5, 0x62, 0x06, 0x08, 0x06, 0x00, 0xC8, 0x00, 0x01, 0x00, 0x01, 0x00, 0xDE, 0x6A, // set rate to 5Hz (measurement period: 200ms, navigation rate: 1 cycle) }; +static const uint8_t ubloxAirborne[] = { + //Preprocessor Airborne_1g Dynamic Platform Model Option + #if defined(GPS_UBLOX_MODE_AIRBORNE_1G) + 0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, 0x06, 0x03, 0x00, // CFG-NAV5 - Set engine settings + 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x05, 0x00, 0xFA, 0x00, // Collected by resetting a GPS unit to defaults. Changing mode to Airborne with + 0xFA, 0x00, 0x64, 0x00, 0x2C, 0x01, 0x00, 0x3C, 0x00, 0x00, 0x00, // <1g acceleration and capturing the data from the U-Center binary console. + 0x00, 0xC8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x28, + + //Default Airborne_4g Dynamic Platform Model + #else + 0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, 0x08, 0x03, 0x00, // CFG-NAV5 - Set engine settings + 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x05, 0x00, 0xFA, 0x00, // Collected by resetting a GPS unit to defaults. Changing mode to Airborne with + 0xFA, 0x00, 0x64, 0x00, 0x2C, 0x01, 0x00, 0x3C, 0x00, 0x00, 0x00, // <4g acceleration and capturing the data from the U-Center binary console. + 0x00, 0xC8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x6C, + #endif +}; + // UBlox 6 Protocol documentation - GPS.G6-SW-10018-F // SBAS Configuration Settings Desciption, Page 4/210 // 31.21 CFG-SBAS (0x06 0x16), Page 142/210 @@ -447,7 +448,7 @@ void gpsInitUblox(void) } } - if (gpsData.messageState >= GPS_MESSAGE_STATE_ENTRY_COUNT) { + if (gpsData.messageState >= GPS_MESSAGE_STATE_INITIALIZED) { // ublox should be initialised, try receiving gpsSetState(GPS_RECEIVING_DATA); } @@ -528,6 +529,21 @@ void gpsUpdate(timeUs_t currentTimeUs) // remove GPS from capability sensorsClear(SENSOR_GPS); gpsSetState(GPS_LOST_COMMUNICATION); +#if !defined(GPS_UBLOX_MODE_PEDESTRIAN) + } else { + if ((gpsData.messageState == GPS_MESSAGE_STATE_IDLE) && STATE(GPS_FIX)) { + gpsData.messageState = GPS_MESSAGE_STATE_AIRBORNE; + gpsData.state_position = 0; + } + if (gpsData.messageState == GPS_MESSAGE_STATE_AIRBORNE) { + if (gpsData.state_position < sizeof(ubloxAirborne)) { + serialWrite(gpsPort, ubloxAirborne[gpsData.state_position]); + gpsData.state_position++; + } else { + gpsData.messageState = GPS_MESSAGE_STATE_ENTRY_COUNT; + } + } +#endif } break; } diff --git a/src/main/io/gps.h b/src/main/io/gps.h index a510b962e..d4f8436fe 100644 --- a/src/main/io/gps.h +++ b/src/main/io/gps.h @@ -104,6 +104,8 @@ typedef enum { GPS_MESSAGE_STATE_INIT, GPS_MESSAGE_STATE_SBAS, GPS_MESSAGE_STATE_GALILEO, + GPS_MESSAGE_STATE_INITIALIZED, + GPS_MESSAGE_STATE_AIRBORNE, GPS_MESSAGE_STATE_ENTRY_COUNT } gpsMessageState_e;