sparkfun / SparkFun_u-blox_GNSS_Arduino_Library

An Arduino library which allows you to communicate seamlessly with the full range of u-blox GNSS modules
Other
224 stars 100 forks source link

Polling data frequency not correct #220

Closed Nick-C130 closed 4 months ago

Nick-C130 commented 4 months ago

Subject of the issue

After setting nav frequency to 10hz it still takes about 2-3 seconds to poll 9 sets of data

Your workbench

M10Q hooked up to teensy 4.0

Steps to reproduce

Code is as follows

  Wire1.begin();
  Wire1.setClock(400000);
  GNSS.begin(Wire1,0x42,500,false);
  GNSS.setI2COutput(COM_TYPE_UBX); 
  GNSS.setNavigationFrequency(10,100);
  GNSS.setDynamicModel(8);
  GNSS.saveConfiguration();
}

and

  unsigned long sT = millis();
  gpsData->latitude = GNSS.getLatitude();
  Serial.print(millis()-sT);
  gpsData->longitude = GNSS.getLongitude();
  HostSerial.print(",");
  Serial.print(millis()-sT);
  gpsData->altitude = GNSS.getAltitude();
  HostSerial.print(",");
  Serial.print(millis()-sT);
  gpsData->numSatellites = GNSS.getSIV();
  HostSerial.print(",");
  Serial.print(millis()-sT);
  gpsData->hdop = GNSS.getHorizontalDOP();//1 second
  HostSerial.print(",");
  Serial.print(millis()-sT);
  gpsData->vdop = GNSS.getVerticalDOP();
  HostSerial.print(",");
  Serial.print(millis()-sT);
  gpsData->hours = GNSS.getHour();//Taking 1 second
  HostSerial.print(",");
  Serial.print(millis()-sT);
  gpsData->minutes = GNSS.getMinute();
  HostSerial.print(",");
  Serial.print(millis()-sT);
  gpsData->seconds = GNSS.getSecond();
  HostSerial.print(",");
  Serial.println(millis()-sT);
  return true;
}

Terminal gives 0,75,75,75,1176,2276,2276,2276,2276 Tried with just the last time and its only adding a few ms to print this often

Expected behavior

Able to pull data in much less then 100ms

Actual behavior

Taking about 2-3s to pull data

PaulZC commented 4 months ago

Hi @Nick-C130 ,

You need to use Periodic ("Auto"), not Polling, to achieve the fastest read speeds. Please see:

https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/blob/main/examples/Example13_PVT/Example1_AutoPVT/Example1_AutoPVT.ino

https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/blob/main/examples/Callbacks/CallbackExample1_NAV_PVT/CallbackExample1_NAV_PVT.ino

I don't know which module you are using, but you will (probably) also need to disable UART1. By default, UART1 will be trying to output the standard NMEA messages at the standard baud rate. At 10Hz, those messages can overload the port. You can disable it using myGNSS.setUART1Output(0);

Also, be careful how many constellations you are using. It depends on the module, but you may need to disable one or more constellations to achieve the fastest navigation rates:

  myGNSS.enableGNSS(true, SFE_UBLOX_GNSS_ID_GPS); // Make sure GPS is enabled (we must leave at least one major GNSS enabled!)
  myGNSS.enableGNSS(false, SFE_UBLOX_GNSS_ID_SBAS); // Disable SBAS
  myGNSS.enableGNSS(false, SFE_UBLOX_GNSS_ID_GALILEO); // Disable Galileo
  myGNSS.enableGNSS(false, SFE_UBLOX_GNSS_ID_BEIDOU); // Disable BeiDou
  myGNSS.enableGNSS(false, SFE_UBLOX_GNSS_ID_IMES); // Disable IMES
  myGNSS.enableGNSS(false, SFE_UBLOX_GNSS_ID_QZSS); // Disable QZSS
  myGNSS.enableGNSS(false, SFE_UBLOX_GNSS_ID_GLONASS); // Disable GLONASS

It might be beneficial to upgrade to v3 of the library.

Best wishes, Paul