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

Commit f64a83c

Browse files
committed
ZED-F9K HIghRateAutoPVT and limited debug to investigate I2C issues on Artemis
1 parent 20490f1 commit f64a83c

File tree

3 files changed

+117
-9
lines changed

3 files changed

+117
-9
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
Configuring the GPS to automatically send position reports over I2C at high frequency
3+
The ZED-F9K can handle rates up to 30Hz
4+
By: Paul Clark (PaulZC)
5+
Date: May 11th, 2020
6+
7+
Based on an earlier example:
8+
By: Nathan Seidle and Thorsten von Eicken
9+
SparkFun Electronics
10+
Date: January 3rd, 2019
11+
License: MIT. See license file for more information but you can
12+
basically do whatever you want with this code.
13+
14+
This example shows how to configure the U-Blox GPS the send navigation reports automatically
15+
and retrieving the latest one via getPVT. This eliminates the blocking in getPVT while the GPS
16+
produces a fresh navigation solution at the expense of returning a slighly old solution.
17+
18+
This can be used over serial or over I2C, this example shows the I2C use. With serial the GPS
19+
simply outputs the UBX_NAV_PVT packet. With I2C it queues it into its internal I2C buffer (4KB in
20+
size?) where it can be retrieved in the next I2C poll.
21+
22+
Feel like supporting open source hardware?
23+
Buy a board from SparkFun!
24+
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
25+
NEO-M8P RTK: https://www.sparkfun.com/products/15005
26+
SAM-M8Q: https://www.sparkfun.com/products/15106
27+
28+
Hardware Connections:
29+
Plug a Qwiic cable into the GPS and a BlackBoard
30+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
31+
Open the serial monitor at 115200 baud to see the output
32+
*/
33+
34+
#include <Wire.h> //Needed for I2C to GPS
35+
36+
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_Ublox_GPS
37+
SFE_UBLOX_GPS myGPS;
38+
39+
uint16_t old_millis = 0; // Store the last millis reading
40+
uint16_t new_millis = 0; // Store the new millis reading
41+
42+
void setup()
43+
{
44+
Serial.begin(115200); // You may need to increase this for very high rates
45+
while (!Serial); //Wait for user to open terminal
46+
Serial.println(F("SparkFun Ublox Example"));
47+
48+
Wire.begin();
49+
50+
#if defined(ARDUINO_ARCH_APOLLO3)
51+
// For the Artemis, we need to disable the internal I2C pull-ups
52+
// otherwise we see many additional I2C bus gremlins.
53+
// If you have disabled the pull-up resistors on your GNSS board,
54+
// you _may_ need to comment the next line:
55+
Wire.setPullups(0); // Disable Artemis I2C pull-ups
56+
57+
// Alternatives values are:
58+
//Wire.setPullups(1); // Set Artemis I2C pull-ups to 1.5K (default)
59+
//Wire.setPullups(6); // Set Artemis I2C pull-ups to 6K
60+
//Wire.setPullups(12); // Set Artemis I2C pull-ups to 12K
61+
//Wire.setPullups(24); // Set Artemis I2C pull-ups to 24K
62+
#endif
63+
64+
myGPS.enableDebugging(Serial, true); // Print limited debug messages only
65+
66+
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
67+
{
68+
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
69+
while (1);
70+
}
71+
72+
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
73+
74+
// For the ZED family, we can limit the GNSS Satellite Systems used to GPS only to
75+
// allow faster navigation rates
76+
myGPS.newCfgValset8(0x10310021, 0, VAL_LAYER_RAM); // Disable GAL in RAM
77+
myGPS.addCfgValset8(0x10310022, 0); // Disable BDS (in RAM)
78+
myGPS.addCfgValset8(0x10310024, 0); // Disable QZSS (in RAM)
79+
myGPS.sendCfgValset8(0x10310025, 0); // Disable GLO (in RAM)
80+
81+
delay(3100); // Wait for the GNSS to reconfigure
82+
83+
myGPS.setNavigationFrequency(30); //Produce 30 (!) solutions per second (only valid on devices like the ZED-F9K)
84+
myGPS.setAutoPVT(true); //Tell the GPS to "send" each solution
85+
//myGPS.saveConfiguration(); //Save the current settings to flash and BBR
86+
}
87+
88+
void loop()
89+
{
90+
// Only print GNSS millis otherwise we will probably overrun the Serial buffer
91+
new_millis = myGPS.getMillisecond(); // Get the latest millis (using AutoPVT)
92+
if (new_millis != old_millis) // Only print millis when it changes
93+
{
94+
if (new_millis < 10) Serial.print(F("0")); // Pad zeros
95+
if (new_millis < 100) Serial.print(F("0")); // Pad zeros
96+
Serial.println(new_millis);
97+
old_millis = new_millis; // Update old_millis
98+
}
99+
delay(5); // Let's limit how often we call checkUbloxInternal via getPVT
100+
}

