Skip to content

Commit

Permalink
BugFix: time to first fix was sometimes abnormally high due to improp…
Browse files Browse the repository at this point in the history
…er configuration of Ublox GPS
  • Loading branch information
TonyBlitWorks committed Aug 29, 2019
1 parent b215def commit 751e1ae
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
50 changes: 33 additions & 17 deletions src/main/io/gps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/io/gps.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 751e1ae

Please sign in to comment.