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

Commit 50086e4

Browse files
authored
Merge pull request #135 from sparkfun/setStaticPosition
Add support for TMOD3 fixed position.
2 parents 7114584 + 32f8583 commit 50086e4

File tree

4 files changed

+139
-0
lines changed

4 files changed

+139
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
19+
Hardware Connections:
20+
Plug a Qwiic cable into the GPS and a BlackBoard
21+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
22+
Open the serial monitor at 115200 baud to see the output
23+
*/
24+
25+
#include <Wire.h> //Needed for I2C to GPS
26+
27+
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS
28+
SFE_UBLOX_GPS myGPS;
29+
30+
void setup()
31+
{
32+
Serial.begin(115200); // You may need to increase this for high navigation rates!
33+
while (!Serial)
34+
; //Wait for user to open terminal
35+
Serial.println(F("SparkFun u-blox Example"));
36+
37+
Wire.begin();
38+
39+
//myGPS.enableDebugging(); // Uncomment this line to enable debug messages
40+
41+
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
42+
{
43+
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
44+
while (1)
45+
;
46+
}
47+
48+
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
49+
50+
//-1280208.308,-4716803.847,4086665.811 is SparkFun HQ so...
51+
52+
//Units are cm so 1234 = 12.34m
53+
//myGPS.setStaticPosition(-128020831, -471680385, 408666581);
54+
55+
//Units are cm with a high precision extension so -1234.5678 should be called: (-123456, -78)
56+
myGPS.setStaticPosition(-128020830, -80, -471680384, -70, 408666581, 10); //With high precision 0.1mm parts
57+
58+
//We can also set via lat/long
59+
//40.09029751,-105.18507900,1560.238
60+
//myGPS.setStaticPosition(400902975, -1051850790, 156024, true); //True at end enables lat/long input
61+
//myGPS.setStaticPosition(400902975, 10, -1051850790, 0, 156023, 80, true);
62+
63+
//Now let's use getVals to read back the data
64+
//long ecefX = myGPS.getVal32(0x40030003);
65+
//Serial.print("ecefX: ");
66+
//Serial.println(ecefX);
67+
68+
Serial.println(F("Done!"));
69+
}
70+
71+
void loop()
72+
{
73+
}

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: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3533,3 +3533,62 @@ boolean SFE_UBLOX_GPS::getVehAtt(uint16_t maxWait)
35333533

35343534
return (true);
35353535
}
3536+
3537+
//Set the ECEF or Lat/Long 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+
// For ECEF the units are: cm, 0.1mm, cm, 0.1mm, cm, 0.1mm
3541+
// For Lat/Lon/Alt the units are: degrees^-7, degrees^-9, degrees^-7, degrees^-9, cm, 0.1mm
3542+
bool SFE_UBLOX_GPS::setStaticPosition(int32_t ecefXOrLat, int8_t ecefXOrLatHP, int32_t ecefYOrLon, int8_t ecefYOrLonHP, int32_t ecefZOrAlt, int8_t ecefZOrAltHP, bool latLong, uint16_t maxWait)
3543+
{
3544+
packetCfg.cls = UBX_CLASS_CFG;
3545+
packetCfg.id = UBX_CFG_TMODE3;
3546+
packetCfg.len = 0;
3547+
packetCfg.startingSpot = 0;
3548+
3549+
//Ask module for the current TimeMode3 settings. Loads into payloadCfg.
3550+
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED)
3551+
return (false);
3552+
3553+
packetCfg.len = 40;
3554+
3555+
//Clear packet payload
3556+
for (uint8_t x = 0; x < packetCfg.len; x++)
3557+
payloadCfg[x] = 0;
3558+
3559+
//customCfg should be loaded with poll response. Now modify only the bits we care about
3560+
payloadCfg[2] = 2; //Set mode to fixed. Use ECEF (not LAT/LON/ALT).
3561+
3562+
if (latLong == true)
3563+
payloadCfg[3] = (uint8_t)(1 << 0); //Set mode to fixed. Use LAT/LON/ALT.
3564+
3565+
//Set ECEF X or Lat
3566+
payloadCfg[4] = (ecefXOrLat >> 8 * 0) & 0xFF; //LSB
3567+
payloadCfg[5] = (ecefXOrLat >> 8 * 1) & 0xFF;
3568+
payloadCfg[6] = (ecefXOrLat >> 8 * 2) & 0xFF;
3569+
payloadCfg[7] = (ecefXOrLat >> 8 * 3) & 0xFF; //MSB
3570+
3571+
//Set ECEF Y or Long
3572+
payloadCfg[8] = (ecefYOrLon >> 8 * 0) & 0xFF; //LSB
3573+
payloadCfg[9] = (ecefYOrLon >> 8 * 1) & 0xFF;
3574+
payloadCfg[10] = (ecefYOrLon >> 8 * 2) & 0xFF;
3575+
payloadCfg[11] = (ecefYOrLon >> 8 * 3) & 0xFF; //MSB
3576+
3577+
//Set ECEF Z or Altitude
3578+
payloadCfg[12] = (ecefZOrAlt >> 8 * 0) & 0xFF; //LSB
3579+
payloadCfg[13] = (ecefZOrAlt >> 8 * 1) & 0xFF;
3580+
payloadCfg[14] = (ecefZOrAlt >> 8 * 2) & 0xFF;
3581+
payloadCfg[15] = (ecefZOrAlt >> 8 * 3) & 0xFF; //MSB
3582+
3583+
//Set high precision parts
3584+
payloadCfg[16] = ecefXOrLatHP;
3585+
payloadCfg[17] = ecefYOrLonHP;
3586+
payloadCfg[18] = ecefZOrAltHP;
3587+
3588+
return ((sendCommand(&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
3589+
}
3590+
3591+
bool SFE_UBLOX_GPS::setStaticPosition(int32_t ecefXOrLat, int32_t ecefYOrLon, int32_t ecefZOrAlt, bool latlong, uint16_t maxWait)
3592+
{
3593+
return (setStaticPosition(ecefXOrLat, 0, ecefYOrLon, 0, ecefZOrAlt, 0, latlong, maxWait));
3594+
}

src/SparkFun_Ublox_Arduino_Library.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,12 @@ 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+
// For ECEF the units are: cm, 0.1mm, cm, 0.1mm, cm, 0.1mm
646+
// For Lat/Lon/Alt the units are: degrees^-7, degrees^-9, degrees^-7, degrees^-9, cm, 0.1mm
647+
bool setStaticPosition(int32_t ecefXOrLat, int8_t ecefXOrLatHP, int32_t ecefYOrLon, int8_t ecefYOrLonHP, int32_t ecefZOrAlt, int8_t ecefZOrAltHP, bool latLong = false, uint16_t maxWait = 250);
648+
bool setStaticPosition(int32_t ecefXOrLat, int32_t ecefYOrLon, int32_t ecefZOrAlt, bool latLong = false, uint16_t maxWait = 250);
649+
644650
//Survey-in specific controls
645651
struct svinStructure
646652
{

0 commit comments

Comments
 (0)