|
| 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 | +} |
0 commit comments