Skip to content

Commit 587022c

Browse files
author
Nathan Seidle
committed
Firmware directory shuffle. Add readme.
1 parent f766ca1 commit 587022c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1540
-0
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
//Wait for survey in to complete
2+
bool updateSurveyInStatus()
3+
{
4+
//Update the LEDs only every second or so
5+
if (millis() - lastBaseUpdate > 1000)
6+
{
7+
lastBaseUpdate += 1000;
8+
9+
if (baseState == BASE_SURVEYING_IN_NOTSTARTED)
10+
{
11+
//Check for <5m horz accuracy
12+
uint32_t accuracy = myGPS.getHorizontalAccuracy(250); //This call defaults to 1100ms and can cause the core to crash with WDT timeout
13+
14+
float f_accuracy = accuracy;
15+
f_accuracy = f_accuracy / 10000.0; // Convert the horizontal accuracy (mm * 10^-1) to a float
16+
17+
if (f_accuracy > 0.0 && f_accuracy < 5.0)
18+
{
19+
//We've got a good positional accuracy, start survey
20+
surveyIn();
21+
}
22+
else
23+
{
24+
Serial.print("Waiting for Horz Accuracy < 5m: ");
25+
Serial.print(f_accuracy, 2); // Print the accuracy with 2 decimal places
26+
Serial.println();
27+
}
28+
29+
} //baseState = Surveying In Not started
30+
else
31+
{
32+
33+
bool response = myGPS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (req can take a long time)
34+
if (response == true)
35+
{
36+
if (myGPS.svin.valid == true)
37+
{
38+
Serial.println(F("Base survey complete! RTCM now broadcasting."));
39+
baseState = BASE_TRANSMITTING;
40+
41+
digitalWrite(baseStatusLED, HIGH); //Turn on LED
42+
}
43+
else
44+
{
45+
byte SIV = myGPS.getSIV();
46+
47+
Serial.print(F("Time elapsed: "));
48+
Serial.print((String)myGPS.svin.observationTime);
49+
Serial.print(F(" Accuracy: "));
50+
Serial.print((String)myGPS.svin.meanAccuracy);
51+
Serial.print(F(" SIV: "));
52+
Serial.print(SIV);
53+
Serial.println();
54+
55+
SerialBT.print(F("Time elapsed: "));
56+
SerialBT.print((String)myGPS.svin.observationTime);
57+
SerialBT.print(F(" Accuracy: "));
58+
SerialBT.print((String)myGPS.svin.meanAccuracy);
59+
SerialBT.print(F(" SIV: "));
60+
SerialBT.print(SIV);
61+
SerialBT.println();
62+
63+
if (myGPS.svin.meanAccuracy > 6.0)
64+
baseState = BASE_SURVEYING_IN_SLOW;
65+
else
66+
baseState = BASE_SURVEYING_IN_FAST;
67+
68+
if (myGPS.svin.observationTime > maxSurveyInWait_s)
69+
{
70+
Serial.println(F("Survey-In took more than 5 minutes. Restarting survey in."));
71+
72+
resetSurvey();
73+
74+
surveyIn();
75+
}
76+
}
77+
}
78+
else
79+
{
80+
Serial.println(F("SVIN request failed"));
81+
}
82+
} //baseState = Surveying In Slow or fast
83+
} //Check every second
84+
85+
//Update the Base LED accordingly
86+
if (baseState == BASE_SURVEYING_IN_NOTSTARTED || baseState == BASE_SURVEYING_IN_SLOW)
87+
{
88+
if (millis() - baseStateBlinkTime > 2000)
89+
{
90+
baseStateBlinkTime += 2000;
91+
Serial.println(F("Slow blink"));
92+
93+
if (digitalRead(baseStatusLED) == LOW)
94+
digitalWrite(baseStatusLED, HIGH);
95+
else
96+
digitalWrite(baseStatusLED, LOW);
97+
}
98+
}
99+
else if (baseState == BASE_SURVEYING_IN_FAST)
100+
{
101+
if (millis() - baseStateBlinkTime > 500)
102+
{
103+
baseStateBlinkTime += 500;
104+
Serial.println(F("Fast blink"));
105+
106+
if (digitalRead(baseStatusLED) == LOW)
107+
digitalWrite(baseStatusLED, HIGH);
108+
else
109+
digitalWrite(baseStatusLED, LOW);
110+
}
111+
}
112+
}
113+
114+
//Configure specific aspects of the receiver for base mode
115+
bool configureUbloxModuleBase()
116+
{
117+
bool response = true;
118+
119+
digitalWrite(positionAccuracyLED_1cm, LOW);
120+
digitalWrite(positionAccuracyLED_10cm, LOW);
121+
digitalWrite(positionAccuracyLED_100cm, LOW);
122+
123+
// Set dynamic model
124+
if (myGPS.getDynamicModel() != DYN_MODEL_STATIONARY)
125+
{
126+
if (myGPS.setDynamicModel(DYN_MODEL_STATIONARY) == false)
127+
{
128+
Serial.println(F("setDynamicModel failed!"));
129+
return (false);
130+
}
131+
}
132+
133+
//In base mode the Surveyor should output RTCM over UART1, UART2, and USB ports:
134+
//(Primary) UART2 in case the Surveyor is connected via radio to rover
135+
//(Seconday) USB in case the Surveyor is used as an NTRIP caster
136+
//(Tertiary) UART1 in case Surveyor is sending RTCM to phone that is then NTRIP caster
137+
if (getRTCMSettings(UBX_RTCM_1005, COM_PORT_UART2) != 1)
138+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_UART2, 1); //Enable message 1005 to output through UART2, message every second
139+
if (getRTCMSettings(UBX_RTCM_1074, COM_PORT_UART2) != 1)
140+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1074, COM_PORT_UART2, 1);
141+
if (getRTCMSettings(UBX_RTCM_1084, COM_PORT_UART2) != 1)
142+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1084, COM_PORT_UART2, 1);
143+
if (getRTCMSettings(UBX_RTCM_1094, COM_PORT_UART2) != 1)
144+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1094, COM_PORT_UART2, 1);
145+
if (getRTCMSettings(UBX_RTCM_1124, COM_PORT_UART2) != 1)
146+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1124, COM_PORT_UART2, 1);
147+
if (getRTCMSettings(UBX_RTCM_1230, COM_PORT_UART2) != 10)
148+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_UART2, 10); //Enable message every 10 seconds
149+
150+
if (getRTCMSettings(UBX_RTCM_1005, COM_PORT_UART1) != 1)
151+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_UART1, 1); //Enable message 1005 to output through UART2, message every second
152+
if (getRTCMSettings(UBX_RTCM_1074, COM_PORT_UART1) != 1)
153+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1074, COM_PORT_UART1, 1);
154+
if (getRTCMSettings(UBX_RTCM_1084, COM_PORT_UART1) != 1)
155+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1084, COM_PORT_UART1, 1);
156+
if (getRTCMSettings(UBX_RTCM_1094, COM_PORT_UART1) != 1)
157+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1094, COM_PORT_UART1, 1);
158+
if (getRTCMSettings(UBX_RTCM_1124, COM_PORT_UART1) != 1)
159+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1124, COM_PORT_UART1, 1);
160+
if (getRTCMSettings(UBX_RTCM_1230, COM_PORT_UART1) != 10)
161+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_UART1, 10); //Enable message every 10 seconds
162+
163+
if (getRTCMSettings(UBX_RTCM_1005, COM_PORT_USB) != 1)
164+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_USB, 1); //Enable message 1005 to output through UART2, message every second
165+
if (getRTCMSettings(UBX_RTCM_1074, COM_PORT_USB) != 1)
166+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1074, COM_PORT_USB, 1);
167+
if (getRTCMSettings(UBX_RTCM_1084, COM_PORT_USB) != 1)
168+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1084, COM_PORT_USB, 1);
169+
if (getRTCMSettings(UBX_RTCM_1094, COM_PORT_USB) != 1)
170+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1094, COM_PORT_USB, 1);
171+
if (getRTCMSettings(UBX_RTCM_1124, COM_PORT_USB) != 1)
172+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1124, COM_PORT_USB, 1);
173+
if (getRTCMSettings(UBX_RTCM_1230, COM_PORT_USB) != 10)
174+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_USB, 10); //Enable message every 10 seconds
175+
176+
if (response == false)
177+
{
178+
Serial.println(F("RTCM failed to enable."));
179+
return (false);
180+
}
181+
182+
return (response);
183+
}
184+
185+
//Start survey
186+
//The ZED-F9P is slightly different than the NEO-M8P. See the Integration manual 3.5.8 for more info.
187+
void surveyIn()
188+
{
189+
resetSurvey();
190+
191+
bool response = myGPS.enableSurveyMode(60, 5.000); //Enable Survey in, 60 seconds, 5.0m
192+
if (response == false)
193+
{
194+
Serial.println(F("Survey start failed"));
195+
return;
196+
}
197+
Serial.println(F("Survey started. This will run until 60s has passed and less than 5m accuracy is achieved."));
198+
199+
baseState = BASE_SURVEYING_IN_SLOW;
200+
}
201+
202+
void resetSurvey()
203+
{
204+
//Slightly modified method for restarting survey-in from: https://portal.u-blox.com/s/question/0D52p00009IsVoMCAV/restarting-surveyin-on-an-f9p
205+
bool response = myGPS.disableSurveyMode(); //Disable survey
206+
delay(500);
207+
response &= myGPS.enableSurveyMode(1000, 400.000); //Enable Survey in with bogus values
208+
delay(500);
209+
response &= myGPS.disableSurveyMode(); //Disable survey
210+
delay(500);
211+
}

0 commit comments

Comments
 (0)