Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 8638c35

Browse files
committed
Add support for TMOD3 fixed position.
1 parent 2816b95 commit 8638c35

File tree

4 files changed

+137
-1
lines changed

4 files changed

+137
-1
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
Set the static position of the receiver.
3+
By: SparkFun Electronics / Nathan Seidle
4+
Date: September 26th, 2020
5+
License: MIT. See license file for more information but you can
6+
basically do whatever you want with this code.
7+
8+
This example shows how to set the static position of a receiver
9+
using an Earth-Centered, Earth-Fixed (ECEF) location. This is the
10+
output from a long (24 hour+) survey-in. Setting the static position
11+
immediately causes the receiver to begin outputting RTCM data (if
12+
enabled), perfect for setting up your own RTCM NTRIP caster or CORS.
13+
14+
Feel like supporting open source hardware?
15+
Buy a board from SparkFun!
16+
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
17+
NEO-M8P RTK: https://www.sparkfun.com/products/15005
18+
SAM-M8Q: https://www.sparkfun.com/products/15106
19+
20+
Hardware Connections:
21+
Plug a Qwiic cable into the GPS and a BlackBoard
22+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
23+
Open the serial monitor at 115200 baud to see the output
24+
*/
25+
26+
#include <Wire.h> //Needed for I2C to GPS
27+
28+
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS
29+
SFE_UBLOX_GPS myGPS;
30+
31+
void setup()
32+
{
33+
Serial.begin(115200); // You may need to increase this for high navigation rates!
34+
while (!Serial)
35+
; //Wait for user to open terminal
36+
Serial.println(F("SparkFun u-blox Example"));
37+
38+
Wire.begin();
39+
40+
//myGPS.enableDebugging(); // Uncomment this line to enable debug messages
41+
42+
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
43+
{
44+
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
45+
while (1)
46+
;
47+
}
48+
49+
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
50+
51+
//-1280208.308,-4716803.847,4086665.811 is SparkFun HQ so...
52+
53+
//Units are cm so 1234 = 12.34m
54+
//myGPS.setStaticPosition(-128020831, -471680385, 408666581);
55+
56+
//Units are cm with a high precision extension so -1234.5678 should be called: (-123456, -78)
57+
myGPS.setStaticPosition(-128020830, -80, -471680384, -70, 408666581, 10, true, 250); //With high precision 0.1mm parts
58+
59+
//We can also set via lat/long
60+
//40.09029751,-105.18507900,1560.238
61+
//myGPS.setStaticPosition(400902975, -1051850790, 156024, true); //True at end enables lat/long input
62+
//myGPS.setStaticPosition(400902975, 10, -1051850790, 0, 156023, 80, true);
63+
64+
//Now let's use getVals to read back the data
65+
//long ecefX = myGPS.getVal32(0x40030003);
66+
//Serial.print("ecefX: ");
67+
//Serial.println(ecefX);
68+
69+
Serial.println(F("Done!"));
70+
}
71+
72+
void loop()
73+
{
74+
}

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ getVehAtt KEYWORD2
159159
setI2CTransactionSize KEYWORD2
160160
getI2CTransactionSize KEYWORD2
161161

162+
setStaticPosition KEYWORD2
162163

163164
#######################################
164165
# Constants (LITERAL1)

src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3533,3 +3533,60 @@ boolean SFE_UBLOX_GPS::getVehAtt(uint16_t maxWait)
35333533

