Skip to content

Commit c31fe53

Browse files
authored
Merge pull request #2 from sparkfun/release_candidate
v2.0.1 : Adding time pulse examples
2 parents e3e9b83 + c3c5c1f commit c31fe53

File tree

7 files changed

+444
-1
lines changed

7 files changed

+444
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/*
2+
Time Pulse Parameters - Bullet Time (https://en.wikipedia.org/wiki/Bullet_time)
3+
By: Paul Clark (PaulZC)
4+
Date: January 13th, 2021
5+
6+
License: MIT. See license file for more information but you can
7+
basically do whatever you want with this code.
8+
9+
This example shows how to change the time pulse parameters and configure the TIMEPULSE (PPS)
10+
pin to produce a pulse once per second but with an adjustable delay. You could use this to
11+
trigger multiple cameras and replicate the "bullet time" effect.
12+
13+
The SparkFun GPS-RTK-SMA Breakout - ZED-F9P (Qwiic) (https://www.sparkfun.com/products/16481)
14+
has solder pads which will let you connect an SMA connector to the TIMEPULSE signal. Need an
15+
accurate timelapse camera shutter signal? This is the product for you!
16+
17+
Feel like supporting open source hardware?
18+
Buy a board from SparkFun!
19+
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
20+
NEO-M8P RTK: https://www.sparkfun.com/products/15005
21+
SAM-M8Q: https://www.sparkfun.com/products/15106
22+
23+
Hardware Connections:
24+
Plug a Qwiic cable into the GNSS and a BlackBoard
25+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
26+
Open the serial monitor at 115200 baud to see the output
27+
*/
28+
29+
#include <Wire.h> //Needed for I2C to GNSS
30+
31+
#include "SparkFun_u-blox_GNSS_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
32+
SFE_UBLOX_GNSS myGNSS;
33+
34+
void setup()
35+
{
36+
Serial.begin(115200);
37+
while (!Serial)
38+
; //Wait for user to open terminal
39+
Serial.println(F("SparkFun u-blox Example"));
40+
41+
Wire.begin();
42+
43+
//myGNSS.enableDebugging(); // Uncomment this line to enable debug messages
44+
45+
if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
46+
{
47+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
48+
while (1)
49+
;
50+
}
51+
52+
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
53+
54+
// Create storage for the time pulse parameters
55+
UBX_CFG_TP5_data_t timePulseParameters;
56+
57+
// Get the time pulse parameters
58+
if (myGNSS.getTimePulseParameters(&timePulseParameters) == false)
59+
{
60+
Serial.println(F("getTimePulseParameters failed! Freezing..."));
61+
while (1) ; // Do nothing more
62+
}
63+
64+
// Print the CFG TP5 version
65+
Serial.print(F("UBX_CFG_TP5 version: "));
66+
Serial.println(timePulseParameters.version);
67+
68+
timePulseParameters.tpIdx = 0; // Select the TIMEPULSE pin
69+
//timePulseParameters.tpIdx = 1; // Or we could select the TIMEPULSE2 pin instead, if the module has one
70+
71+
// We can configure the time pulse pin to produce a defined frequency or period
72+
// Here is how to set the period:
73+
74+
// Let's say that we want our pulse-per-second to be as accurate as possible. So, let's tell the module
75+
// to generate no signal while it is _locking_ to GNSS time. We want the signal to start only when the module is
76+
// _locked_ to GNSS time.
77+
timePulseParameters.freqPeriod = 0; // Set the frequency/period to zero
78+
timePulseParameters.pulseLenRatio = 0; // Set the pulse ratio to zero
79+
80+
// When the module is _locked_ to GNSS time, make it generate a 0.1 second pulse once per second
81+
timePulseParameters.freqPeriodLock = 1000000; // Set the period to 1,000,000 us
82+
timePulseParameters.pulseLenRatioLock = 100000; // Set the pulse length to 0.1s (100,000 us)
83+
timePulseParameters.flags.bits.polarity = 1; // Set the polarity to "1" (high for 0.1s, low for 0.9s, rising edge at top of second)
84+
85+
// We can use userConfigDelay to delay the pulse for each camera. The delay needs to be negative for this example.
86+
// We can delay the pulse by +/- 2^31 nanoseconds (+/- 2.147 seconds)
87+
//timePulseParameters.userConfigDelay = 0; // Camera 1: delay the pulse by 0ns
88+
//timePulseParameters.userConfigDelay = -100000000; // Camera 2: delay the pulse by 0.1s (100,000,000 ns)
89+
//timePulseParameters.userConfigDelay = -200000000; // Camera 3: delay the pulse by 0.2s (200,000,000 ns)
90+
timePulseParameters.userConfigDelay = -300000000; // Camera 4: delay the pulse by 0.3s (300,000,000 ns)
91+
//timePulseParameters.userConfigDelay = -400000000; // Camera 5: delay the pulse by 0.4s (400,000,000 ns)
92+
//timePulseParameters.userConfigDelay = -500000000; // Camera 6: delay the pulse by 0.5s (500,000,000 ns)
93+
//timePulseParameters.userConfigDelay = -600000000; // Camera 7: delay the pulse by 0.6s (600,000,000 ns)
94+
//timePulseParameters.userConfigDelay = -700000000; // Camera 8: delay the pulse by 0.7s (700,000,000 ns)
95+
//timePulseParameters.userConfigDelay = -800000000; // Camera 9: delay the pulse by 0.8s (800,000,000 ns)
96+
//timePulseParameters.userConfigDelay = -900000000; // Camera 10: delay the pulse by 0.9s (900,000,000 ns)
97+
98+
timePulseParameters.flags.bits.active = 1; // Make sure the active flag is set to enable the time pulse. (Set to 0 to disable.)
99+
timePulseParameters.flags.bits.lockedOtherSet = 1; // Tell the module to use freqPeriod while locking and freqPeriodLock when locked to GNSS time
100+
timePulseParameters.flags.bits.isFreq = 0; // Tell the module that we want to set the period (not the frequency)
101+
timePulseParameters.flags.bits.isLength = 1; // Tell the module that pulseLenRatio is a length (in us) - not a duty cycle
102+
103+
// Now set the time pulse parameters
104+
if (myGNSS.setTimePulseParameters(&timePulseParameters) == false)
105+
{
106+
Serial.println(F("setTimePulseParameters failed!"));
107+
}
108+
else
109+
{
110+
Serial.println(F("Success!"));
111+
}
112+
113+
// Finally, save the time pulse parameters in battery-backed memory so the pulse will automatically restart at power on
114+
myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_NAVCONF); // Save the configuration
115+
}
116+
117+
void loop()
118+
{
119+
// Nothing to do here
120+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
Time Pulse Parameters - Frequency
3+
By: Paul Clark (PaulZC)
4+
Date: January 13th, 2021
5+
6+
License: MIT. See license file for more information but you can
7+
basically do whatever you want with this code.
8+
9+
This example shows how to change the time pulse parameters and configure the TIMEPULSE (PPS)
10+
pin to produce a 1kHz squarewave
11+
12+
The SparkFun GPS-RTK-SMA Breakout - ZED-F9P (Qwiic) (https://www.sparkfun.com/products/16481)
13+
has solder pads which will let you connect an SMA connector to the TIMEPULSE signal. Need an
14+
accurate frequency or clock source for your latest project? This is the product for you!
15+
16+
Feel like supporting open source hardware?
17+
Buy a board from SparkFun!
18+
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
19+
NEO-M8P RTK: https://www.sparkfun.com/products/15005
20+
SAM-M8Q: https://www.sparkfun.com/products/15106
21+
22+
Hardware Connections:
23+
Plug a Qwiic cable into the GNSS and a BlackBoard
24+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
25+
Open the serial monitor at 115200 baud to see the output
26+
*/
27+
28+
#include <Wire.h> //Needed for I2C to GNSS
29+
30+
#include "SparkFun_u-blox_GNSS_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
31+
SFE_UBLOX_GNSS myGNSS;
32+
33+
void setup()
34+
{
35+
Serial.begin(115200);
36+
while (!Serial)
37+
; //Wait for user to open terminal
38+
Serial.println(F("SparkFun u-blox Example"));
39+
40+
Wire.begin();
41+
42+
//myGNSS.enableDebugging(); // Uncomment this line to enable debug messages
43+
44+
if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
45+
{
46+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
47+
while (1)
48+
;
49+
}
50+
51+
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
52+
53+
// Create storage for the time pulse parameters
54+
UBX_CFG_TP5_data_t timePulseParameters;
55+
56+
// Get the time pulse parameters
57+
if (myGNSS.getTimePulseParameters(&timePulseParameters) == false)
58+
{
59+
Serial.println(F("getTimePulseParameters failed! Freezing..."));
60+
while (1) ; // Do nothing more
61+
}
62+
63+
// Print the CFG TP5 version
64+
Serial.print(F("UBX_CFG_TP5 version: "));
65+
Serial.println(timePulseParameters.version);
66+
67+
timePulseParameters.tpIdx = 0; // Select the TIMEPULSE pin
68+
//timePulseParameters.tpIdx = 1; // Or we could select the TIMEPULSE2 pin instead, if the module has one
69+
70+
// We can configure the time pulse pin to produce a defined frequency or period
71+
// Here is how to set the frequency:
72+
73+
// While the module is _locking_ to GNSS time, make it generate 2kHz
74+
timePulseParameters.freqPeriod = 2000; // Set the frequency/period to 2000Hz
75+
timePulseParameters.pulseLenRatio = 0x55555555; // Set the pulse ratio to 1/3 * 2^32 to produce 33:67 mark:space
76+
77+
// When the module is _locked_ to GNSS time, make it generate 1kHz
78+
timePulseParameters.freqPeriodLock = 1000; // Set the frequency/period to 1000Hz
79+
timePulseParameters.pulseLenRatioLock = 0x80000000; // Set the pulse ratio to 1/2 * 2^32 to produce 50:50 mark:space
80+
81+
timePulseParameters.flags.bits.active = 1; // Make sure the active flag is set to enable the time pulse. (Set to 0 to disable.)
82+
timePulseParameters.flags.bits.lockedOtherSet = 1; // Tell the module to use freqPeriod while locking and freqPeriodLock when locked to GNSS time
83+
timePulseParameters.flags.bits.isFreq = 1; // Tell the module that we want to set the frequency (not the period)
84+
timePulseParameters.flags.bits.isLength = 0; // Tell the module that pulseLenRatio is a ratio / duty cycle (* 2^-32) - not a length (in us)
85+
timePulseParameters.flags.bits.polarity = 1; // Tell the module that we want the rising edge at the top of second. (Set to 0 for falling edge.)
86+
87+
// Now set the time pulse parameters
88+
if (myGNSS.setTimePulseParameters(&timePulseParameters) == false)
89+
{
90+
Serial.println(F("setTimePulseParameters failed!"));
91+
}
92+
else
93+
{
94+
Serial.println(F("Success!"));
95+
}
96+
}
97+
98+
void loop()
99+
{
100+
// Nothing to do here
101+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
Time Pulse Parameters - Period
3+
By: Paul Clark (PaulZC)
4+
Date: January 13th, 2021
5+
6+
License: MIT. See license file for more information but you can
7+
basically do whatever you want with this code.
8+
9+
This example shows how to change the time pulse parameters and configure the TIMEPULSE (PPS)
10+
pin to produce a 1 second pulse every 30 seconds. What's really cool is that if you run this
11+
example on two GNSS boards, the pulses are precisely synchronised!
12+
13+
The SparkFun GPS-RTK-SMA Breakout - ZED-F9P (Qwiic) (https://www.sparkfun.com/products/16481)
14+
has solder pads which will let you connect an SMA connector to the TIMEPULSE signal. Need an
15+
accurate timelapse camera shutter signal? This is the product for you!
16+
17+
Feel like supporting open source hardware?
18+
Buy a board from SparkFun!
19+
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
20+
NEO-M8P RTK: https://www.sparkfun.com/products/15005
21+
SAM-M8Q: https://www.sparkfun.com/products/15106
22+
23+
Hardware Connections:
24+
Plug a Qwiic cable into the GNSS and a BlackBoard
25+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
26+
Open the serial monitor at 115200 baud to see the output
27+
*/
28+
29+
#include <Wire.h> //Needed for I2C to GNSS
30+
31+
#include "SparkFun_u-blox_GNSS_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
32+
SFE_UBLOX_GNSS myGNSS;
33+
34+
void setup()
35+
{
36+
Serial.begin(115200);
37+
while (!Serial)
38+
; //Wait for user to open terminal
39+
Serial.println(F("SparkFun u-blox Example"));
40+
41+
Wire.begin();
42+
43+
//myGNSS.enableDebugging(); // Uncomment this line to enable debug messages
44+
45+
if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
46+
{
47+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
48+
while (1)
49+
;
50+
}
51+
52+
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
53+
54+
// Create storage for the time pulse parameters
55+
UBX_CFG_TP5_data_t timePulseParameters;
56+
57+
// Get the time pulse parameters
58+
if (myGNSS.getTimePulseParameters(&timePulseParameters) == false)
59+
{
60+
Serial.println(F("getTimePulseParameters failed! Freezing..."));
61+
while (1) ; // Do nothing more
62+
}
63+
64+
// Print the CFG TP5 version
65+
Serial.print(F("UBX_CFG_TP5 version: "));
66+
Serial.println(timePulseParameters.version);
67+
68+
timePulseParameters.tpIdx = 0; // Select the TIMEPULSE pin
69+
//timePulseParameters.tpIdx = 1; // Or we could select the TIMEPULSE2 pin instead, if the module has one
70+
71+
// We can configure the time pulse pin to produce a defined frequency or period
72+
// Here is how to set the period:
73+
74+
// Let's say that we want our 1 pulse every 30 seconds to be as accurate as possible. So, let's tell the module
75+
// to generate no signal while it is _locking_ to GNSS time. We want the signal to start only when the module is
76+
// _locked_ to GNSS time.
77+
timePulseParameters.freqPeriod = 0; // Set the frequency/period to zero
78+
timePulseParameters.pulseLenRatio = 0; // Set the pulse ratio to zero
79+
80+
// When the module is _locked_ to GNSS time, make it generate a 1 second pulse every 30 seconds
81+
// (Although the period can be a maximum of 2^32 microseconds (over one hour), the upper limit appears to be around 33 seconds)
82+
timePulseParameters.freqPeriodLock = 30000000; // Set the period to 30,000,000 us
83+
timePulseParameters.pulseLenRatioLock = 1000000; // Set the pulse length to 1,000,000 us
84+
85+
timePulseParameters.flags.bits.active = 1; // Make sure the active flag is set to enable the time pulse. (Set to 0 to disable.)
86+
timePulseParameters.flags.bits.lockedOtherSet = 1; // Tell the module to use freqPeriod while locking and freqPeriodLock when locked to GNSS time
87+
timePulseParameters.flags.bits.isFreq = 0; // Tell the module that we want to set the period (not the frequency)
88+
timePulseParameters.flags.bits.isLength = 1; // Tell the module that pulseLenRatio is a length (in us) - not a duty cycle
89+
timePulseParameters.flags.bits.polarity = 1; // Tell the module that we want the rising edge at the top of second. (Set to 0 for falling edge.)
90+
91+
// Now set the time pulse parameters
92+
if (myGNSS.setTimePulseParameters(&timePulseParameters) == false)
93+
{
94+
Serial.println(F("setTimePulseParameters failed!"));
95+
}
96+
else
97+
{
98+
Serial.println(F("Success!"));
99+
}
100+
101+
// Finally, save the time pulse parameters in battery-backed memory so the pulse will automatically restart at power on
102+
myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_NAVCONF); // Save the configuration
103+
}
104+
105+
void loop()
106+
{
107+
// Nothing to do here
108+
}

Diff for: library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun u-blox GNSS Arduino Library
2-
version=2.0.0
2+
version=2.0.1
33
author=SparkFun Electronics <[email protected]>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library for I2C and Serial Communication with u-blox modules

0 commit comments

Comments
 (0)