Skip to content

v2.0.1 : Adding time pulse examples #2

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
Jan 14, 2021
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
Time Pulse Parameters - Bullet Time (https://en.wikipedia.org/wiki/Bullet_time)
By: Paul Clark (PaulZC)
Date: January 13th, 2021

License: MIT. See license file for more information but you can
basically do whatever you want with this code.

This example shows how to change the time pulse parameters and configure the TIMEPULSE (PPS)
pin to produce a pulse once per second but with an adjustable delay. You could use this to
trigger multiple cameras and replicate the "bullet time" effect.

The SparkFun GPS-RTK-SMA Breakout - ZED-F9P (Qwiic) (https://www.sparkfun.com/products/16481)
has solder pads which will let you connect an SMA connector to the TIMEPULSE signal. Need an
accurate timelapse camera shutter signal? This is the product for you!

Feel like supporting open source hardware?
Buy a board from SparkFun!
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
NEO-M8P RTK: https://www.sparkfun.com/products/15005
SAM-M8Q: https://www.sparkfun.com/products/15106

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_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
SFE_UBLOX_GNSS myGNSS;

void setup()
{
Serial.begin(115200);
while (!Serial)
; //Wait for user to open terminal
Serial.println(F("SparkFun u-blox Example"));

Wire.begin();

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

if (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. Freezing."));
while (1)
;
}

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

// Create storage for the time pulse parameters
UBX_CFG_TP5_data_t timePulseParameters;

// Get the time pulse parameters
if (myGNSS.getTimePulseParameters(&timePulseParameters) == false)
{
Serial.println(F("getTimePulseParameters failed! Freezing..."));
while (1) ; // Do nothing more
}

// Print the CFG TP5 version
Serial.print(F("UBX_CFG_TP5 version: "));
Serial.println(timePulseParameters.version);

timePulseParameters.tpIdx = 0; // Select the TIMEPULSE pin
//timePulseParameters.tpIdx = 1; // Or we could select the TIMEPULSE2 pin instead, if the module has one

// We can configure the time pulse pin to produce a defined frequency or period
// Here is how to set the period:

// Let's say that we want our pulse-per-second to be as accurate as possible. So, let's tell the module
// to generate no signal while it is _locking_ to GNSS time. We want the signal to start only when the module is
// _locked_ to GNSS time.
timePulseParameters.freqPeriod = 0; // Set the frequency/period to zero
timePulseParameters.pulseLenRatio = 0; // Set the pulse ratio to zero

// When the module is _locked_ to GNSS time, make it generate a 0.1 second pulse once per second
timePulseParameters.freqPeriodLock = 1000000; // Set the period to 1,000,000 us
timePulseParameters.pulseLenRatioLock = 100000; // Set the pulse length to 0.1s (100,000 us)
timePulseParameters.flags.bits.polarity = 1; // Set the polarity to "1" (high for 0.1s, low for 0.9s, rising edge at top of second)

// We can use userConfigDelay to delay the pulse for each camera. The delay needs to be negative for this example.
// We can delay the pulse by +/- 2^31 nanoseconds (+/- 2.147 seconds)
//timePulseParameters.userConfigDelay = 0; // Camera 1: delay the pulse by 0ns
//timePulseParameters.userConfigDelay = -100000000; // Camera 2: delay the pulse by 0.1s (100,000,000 ns)
//timePulseParameters.userConfigDelay = -200000000; // Camera 3: delay the pulse by 0.2s (200,000,000 ns)
timePulseParameters.userConfigDelay = -300000000; // Camera 4: delay the pulse by 0.3s (300,000,000 ns)
//timePulseParameters.userConfigDelay = -400000000; // Camera 5: delay the pulse by 0.4s (400,000,000 ns)
//timePulseParameters.userConfigDelay = -500000000; // Camera 6: delay the pulse by 0.5s (500,000,000 ns)
//timePulseParameters.userConfigDelay = -600000000; // Camera 7: delay the pulse by 0.6s (600,000,000 ns)
//timePulseParameters.userConfigDelay = -700000000; // Camera 8: delay the pulse by 0.7s (700,000,000 ns)
//timePulseParameters.userConfigDelay = -800000000; // Camera 9: delay the pulse by 0.8s (800,000,000 ns)
//timePulseParameters.userConfigDelay = -900000000; // Camera 10: delay the pulse by 0.9s (900,000,000 ns)

timePulseParameters.flags.bits.active = 1; // Make sure the active flag is set to enable the time pulse. (Set to 0 to disable.)
timePulseParameters.flags.bits.lockedOtherSet = 1; // Tell the module to use freqPeriod while locking and freqPeriodLock when locked to GNSS time
timePulseParameters.flags.bits.isFreq = 0; // Tell the module that we want to set the period (not the frequency)
timePulseParameters.flags.bits.isLength = 1; // Tell the module that pulseLenRatio is a length (in us) - not a duty cycle

// Now set the time pulse parameters
if (myGNSS.setTimePulseParameters(&timePulseParameters) == false)
{
Serial.println(F("setTimePulseParameters failed!"));
}
else
{
Serial.println(F("Success!"));
}

// Finally, save the time pulse parameters in battery-backed memory so the pulse will automatically restart at power on
myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_NAVCONF); // Save the configuration
}

void loop()
{
// Nothing to do here
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
Time Pulse Parameters - Frequency
By: Paul Clark (PaulZC)
Date: January 13th, 2021

License: MIT. See license file for more information but you can
basically do whatever you want with this code.

This example shows how to change the time pulse parameters and configure the TIMEPULSE (PPS)
pin to produce a 1kHz squarewave

The SparkFun GPS-RTK-SMA Breakout - ZED-F9P (Qwiic) (https://www.sparkfun.com/products/16481)
has solder pads which will let you connect an SMA connector to the TIMEPULSE signal. Need an
accurate frequency or clock source for your latest project? This is the product for you!

Feel like supporting open source hardware?
Buy a board from SparkFun!
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
NEO-M8P RTK: https://www.sparkfun.com/products/15005
SAM-M8Q: https://www.sparkfun.com/products/15106

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_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
SFE_UBLOX_GNSS myGNSS;

void setup()
{
Serial.begin(115200);
while (!Serial)
; //Wait for user to open terminal
Serial.println(F("SparkFun u-blox Example"));

Wire.begin();

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

if (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. Freezing."));
while (1)
;
}

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

// Create storage for the time pulse parameters
UBX_CFG_TP5_data_t timePulseParameters;

// Get the time pulse parameters
if (myGNSS.getTimePulseParameters(&timePulseParameters) == false)
{
Serial.println(F("getTimePulseParameters failed! Freezing..."));
while (1) ; // Do nothing more
}

// Print the CFG TP5 version
Serial.print(F("UBX_CFG_TP5 version: "));
Serial.println(timePulseParameters.version);

timePulseParameters.tpIdx = 0; // Select the TIMEPULSE pin
//timePulseParameters.tpIdx = 1; // Or we could select the TIMEPULSE2 pin instead, if the module has one

// We can configure the time pulse pin to produce a defined frequency or period
// Here is how to set the frequency:

// While the module is _locking_ to GNSS time, make it generate 2kHz
timePulseParameters.freqPeriod = 2000; // Set the frequency/period to 2000Hz
timePulseParameters.pulseLenRatio = 0x55555555; // Set the pulse ratio to 1/3 * 2^32 to produce 33:67 mark:space

// When the module is _locked_ to GNSS time, make it generate 1kHz
timePulseParameters.freqPeriodLock = 1000; // Set the frequency/period to 1000Hz
timePulseParameters.pulseLenRatioLock = 0x80000000; // Set the pulse ratio to 1/2 * 2^32 to produce 50:50 mark:space

timePulseParameters.flags.bits.active = 1; // Make sure the active flag is set to enable the time pulse. (Set to 0 to disable.)
timePulseParameters.flags.bits.lockedOtherSet = 1; // Tell the module to use freqPeriod while locking and freqPeriodLock when locked to GNSS time
timePulseParameters.flags.bits.isFreq = 1; // Tell the module that we want to set the frequency (not the period)
timePulseParameters.flags.bits.isLength = 0; // Tell the module that pulseLenRatio is a ratio / duty cycle (* 2^-32) - not a length (in us)
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.)

// Now set the time pulse parameters
if (myGNSS.setTimePulseParameters(&timePulseParameters) == false)
{
Serial.println(F("setTimePulseParameters failed!"));
}
else
{
Serial.println(F("Success!"));
}
}

void loop()
{
// Nothing to do here
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
Time Pulse Parameters - Period
By: Paul Clark (PaulZC)
Date: January 13th, 2021

License: MIT. See license file for more information but you can
basically do whatever you want with this code.

This example shows how to change the time pulse parameters and configure the TIMEPULSE (PPS)
pin to produce a 1 second pulse every 30 seconds. What's really cool is that if you run this
example on two GNSS boards, the pulses are precisely synchronised!

The SparkFun GPS-RTK-SMA Breakout - ZED-F9P (Qwiic) (https://www.sparkfun.com/products/16481)
has solder pads which will let you connect an SMA connector to the TIMEPULSE signal. Need an
accurate timelapse camera shutter signal? This is the product for you!

Feel like supporting open source hardware?
Buy a board from SparkFun!
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
NEO-M8P RTK: https://www.sparkfun.com/products/15005
SAM-M8Q: https://www.sparkfun.com/products/15106

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_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
SFE_UBLOX_GNSS myGNSS;

void setup()
{
Serial.begin(115200);
while (!Serial)
; //Wait for user to open terminal
Serial.println(F("SparkFun u-blox Example"));

Wire.begin();

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

if (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. Freezing."));
while (1)
;
}

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

// Create storage for the time pulse parameters
UBX_CFG_TP5_data_t timePulseParameters;

// Get the time pulse parameters
if (myGNSS.getTimePulseParameters(&timePulseParameters) == false)
{
Serial.println(F("getTimePulseParameters failed! Freezing..."));
while (1) ; // Do nothing more
}

// Print the CFG TP5 version
Serial.print(F("UBX_CFG_TP5 version: "));
Serial.println(timePulseParameters.version);

timePulseParameters.tpIdx = 0; // Select the TIMEPULSE pin
//timePulseParameters.tpIdx = 1; // Or we could select the TIMEPULSE2 pin instead, if the module has one

// We can configure the time pulse pin to produce a defined frequency or period
// Here is how to set the period:

// Let's say that we want our 1 pulse every 30 seconds to be as accurate as possible. So, let's tell the module
// to generate no signal while it is _locking_ to GNSS time. We want the signal to start only when the module is
// _locked_ to GNSS time.
timePulseParameters.freqPeriod = 0; // Set the frequency/period to zero
timePulseParameters.pulseLenRatio = 0; // Set the pulse ratio to zero

// When the module is _locked_ to GNSS time, make it generate a 1 second pulse every 30 seconds
// (Although the period can be a maximum of 2^32 microseconds (over one hour), the upper limit appears to be around 33 seconds)
timePulseParameters.freqPeriodLock = 30000000; // Set the period to 30,000,000 us
timePulseParameters.pulseLenRatioLock = 1000000; // Set the pulse length to 1,000,000 us

timePulseParameters.flags.bits.active = 1; // Make sure the active flag is set to enable the time pulse. (Set to 0 to disable.)
timePulseParameters.flags.bits.lockedOtherSet = 1; // Tell the module to use freqPeriod while locking and freqPeriodLock when locked to GNSS time
timePulseParameters.flags.bits.isFreq = 0; // Tell the module that we want to set the period (not the frequency)
timePulseParameters.flags.bits.isLength = 1; // Tell the module that pulseLenRatio is a length (in us) - not a duty cycle
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.)

// Now set the time pulse parameters
if (myGNSS.setTimePulseParameters(&timePulseParameters) == false)
{
Serial.println(F("setTimePulseParameters failed!"));
}
else
{
Serial.println(F("Success!"));
}

// Finally, save the time pulse parameters in battery-backed memory so the pulse will automatically restart at power on
myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_NAVCONF); // Save the configuration
}

void loop()
{
// Nothing to do here
}
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 Arduino Library
version=2.0.0
version=2.0.1
author=SparkFun Electronics <[email protected]>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for I2C and Serial Communication with u-blox modules
Expand Down
Loading