35343534
return (true);
35353535
}
3536+
3537+
//Set the ECEF coordinates of a receiver
3538+
//This imediately puts the receiver in TIME mode (fixed) and will begin outputting RTCM sentences if enabled
3539+
//This is helpful once an antenna's position has been established. See this tutorial: https://learn.sparkfun.com/tutorials/how-to-build-a-diy-gnss-reference-station#gather-raw-gnss-data
3540+
bool SFE_UBLOX_GPS::setStaticPosition(int32_t ecefX, int8_t ecefXHP, int32_t ecefY, int8_t ecefYHP, int32_t ecefZ, int8_t ecefZHP, bool latLong, uint16_t maxWait)
3541+
{
3542+
packetCfg.cls = UBX_CLASS_CFG;
3543+
packetCfg.id = UBX_CFG_TMODE3;
3544+
packetCfg.len = 0;
3545+
packetCfg.startingSpot = 0;
3546+
3547+
//Ask module for the current TimeMode3 settings. Loads into payloadCfg.
3548+
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED)
3549+
return (false);
3550+
3551+
packetCfg.len = 40;
3552+
3553+
//Clear packet payload
3554+
for (uint8_t x = 0; x < packetCfg.len; x++)
3555+
payloadCfg[x] = 0;
3556+
3557+
//customCfg should be loaded with poll response. Now modify only the bits we care about
3558+
payloadCfg[2] = 2; //Set mode to fixed. Use ECEF (not LAT/LON/ALT).
3559+
3560+
if (latLong == true)
3561+
payloadCfg[3] = (uint8_t)(1 << 0); //Set mode to fixed. Use LAT/LON/ALT.
3562+
3563+
//Set ECEF X
3564+
payloadCfg[4] = (ecefX >> 8 * 0) & 0xFF; //LSB
3565+
payloadCfg[5] = (ecefX >> 8 * 1) & 0xFF;
3566+
payloadCfg[6] = (ecefX >> 8 * 2) & 0xFF;
3567+
payloadCfg[7] = (ecefX >> 8 * 3) & 0xFF; //MSB
3568+
3569+
//Set ECEF Y
3570+
payloadCfg[8] = (ecefY >> 8 * 0) & 0xFF; //LSB
3571+
payloadCfg[9] = (ecefY >> 8 * 1) & 0xFF;
3572+
payloadCfg[10] = (ecefY >> 8 * 2) & 0xFF;
3573+
payloadCfg[11] = (ecefY >> 8 * 3) & 0xFF; //MSB
3574+
3575+
//Set ECEF Z
3576+
payloadCfg[12] = (ecefZ >> 8 * 0) & 0xFF; //LSB
3577+
payloadCfg[13] = (ecefZ >> 8 * 1) & 0xFF;
3578+
payloadCfg[14] = (ecefZ >> 8 * 2) & 0xFF;
3579+
payloadCfg[15] = (ecefZ >> 8 * 3) & 0xFF; //MSB
3580+
3581+
//Set ECEF high precision bits
3582+
payloadCfg[16] = ecefXHP;
3583+
payloadCfg[17] = ecefYHP;
3584+
payloadCfg[18] = ecefZHP;
3585+
3586+
return ((sendCommand(&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
3587+
}
3588+
3589+
bool SFE_UBLOX_GPS::setStaticPosition(int32_t ecefX, int32_t ecefY, int32_t ecefZ, bool latlong, uint16_t maxWait)
3590+
{
3591+
return (setStaticPosition(ecefX, 0, ecefY, 0, ecefZ, 0, latlong, maxWait));
3592+
}

src/SparkFun_Ublox_Arduino_Library.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ class SFE_UBLOX_GPS
461461
//Control the size of the internal I2C transaction amount
462462
void setI2CTransactionSize(uint8_t bufferSize);
463463
uint8_t getI2CTransactionSize(void);
464-
464+
465465
//Set the max number of bytes set in a given I2C transaction
466466
uint8_t i2cTransactionSize = 32; //Default to ATmega328 limit
467467

@@ -641,6 +641,10 @@ class SFE_UBLOX_GPS
641641
sfe_ublox_status_e getSensState(uint8_t sensor, uint16_t maxWait = 1100);
642642
boolean getVehAtt(uint16_t maxWait = 1100);
643643

644+
//Given coordinates, put receiver into static position. Set latlong to true to pass in lat/long values instead of ecef.
645+
bool setStaticPosition(int32_t ecefX, int8_t ecefXHP, int32_t ecefY, int8_t ecefYHP, int32_t ecefZ, int8_t ecefZHP, bool latLong = false, uint16_t maxWait = 250);
646+
bool setStaticPosition(int32_t ecefX, int32_t ecefY, int32_t ecefZ, bool latlong = true, uint16_t maxWait = 250);
647+
644648
//Survey-in specific controls
645649
struct svinStructure
646650
{

0 commit comments

Comments
 (0)