src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,22 @@ boolean SFE_UBLOX_GPS::begin(Stream &serialPort)
8383

8484
//Enable or disable the printing of sent/response HEX values.
8585
//Use this in conjunction with 'Transport Logging' from the Universal Reader Assistant to see what they're doing that we're not
86-
void SFE_UBLOX_GPS::enableDebugging(Stream &debugPort)
86+
void SFE_UBLOX_GPS::enableDebugging(Stream &debugPort, boolean printLimitedDebug)
8787
{
8888
_debugSerial = &debugPort; //Grab which port the user wants us to use for debugging
89-
90-
_printDebug = true; //Should we print the commands we send? Good for debugging
89+
if (printLimitedDebug == false)
90+
{
91+
_printDebug = true; //Should we print the commands we send? Good for debugging
92+
}
93+
else
94+
{
95+
_printLimitedDebug = true; //Should we print limited debug messages? Good for debugging high navigation rates
96+
}
9197
}
9298
void SFE_UBLOX_GPS::disableDebugging(void)
9399
{
94100
_printDebug = false; //Turn off extra print statements
101+
_printLimitedDebug = false;
95102
}
96103

97104
//Safely print messages
@@ -302,9 +309,9 @@ boolean SFE_UBLOX_GPS::checkUbloxI2C(ubxPacket *incomingUBX, uint8_t requestedCl
302309
if (lsb == 0xFF)
303310
{
304311
//I believe this is a Ublox bug. Device should never present an 0xFF.
305-
if (_printDebug == true)
312+
if ((_printDebug == true) || (_printLimitedDebug == true)) // Print this if doing limited debugging
306313
{
307-
_debugSerial->println(F("checkUbloxI2C: Ublox bug, no bytes available"));
314+
_debugSerial->println(F("checkUbloxI2C: Ublox bug, length lsb is 0xFF"));
308315
}
309316
if (checksumFailurePin >= 0)
310317
{
@@ -336,7 +343,7 @@ boolean SFE_UBLOX_GPS::checkUbloxI2C(ubxPacket *incomingUBX, uint8_t requestedCl
336343
//Clear the MSbit
337344
bytesAvailable &= ~((uint16_t)1 << 15);
338345

339-
if (_printDebug == true)
346+
if ((_printDebug == true) || (_printLimitedDebug == true)) // Print this if doing limited debugging
340347
{
341348
_debugSerial->print(F("checkUbloxI2C: Bytes available error:"));
342349
_debugSerial->println(bytesAvailable);
@@ -395,7 +402,7 @@ boolean SFE_UBLOX_GPS::checkUbloxI2C(ubxPacket *incomingUBX, uint8_t requestedCl
395402
{
396403
if (incoming == 0x7F)
397404
{
398-
if (_printDebug == true)
405+
if ((_printDebug == true) || (_printLimitedDebug == true)) // Print this if doing limited debugging
399406
{
400407
_debugSerial->println(F("checkUbloxU2C: Ublox error, module not ready with data"));
401408
}
@@ -809,7 +816,7 @@ void SFE_UBLOX_GPS::processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_t
809816
incomingUBX->classAndIDmatch = SFE_UBLOX_PACKET_VALIDITY_NOT_VALID; // If we have a match, set the classAndIDmatch flag to not valid
810817
}
811818

812-
if (_printDebug == true)
819+
if ((_printDebug == true) || (_printLimitedDebug == true)) // Print this if doing limited debugging
813820
{
814821
//Drive an external pin to allow for easier logic analyzation
815822
if (checksumFailurePin >= 0)

src/SparkFun_Ublox_Arduino_Library.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ class SFE_UBLOX_GPS
615615

616616
boolean getRELPOSNED(uint16_t maxWait = 1100); //Get Relative Positioning Information of the NED frame
617617

618-
void enableDebugging(Stream &debugPort = Serial); //Given a port to print to, enable debug messages
618+
void enableDebugging(Stream &debugPort = Serial, boolean printLimitedDebug = false); //Given a port to print to, enable debug messages. Default to all, not limited.
619619
void disableDebugging(void); //Turn off debug statements
620620
void debugPrint(char *message); //Safely print debug statements
621621
void debugPrintln(char *message); //Safely print debug statements
@@ -823,6 +823,7 @@ class SFE_UBLOX_GPS
823823
//This can be changed using the ublox configuration software
824824

825825
boolean _printDebug = false; //Flag to print the serial commands we are sending to the Serial port for debug
826+
boolean _printLimitedDebug = false; //Flag to print limited debug messages. Useful for I2C debugging or high navigation rates
826827

827828
//The packet buffers
828829
//These are pointed at from within the ubxPacket

0 commit comments

Comments
 (0)