sparkfun / SparkFun_u-blox_GNSS_v3

An Arduino library which allows you to communicate seamlessly with u-blox GNSS modules using the Configuration Interface
Other
52 stars 24 forks source link

getMeasurementRate() returns inconsistent values #58

Closed ozankilic7 closed 1 month ago

ozankilic7 commented 2 months ago

Hello,

I have been trying to use getMeasurementRate() verify the configuration of a SAM-M10Q module on a custom board. However, it returns "16329" value repeatedly when it pushes the data rate command. The command is pushed right after the module is powered on. I have no valid position due to no satellite coverage. I think that explains the initial "0" value.

After 50+ tries it actually returns expected value. (Still no valid position) Not sure what it could be related to.

ublox_getMeas

Here is the part I request the data rate:

 // Data rate check
  measRate = myGNSS.getMeasurementRate();  // Get the measurement rate of the module
  Serial.print("Ublox Rate in Hz: ");
  Serial.println(measRate);
  while (measRate != 50) {
    Serial.print("Trying again..");
    push_ublox_command(20Hz, sizeof(20Hz));
    delay(1000);
    measRate = myGNSS.getMeasurementRate();  // Get the measurement rate of the module
    Serial.println(measRate);
  }

Your workbench

It is wired to ESP32 via UART.

Steps to reproduce

Immediately after connecting SAM-M10Q via UART serial, request the measurement rate with getMeasurementRate() .

PaulZC commented 1 month ago

Hi Ozan (@ozankilic7 ),

You haven't shared enough of your code for me to replicate your issue. What type is measRate? What code is behind push_ublox_command?

There are two ways to call getMeasurementRate. You are using the 'unsafe' way. See below for the 'safe' way.

getMeasurementRate is a misnomer. The function actually returns the measurement interval in milliseconds. The default value is 1000 (1000ms = 1Hz). To get the navigation frequency in Hz, call getNavigationFrequency.

I don't have a SAM-M10Q here. Below is what I see on the MAX-M10S - almost the same module. The code is running on an ESP32 Thing Plus C, connected to UART1.

I suspect the error is in your push_ublox_command. Why not call myGNSS.setMeasurementRate(50) ?

Be careful with your constellations and baud rate. The SAM-M10Q will run at 20Hz, but only when tracking GPS + GAL in High Performance mode - configuration required. With all four constellations enabled, in default mode, 4Hz is the fastest you can go. myGNSS.enableGNSS will help here. Be careful that you do not overload UART1. At 38400 baud and high navigation rates, even the default NMEA messages may overload the port.

image

ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1288
load:0x40078000,len:13872
load:0x40080400,len:4
ho 8 tail 4 room 4
load:0x40080404,len:3048
entry 0x40080590

SparkFun u-blox Example
Interval in ms: 1000
Interval in ms: 1000
Rate in Hz: 1
Rate in Hz: 1
#include <SparkFun_u-blox_GNSS_v3.h> //http://librarymanager/All#SparkFun_u-blox_GNSS_v3

SFE_UBLOX_GNSS_SERIAL myGNSS;

#define mySerial Serial1 // Use Serial1 to connect to the GNSS module. Change this if required

void setup()
{
  Serial.begin(115200);
  delay(1000); 
  Serial.println();
  Serial.println("SparkFun u-blox Example");

  mySerial.begin(38400); // u-blox F9 and M10 modules default to 38400 baud. Change this if required

  //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial

  while (myGNSS.begin(mySerial) == false) //Connect to the u-blox module using mySerial (defined above)
  {
    Serial.println(F("u-blox GNSS not detected. Retrying..."));
    delay (1000);
  }

  // Safe method:
  uint16_t measRate;
  if (myGNSS.getMeasurementRate(&measRate) == true)
  {
    Serial.print("Interval in ms: ");
    Serial.println(measRate);
  }
  else
  {
    Serial.println("getMeasurementRate failed");
  }

  // Unsafe method:
  measRate = myGNSS.getMeasurementRate();
  Serial.print("Interval in ms: ");
  Serial.println(measRate);

  // Safe method:
  uint8_t navFreq;
  if (myGNSS.getNavigationFrequency(&navFreq) == true) // Note: if the measurementRate (which is actually a period) is more than 1000ms, this will return zero
  {
    Serial.print("Rate in Hz: ");
    Serial.println(navFreq);
  }
  else
  {
    Serial.println("getMeasurementRate failed");
  }

  // Unsafe method:
  navFreq = myGNSS.getNavigationFrequency();
  Serial.print("Rate in Hz: ");
  Serial.println(navFreq);
}

void loop()
{
}

Closing... Please reopen if you need more help with this.

Best wishes, Paul