Skip to content

Commit ea5871d

Browse files
authored
Merge pull request #13 from sparkfun/release_candidate
Version 3.0.6
2 parents f95988e + 1b14c47 commit ea5871d

File tree

7 files changed

+544
-20
lines changed

7 files changed

+544
-20
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
Displaying the TIM TP timing information for the _next_ TP time pulse
3+
(PVT provides the time of the _previous_ pulse)
4+
By: Paul Clark
5+
SparkFun Electronics
6+
Date: March 24th, 2023
7+
License: MIT. See license file for more information.
8+
9+
This example shows how to query a u-blox module for the TIM TP time-pulse-of-week.
10+
This contains the timing information for the _next_ time pulse. I.e. it is output
11+
_ahead_ of time. PVT contains the time of the _previous_ pulse.
12+
13+
Feel like supporting open source hardware?
14+
Buy a board from SparkFun!
15+
SparkFun GPS-RTK2 - ZED-F9P (GPS-15136) https://www.sparkfun.com/products/15136
16+
SparkFun GPS-RTK-SMA - ZED-F9P (GPS-16481) https://www.sparkfun.com/products/16481
17+
SparkFun MAX-M10S Breakout (GPS-18037) https://www.sparkfun.com/products/18037
18+
SparkFun ZED-F9K Breakout (GPS-18719) https://www.sparkfun.com/products/18719
19+
SparkFun ZED-F9R Breakout (GPS-16344) https://www.sparkfun.com/products/16344
20+
21+
Hardware Connections:
22+
Plug a Qwiic cable into the GNSS and a BlackBoard
23+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
24+
Open the serial monitor at 115200 baud to see the output
25+
*/
26+
27+
#include <Wire.h> //Needed for I2C to GNSS
28+
29+
#include <SparkFun_u-blox_GNSS_v3.h> //http://librarymanager/All#SparkFun_u-blox_GNSS_v3
30+
SFE_UBLOX_GNSS myGNSS;
31+
32+
void setup()
33+
{
34+
delay(1000);
35+
36+
Serial.begin(115200);
37+
Serial.println("SparkFun u-blox Example");
38+
39+
Wire.begin();
40+
41+
while (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
42+
{
43+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring."));
44+
}
45+
46+
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
47+
}
48+
49+
void loop()
50+
{
51+
/*
52+
// Read the time pulse of week and construct the microseconds
53+
if (myGNSS.getTIMTP()) //getTIMTP will return true if new fresh data is received
54+
{
55+
uint16_t week = myGNSS.getTIMTPweek(); //Get the time base week number
56+
uint32_t towMS = myGNSS.getTIMTPtowMS(); //Get the time base pulse-of-week (ms)
57+
uint32_t towSubMS = myGNSS.getTIMTPtowSubMS(); //Read the sub-millisecond data (ms * 2^-32)
58+
59+
double tow = towMS;
60+
tow /= 1000.0; //Convert to seconds
61+
62+
double subMS = towSubMS;
63+
subMS *= pow(2.0, -32.0); //Convert to ms
64+
subMS /= 1000.0; //Convert to seconds
65+
66+
tow += subMS; //Construct the time of week
67+
68+
Serial.print("TIM TP: week: ");
69+
Serial.print(week); //Print the time base week number
70+
Serial.print(" tow: ");
71+
Serial.println(tow, 6); //Print the time of week with six deimal places (i.e. show the microseconds)
72+
}
73+
*/
74+
75+
//getTIMTP and getPVT will return true if fresh data is available.
76+
//Note: both methods poll data from the GNSS:
77+
// getTIMTP will poll TIM TP, wait and return true when the TIM TP data arrives.
78+
// Then getPVT will poll NAV PVT, wait and return true when the NAV PVT data arrives.
79+
// The TIM TP data will then be one second old.
80+
// Because TIM TP provides the time of the _next_ time pulse and NAV PVT provides
81+
// the time of the _previous_ time pulse, the two Epochs should be the same!
82+
if (myGNSS.getTIMTP() && myGNSS.getPVT())
83+
{
84+
// Read the time pulse of week as Unix Epoch
85+
// CAUTION! Assumes the time base is UTC and the week number is GPS
86+
uint32_t microsTP;
87+
uint32_t epochTP = myGNSS.getTIMTPAsEpoch(microsTP); //Read the next time pulse of week as Unix Epoch
88+
89+
Serial.print("TIM TP as Epoch: ");
90+
Serial.print(epochTP); //Print the time of the next pulse
91+
Serial.print(".");
92+
if (microsTP < 100000) Serial.print("0"); //Pad the zeros if needed
93+
if (microsTP < 10000) Serial.print("0");
94+
if (microsTP < 1000) Serial.print("0");
95+
if (microsTP < 100) Serial.print("0");
96+
if (microsTP < 10) Serial.print("0");
97+
Serial.println(microsTP);
98+
99+
// Read the PVT time of week as Unix Epoch
100+
uint32_t microsPVT;
101+
uint32_t epochPVT = myGNSS.getUnixEpoch(microsPVT); //Read the time of week as Unix Epoch
102+
103+
Serial.print("NAV PVT as Epoch: ");
104+
Serial.print(epochPVT); //Print the time of the next pulse
105+
Serial.print(".");
106+
if (microsPVT < 100000) Serial.print("0"); //Pad the zeros if needed
107+
if (microsPVT < 10000) Serial.print("0");
108+
if (microsPVT < 1000) Serial.print("0");
109+
if (microsPVT < 100) Serial.print("0");
110+
if (microsPVT < 10) Serial.print("0");
111+
Serial.println(microsPVT);
112+
113+
Serial.println();
114+
}
115+
}

keywords.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ UBX_RXM_MEASX_data_t KEYWORD1
6060
UBX_RXM_QZSSL6_message_data_t KEYWORD1
6161

6262
UBX_TIM_TM2_data_t KEYWORD1
63+
UBX_TIM_TP_data_t KEYWORD1
6364

6465
UBX_ESF_ALG_data_t KEYWORD1
6566
UBX_ESF_INS_data_t KEYWORD1
@@ -491,6 +492,15 @@ assumeAutoTIMTM2 KEYWORD2
491492
flushTIMTM2 KEYWORD2
492493
logTIMTM2 KEYWORD2
493494

495+
getTIMTP KEYWORD2
496+
setAutoTIMTP KEYWORD2
497+
setAutoTIMTPrate KEYWORD2
498+
setAutoTIMTPcallback KEYWORD2
499+
setAutoTIMTPcallbackPtr KEYWORD2
500+
assumeAutoTIMTP KEYWORD2
501+
flushTIMTP KEYWORD2
502+
logTIMTP KEYWORD2
503+
494504
getEsfAlignment KEYWORD2
495505
getESFALG KEYWORD2
496506
setAutoESFALG KEYWORD2
@@ -666,6 +676,11 @@ getRelPosAccD KEYWORD2
666676
getAOPSTATUSuseAOP KEYWORD2
667677
getAOPSTATUSstatus KEYWORD2
668678

679+
getTIMTPtowMS KEYWORD2
680+
getTIMTPtowSubMS KEYWORD2
681+
getTIMTPweek KEYWORD2
682+
getTIMTPAsEpoch KEYWORD2
683+
669684
getESFroll KEYWORD2
670685
getESFpitch KEYWORD2
671686
getESFyaw KEYWORD2
@@ -904,6 +919,7 @@ UBX_RXM_SPARTN LITERAL1
904919
UBX_RXM_QZSSL6 LITERAL1
905920

906921
UBX_TIM_TM2 LITERAL1
922+
UBX_TIM_TP LITERAL1
907923

908924
UBX_RTCM_MSB LITERAL1
909925
UBX_RTCM_1005 LITERAL1

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun u-blox GNSS v3
2-
version=3.0.5
2+
version=3.0.6
33
author=SparkFun Electronics <[email protected]>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules<br/><br/>

0 commit comments

Comments
 (0)