Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Better ACK handling #64

Merged
merged 8 commits into from
Dec 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,27 @@ SFE_UBLOX_GPS myGPS;
void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
while (!Serial)
; //Wait for user to open terminal
Serial.println("SparkFun Ublox Example");

Wire.begin();

if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
{
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
while (1);
while (1)
;
}

myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
myGPS.setNavigationFrequency(2); //Produce two solutions per second
myGPS.setAutoPVT(true, false); //Tell the GPS to "send" each solution and the lib not to update stale data implicitly
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
myGPS.setNavigationFrequency(2); //Produce two solutions per second
myGPS.setAutoPVT(true, false); //Tell the GPS to "send" each solution and the lib not to update stale data implicitly
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
}

/*
Calling getPVT would return false now (compare to Example 13 where it would return true), so we just use the data provided
Calling getPVT would return false now (compare to previous example where it would return true), so we just use the data provided
If you are using a threaded OS eg. FreeRTOS on an ESP32, the explicit mode of autoPVT allows you to use the data provided on both cores and inside multiple threads
The data update in background creates an inconsistent state, but that should not cause issues for most applications as they usually won't change the GPS location significantly within a 2Hz - 5Hz update rate.
Also you could oversample (10Hz - 20Hz) the data to smooth out such issues...
Expand All @@ -62,12 +64,14 @@ void loop()
{
static uint16_t counter = 0;

if (counter % 10 == 0) {
if (counter % 10 == 0)
{
// update your AHRS filter here for a ~100Hz update rate
// GPS data will be quasi static but data from your IMU will be changing
}
// debug output each half second
if (counter % 500 == 0) {
if (counter % 500 == 0)
{
Serial.println();
long latitude = myGPS.getLatitude();
Serial.print(F("Lat: "));
Expand All @@ -90,7 +94,8 @@ void loop()
Serial.println();
}
// call checkUblox all 50ms to capture the gps data
if (counter % 50 == 0) {
if (counter % 50 == 0)
{
myGPS.checkUblox();
}
delay(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox m

void setup()
{
Serial.begin(500000); //Increase serial speed to maximize
Serial.begin(500000); //Increase serial speed to maximize
while (!Serial)
; //Wait for user to open terminal
Serial.println("SparkFun Ublox Example");

Wire.begin();
Wire.setClock(400000);

if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
{
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
Expand All @@ -53,18 +53,16 @@ void setup()

//myGPS.enableDebugging(); //Enable debug messages over Serial (default)

myGPS.setNavigationFrequency(10); //Set output to 10 times a second
myGPS.setNavigationFrequency(10); //Set output to 10 times a second
byte rate = myGPS.getNavigationFrequency(); //Get the update rate of this module
Serial.print("Current update rate:");
Serial.println(rate);

}

void loop()
{
//Query module only every second. Doing it more often will just cause I2C traffic.
//The module only responds when a new position is available
if (millis() - lastTime > 10)
// Calling getPVT returns true if there actually is a fresh navigation solution available.
if (myGPS.getPVT())
{
lastTime = millis(); //Update the timer

Expand All @@ -86,6 +84,7 @@ void loop()
Serial.print(F(" SIV: "));
Serial.print(SIV);

Serial.print(" ");
Serial.print(myGPS.getYear());
Serial.print("-");
Serial.print(myGPS.getMonth());
Expand All @@ -100,6 +99,8 @@ void loop()
Serial.print(".");
Serial.print(myGPS.getNanosecond());

myGPS.flushPVT();

Serial.println();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox m

void setup()
{
Serial.begin(500000); //Increase serial speed to maximize
Serial.begin(500000); //Increase serial speed to maximize
while (!Serial)
; //Wait for user to open terminal
Serial.println("SparkFun Ublox Example");

Wire.begin();
Wire.setClock(400000);

if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
{
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
Expand All @@ -51,21 +51,21 @@ void setup()

//myGPS.enableDebugging(); //Enable debug messages over Serial (default)

myGPS.setNavigationFrequency(10); //Set output to 10 times a second
myGPS.setNavigationFrequency(10); //Set output to 10 times a second
byte rate = myGPS.getNavigationFrequency(); //Get the update rate of this module
Serial.print("Current update rate:");
Serial.println(rate);
myGPS.saveConfiguration(); //Save the current settings to flash and BBR

myGPS.saveConfiguration(); //Save the current settings to flash and BBR

pinMode(2, OUTPUT); //For debug capture
digitalWrite(2, HIGH);
}

void loop()
{
//Query module very often to get max update rate
if (millis() - lastTime > 10)
// Calling getPVT returns true if there actually is a fresh navigation solution available.
if (myGPS.getPVT())
{
lastTime = millis(); //Update the timer

Expand Down Expand Up @@ -102,11 +102,13 @@ void loop()
Serial.print(".");
//Pretty print leading zeros
int mseconds = myGPS.getMillisecond();
if(mseconds < 100) Serial.print("0");
if(mseconds < 10) Serial.print("0");
if (mseconds < 100)
Serial.print("0");
if (mseconds < 10)
Serial.print("0");
Serial.print(mseconds);

Serial.print(" nanoSeconds: ");
Serial.print(" nanoSeconds: ");
Serial.print(myGPS.getNanosecond());

Serial.println();
Expand Down
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ debugPrintln KEYWORD2
factoryReset KEYWORD2
setAutoPVT KEYWORD2
assumeAutoPVT KEYWORD2
flushPVT KEYWORD2

getYear KEYWORD2
getMonth KEYWORD2
Expand Down
Loading