From f64a83cdade0d91ac43f841608f098bc49173688 Mon Sep 17 00:00:00 2001 From: Paul <5690545+PaulZC@users.noreply.github.com> Date: Mon, 11 May 2020 13:11:31 +0100 Subject: [PATCH 1/2] ZED-F9K HIghRateAutoPVT and limited debug to investigate I2C issues on Artemis --- .../Example1_HighRateAutoPVT.ino | 100 ++++++++++++++++++ src/SparkFun_Ublox_Arduino_Library.cpp | 23 ++-- src/SparkFun_Ublox_Arduino_Library.h | 3 +- 3 files changed, 117 insertions(+), 9 deletions(-) create mode 100644 examples/ZED-F9K/Example1_HighRateAutoPVT/Example1_HighRateAutoPVT.ino diff --git a/examples/ZED-F9K/Example1_HighRateAutoPVT/Example1_HighRateAutoPVT.ino b/examples/ZED-F9K/Example1_HighRateAutoPVT/Example1_HighRateAutoPVT.ino new file mode 100644 index 0000000..86788ac --- /dev/null +++ b/examples/ZED-F9K/Example1_HighRateAutoPVT/Example1_HighRateAutoPVT.ino @@ -0,0 +1,100 @@ +/* + Configuring the GPS to automatically send position reports over I2C at high frequency + The ZED-F9K can handle rates up to 30Hz + By: Paul Clark (PaulZC) + Date: May 11th, 2020 + + Based on an earlier example: + By: Nathan Seidle and Thorsten von Eicken + SparkFun Electronics + Date: January 3rd, 2019 + License: MIT. See license file for more information but you can + basically do whatever you want with this code. + + This example shows how to configure the U-Blox GPS the send navigation reports automatically + and retrieving the latest one via getPVT. This eliminates the blocking in getPVT while the GPS + produces a fresh navigation solution at the expense of returning a slighly old solution. + + This can be used over serial or over I2C, this example shows the I2C use. With serial the GPS + simply outputs the UBX_NAV_PVT packet. With I2C it queues it into its internal I2C buffer (4KB in + size?) where it can be retrieved in the next I2C poll. + + Feel like supporting open source hardware? + Buy a board from SparkFun! + ZED-F9P RTK2: https://www.sparkfun.com/products/15136 + NEO-M8P RTK: https://www.sparkfun.com/products/15005 + SAM-M8Q: https://www.sparkfun.com/products/15106 + + Hardware Connections: + Plug a Qwiic cable into the GPS and a BlackBoard + If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) + Open the serial monitor at 115200 baud to see the output +*/ + +#include //Needed for I2C to GPS + +#include //http://librarymanager/All#SparkFun_Ublox_GPS +SFE_UBLOX_GPS myGPS; + +uint16_t old_millis = 0; // Store the last millis reading +uint16_t new_millis = 0; // Store the new millis reading + +void setup() +{ + Serial.begin(115200); // You may need to increase this for very high rates + while (!Serial); //Wait for user to open terminal + Serial.println(F("SparkFun Ublox Example")); + + Wire.begin(); + +#if defined(ARDUINO_ARCH_APOLLO3) + // For the Artemis, we need to disable the internal I2C pull-ups + // otherwise we see many additional I2C bus gremlins. + // If you have disabled the pull-up resistors on your GNSS board, + // you _may_ need to comment the next line: + Wire.setPullups(0); // Disable Artemis I2C pull-ups + + // Alternatives values are: + //Wire.setPullups(1); // Set Artemis I2C pull-ups to 1.5K (default) + //Wire.setPullups(6); // Set Artemis I2C pull-ups to 6K + //Wire.setPullups(12); // Set Artemis I2C pull-ups to 12K + //Wire.setPullups(24); // Set Artemis I2C pull-ups to 24K +#endif + + myGPS.enableDebugging(Serial, true); // Print limited debug messages only + + 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); + } + + myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) + + // For the ZED family, we can limit the GNSS Satellite Systems used to GPS only to + // allow faster navigation rates + myGPS.newCfgValset8(0x10310021, 0, VAL_LAYER_RAM); // Disable GAL in RAM + myGPS.addCfgValset8(0x10310022, 0); // Disable BDS (in RAM) + myGPS.addCfgValset8(0x10310024, 0); // Disable QZSS (in RAM) + myGPS.sendCfgValset8(0x10310025, 0); // Disable GLO (in RAM) + + delay(3100); // Wait for the GNSS to reconfigure + + myGPS.setNavigationFrequency(30); //Produce 30 (!) solutions per second (only valid on devices like the ZED-F9K) + myGPS.setAutoPVT(true); //Tell the GPS to "send" each solution + //myGPS.saveConfiguration(); //Save the current settings to flash and BBR +} + +void loop() +{ + // Only print GNSS millis otherwise we will probably overrun the Serial buffer + new_millis = myGPS.getMillisecond(); // Get the latest millis (using AutoPVT) + if (new_millis != old_millis) // Only print millis when it changes + { + if (new_millis < 10) Serial.print(F("0")); // Pad zeros + if (new_millis < 100) Serial.print(F("0")); // Pad zeros + Serial.println(new_millis); + old_millis = new_millis; // Update old_millis + } + delay(5); // Let's limit how often we call checkUbloxInternal via getPVT +} diff --git a/src/SparkFun_Ublox_Arduino_Library.cpp b/src/SparkFun_Ublox_Arduino_Library.cpp index 6bcc68d..d51e193 100644 --- a/src/SparkFun_Ublox_Arduino_Library.cpp +++ b/src/SparkFun_Ublox_Arduino_Library.cpp @@ -83,15 +83,22 @@ boolean SFE_UBLOX_GPS::begin(Stream &serialPort) //Enable or disable the printing of sent/response HEX values. //Use this in conjunction with 'Transport Logging' from the Universal Reader Assistant to see what they're doing that we're not -void SFE_UBLOX_GPS::enableDebugging(Stream &debugPort) +void SFE_UBLOX_GPS::enableDebugging(Stream &debugPort, boolean printLimitedDebug) { _debugSerial = &debugPort; //Grab which port the user wants us to use for debugging - - _printDebug = true; //Should we print the commands we send? Good for debugging + if (printLimitedDebug == false) + { + _printDebug = true; //Should we print the commands we send? Good for debugging + } + else + { + _printLimitedDebug = true; //Should we print limited debug messages? Good for debugging high navigation rates + } } void SFE_UBLOX_GPS::disableDebugging(void) { _printDebug = false; //Turn off extra print statements + _printLimitedDebug = false; } //Safely print messages @@ -302,9 +309,9 @@ boolean SFE_UBLOX_GPS::checkUbloxI2C(ubxPacket *incomingUBX, uint8_t requestedCl if (lsb == 0xFF) { //I believe this is a Ublox bug. Device should never present an 0xFF. - if (_printDebug == true) + if ((_printDebug == true) || (_printLimitedDebug == true)) // Print this if doing limited debugging { - _debugSerial->println(F("checkUbloxI2C: Ublox bug, no bytes available")); + _debugSerial->println(F("checkUbloxI2C: Ublox bug, length lsb is 0xFF")); } if (checksumFailurePin >= 0) { @@ -336,7 +343,7 @@ boolean SFE_UBLOX_GPS::checkUbloxI2C(ubxPacket *incomingUBX, uint8_t requestedCl //Clear the MSbit bytesAvailable &= ~((uint16_t)1 << 15); - if (_printDebug == true) + if ((_printDebug == true) || (_printLimitedDebug == true)) // Print this if doing limited debugging { _debugSerial->print(F("checkUbloxI2C: Bytes available error:")); _debugSerial->println(bytesAvailable); @@ -395,7 +402,7 @@ boolean SFE_UBLOX_GPS::checkUbloxI2C(ubxPacket *incomingUBX, uint8_t requestedCl { if (incoming == 0x7F) { - if (_printDebug == true) + if ((_printDebug == true) || (_printLimitedDebug == true)) // Print this if doing limited debugging { _debugSerial->println(F("checkUbloxU2C: Ublox error, module not ready with data")); } @@ -809,7 +816,7 @@ void SFE_UBLOX_GPS::processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_t incomingUBX->classAndIDmatch = SFE_UBLOX_PACKET_VALIDITY_NOT_VALID; // If we have a match, set the classAndIDmatch flag to not valid } - if (_printDebug == true) + if ((_printDebug == true) || (_printLimitedDebug == true)) // Print this if doing limited debugging { //Drive an external pin to allow for easier logic analyzation if (checksumFailurePin >= 0) diff --git a/src/SparkFun_Ublox_Arduino_Library.h b/src/SparkFun_Ublox_Arduino_Library.h index c49585f..970a16d 100644 --- a/src/SparkFun_Ublox_Arduino_Library.h +++ b/src/SparkFun_Ublox_Arduino_Library.h @@ -615,7 +615,7 @@ class SFE_UBLOX_GPS boolean getRELPOSNED(uint16_t maxWait = 1100); //Get Relative Positioning Information of the NED frame - void enableDebugging(Stream &debugPort = Serial); //Given a port to print to, enable debug messages + void enableDebugging(Stream &debugPort = Serial, boolean printLimitedDebug = false); //Given a port to print to, enable debug messages. Default to all, not limited. void disableDebugging(void); //Turn off debug statements void debugPrint(char *message); //Safely print debug statements void debugPrintln(char *message); //Safely print debug statements @@ -823,6 +823,7 @@ class SFE_UBLOX_GPS //This can be changed using the ublox configuration software boolean _printDebug = false; //Flag to print the serial commands we are sending to the Serial port for debug + boolean _printLimitedDebug = false; //Flag to print limited debug messages. Useful for I2C debugging or high navigation rates //The packet buffers //These are pointed at from within the ubxPacket From 7bf5576a9981211d56d23a335d8db239fed76ed5 Mon Sep 17 00:00:00 2001 From: Paul <5690545+PaulZC@users.noreply.github.com> Date: Tue, 19 May 2020 07:52:26 +0100 Subject: [PATCH 2/2] Delete Example1_HighRateAutoPVT.ino --- .../Example1_HighRateAutoPVT.ino | 100 ------------------ 1 file changed, 100 deletions(-) delete mode 100644 examples/ZED-F9K/Example1_HighRateAutoPVT/Example1_HighRateAutoPVT.ino diff --git a/examples/ZED-F9K/Example1_HighRateAutoPVT/Example1_HighRateAutoPVT.ino b/examples/ZED-F9K/Example1_HighRateAutoPVT/Example1_HighRateAutoPVT.ino deleted file mode 100644 index 86788ac..0000000 --- a/examples/ZED-F9K/Example1_HighRateAutoPVT/Example1_HighRateAutoPVT.ino +++ /dev/null @@ -1,100 +0,0 @@ -/* - Configuring the GPS to automatically send position reports over I2C at high frequency - The ZED-F9K can handle rates up to 30Hz - By: Paul Clark (PaulZC) - Date: May 11th, 2020 - - Based on an earlier example: - By: Nathan Seidle and Thorsten von Eicken - SparkFun Electronics - Date: January 3rd, 2019 - License: MIT. See license file for more information but you can - basically do whatever you want with this code. - - This example shows how to configure the U-Blox GPS the send navigation reports automatically - and retrieving the latest one via getPVT. This eliminates the blocking in getPVT while the GPS - produces a fresh navigation solution at the expense of returning a slighly old solution. - - This can be used over serial or over I2C, this example shows the I2C use. With serial the GPS - simply outputs the UBX_NAV_PVT packet. With I2C it queues it into its internal I2C buffer (4KB in - size?) where it can be retrieved in the next I2C poll. - - Feel like supporting open source hardware? - Buy a board from SparkFun! - ZED-F9P RTK2: https://www.sparkfun.com/products/15136 - NEO-M8P RTK: https://www.sparkfun.com/products/15005 - SAM-M8Q: https://www.sparkfun.com/products/15106 - - Hardware Connections: - Plug a Qwiic cable into the GPS and a BlackBoard - If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) - Open the serial monitor at 115200 baud to see the output -*/ - -#include //Needed for I2C to GPS - -#include //http://librarymanager/All#SparkFun_Ublox_GPS -SFE_UBLOX_GPS myGPS; - -uint16_t old_millis = 0; // Store the last millis reading -uint16_t new_millis = 0; // Store the new millis reading - -void setup() -{ - Serial.begin(115200); // You may need to increase this for very high rates - while (!Serial); //Wait for user to open terminal - Serial.println(F("SparkFun Ublox Example")); - - Wire.begin(); - -#if defined(ARDUINO_ARCH_APOLLO3) - // For the Artemis, we need to disable the internal I2C pull-ups - // otherwise we see many additional I2C bus gremlins. - // If you have disabled the pull-up resistors on your GNSS board, - // you _may_ need to comment the next line: - Wire.setPullups(0); // Disable Artemis I2C pull-ups - - // Alternatives values are: - //Wire.setPullups(1); // Set Artemis I2C pull-ups to 1.5K (default) - //Wire.setPullups(6); // Set Artemis I2C pull-ups to 6K - //Wire.setPullups(12); // Set Artemis I2C pull-ups to 12K - //Wire.setPullups(24); // Set Artemis I2C pull-ups to 24K -#endif - - myGPS.enableDebugging(Serial, true); // Print limited debug messages only - - 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); - } - - myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) - - // For the ZED family, we can limit the GNSS Satellite Systems used to GPS only to - // allow faster navigation rates - myGPS.newCfgValset8(0x10310021, 0, VAL_LAYER_RAM); // Disable GAL in RAM - myGPS.addCfgValset8(0x10310022, 0); // Disable BDS (in RAM) - myGPS.addCfgValset8(0x10310024, 0); // Disable QZSS (in RAM) - myGPS.sendCfgValset8(0x10310025, 0); // Disable GLO (in RAM) - - delay(3100); // Wait for the GNSS to reconfigure - - myGPS.setNavigationFrequency(30); //Produce 30 (!) solutions per second (only valid on devices like the ZED-F9K) - myGPS.setAutoPVT(true); //Tell the GPS to "send" each solution - //myGPS.saveConfiguration(); //Save the current settings to flash and BBR -} - -void loop() -{ - // Only print GNSS millis otherwise we will probably overrun the Serial buffer - new_millis = myGPS.getMillisecond(); // Get the latest millis (using AutoPVT) - if (new_millis != old_millis) // Only print millis when it changes - { - if (new_millis < 10) Serial.print(F("0")); // Pad zeros - if (new_millis < 100) Serial.print(F("0")); // Pad zeros - Serial.println(new_millis); - old_millis = new_millis; // Update old_millis - } - delay(5); // Let's limit how often we call checkUbloxInternal via getPVT -}