Skip to content

Version 3.0.6 #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 24, 2023
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
115 changes: 115 additions & 0 deletions examples/Basics/Example32_TIMTP/Example32_TIMTP.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
Displaying the TIM TP timing information for the _next_ TP time pulse
(PVT provides the time of the _previous_ pulse)
By: Paul Clark
SparkFun Electronics
Date: March 24th, 2023
License: MIT. See license file for more information.

This example shows how to query a u-blox module for the TIM TP time-pulse-of-week.
This contains the timing information for the _next_ time pulse. I.e. it is output
_ahead_ of time. PVT contains the time of the _previous_ pulse.

Feel like supporting open source hardware?
Buy a board from SparkFun!
SparkFun GPS-RTK2 - ZED-F9P (GPS-15136) https://www.sparkfun.com/products/15136
SparkFun GPS-RTK-SMA - ZED-F9P (GPS-16481) https://www.sparkfun.com/products/16481
SparkFun MAX-M10S Breakout (GPS-18037) https://www.sparkfun.com/products/18037
SparkFun ZED-F9K Breakout (GPS-18719) https://www.sparkfun.com/products/18719
SparkFun ZED-F9R Breakout (GPS-16344) https://www.sparkfun.com/products/16344

Hardware Connections:
Plug a Qwiic cable into the GNSS 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 <Wire.h> //Needed for I2C to GNSS

#include <SparkFun_u-blox_GNSS_v3.h> //http://librarymanager/All#SparkFun_u-blox_GNSS_v3
SFE_UBLOX_GNSS myGNSS;

void setup()
{
delay(1000);

Serial.begin(115200);
Serial.println("SparkFun u-blox Example");

Wire.begin();

while (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
{
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring."));
}

myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
}

void loop()
{
/*
// Read the time pulse of week and construct the microseconds
if (myGNSS.getTIMTP()) //getTIMTP will return true if new fresh data is received
{
uint16_t week = myGNSS.getTIMTPweek(); //Get the time base week number
uint32_t towMS = myGNSS.getTIMTPtowMS(); //Get the time base pulse-of-week (ms)
uint32_t towSubMS = myGNSS.getTIMTPtowSubMS(); //Read the sub-millisecond data (ms * 2^-32)

double tow = towMS;
tow /= 1000.0; //Convert to seconds

double subMS = towSubMS;
subMS *= pow(2.0, -32.0); //Convert to ms
subMS /= 1000.0; //Convert to seconds

tow += subMS; //Construct the time of week

Serial.print("TIM TP: week: ");
Serial.print(week); //Print the time base week number
Serial.print(" tow: ");
Serial.println(tow, 6); //Print the time of week with six deimal places (i.e. show the microseconds)
}
*/

//getTIMTP and getPVT will return true if fresh data is available.
//Note: both methods poll data from the GNSS:
// getTIMTP will poll TIM TP, wait and return true when the TIM TP data arrives.
// Then getPVT will poll NAV PVT, wait and return true when the NAV PVT data arrives.
// The TIM TP data will then be one second old.
// Because TIM TP provides the time of the _next_ time pulse and NAV PVT provides
// the time of the _previous_ time pulse, the two Epochs should be the same!
if (myGNSS.getTIMTP() && myGNSS.getPVT())
{
// Read the time pulse of week as Unix Epoch
// CAUTION! Assumes the time base is UTC and the week number is GPS
uint32_t microsTP;
uint32_t epochTP = myGNSS.getTIMTPAsEpoch(microsTP); //Read the next time pulse of week as Unix Epoch

Serial.print("TIM TP as Epoch: ");
Serial.print(epochTP); //Print the time of the next pulse
Serial.print(".");
if (microsTP < 100000) Serial.print("0"); //Pad the zeros if needed
if (microsTP < 10000) Serial.print("0");
if (microsTP < 1000) Serial.print("0");
if (microsTP < 100) Serial.print("0");
if (microsTP < 10) Serial.print("0");
Serial.println(microsTP);

// Read the PVT time of week as Unix Epoch
uint32_t microsPVT;
uint32_t epochPVT = myGNSS.getUnixEpoch(microsPVT); //Read the time of week as Unix Epoch

Serial.print("NAV PVT as Epoch: ");
Serial.print(epochPVT); //Print the time of the next pulse
Serial.print(".");
if (microsPVT < 100000) Serial.print("0"); //Pad the zeros if needed
if (microsPVT < 10000) Serial.print("0");
if (microsPVT < 1000) Serial.print("0");
if (microsPVT < 100) Serial.print("0");
if (microsPVT < 10) Serial.print("0");
Serial.println(microsPVT);

Serial.println();
}
}
16 changes: 16 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ UBX_RXM_MEASX_data_t KEYWORD1
UBX_RXM_QZSSL6_message_data_t KEYWORD1

UBX_TIM_TM2_data_t KEYWORD1
UBX_TIM_TP_data_t KEYWORD1

UBX_ESF_ALG_data_t KEYWORD1
UBX_ESF_INS_data_t KEYWORD1
Expand Down Expand Up @@ -491,6 +492,15 @@ assumeAutoTIMTM2 KEYWORD2
flushTIMTM2 KEYWORD2
logTIMTM2 KEYWORD2

getTIMTP KEYWORD2
setAutoTIMTP KEYWORD2
setAutoTIMTPrate KEYWORD2
setAutoTIMTPcallback KEYWORD2
setAutoTIMTPcallbackPtr KEYWORD2
assumeAutoTIMTP KEYWORD2
flushTIMTP KEYWORD2
logTIMTP KEYWORD2

getEsfAlignment KEYWORD2
getESFALG KEYWORD2
setAutoESFALG KEYWORD2
Expand Down Expand Up @@ -666,6 +676,11 @@ getRelPosAccD KEYWORD2
getAOPSTATUSuseAOP KEYWORD2
getAOPSTATUSstatus KEYWORD2

getTIMTPtowMS KEYWORD2
getTIMTPtowSubMS KEYWORD2
getTIMTPweek KEYWORD2
getTIMTPAsEpoch KEYWORD2

getESFroll KEYWORD2
getESFpitch KEYWORD2
getESFyaw KEYWORD2
Expand Down Expand Up @@ -904,6 +919,7 @@ UBX_RXM_SPARTN LITERAL1
UBX_RXM_QZSSL6 LITERAL1

UBX_TIM_TM2 LITERAL1
UBX_TIM_TP LITERAL1

UBX_RTCM_MSB LITERAL1
UBX_RTCM_1005 LITERAL1
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SparkFun u-blox GNSS v3
version=3.0.5
version=3.0.6
author=SparkFun Electronics <[email protected]>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules<br/><br/>
Expand Down
Loading