Skip to content

Commit b6f160f

Browse files
committed
Add RX Clock Drift reporting
1 parent 40a8060 commit b6f160f

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

Firmware/GNSSDO_Firmware/Begin.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ int64_t getFrequencyControlWord()
633633
void updateTCXOClockBias()
634634
{
635635
tcxoClockBias_ms = gnssClockBias_ms; // Default to the PVTGeodetic RxClkBias
636+
tcxoClockDrift_ppm = gnssClockDrift_ppm;
636637
snprintf(rxClkBiasSource, sizeof(rxClkBiasSource), "PVT");
637638

638639
if (settings.preferNonCompositeGPSBias || settings.preferNonCompositeGalileoBias) // These are mutex
@@ -641,6 +642,7 @@ void updateTCXOClockBias()
641642
if (fugroTimeSystems[index].updated) // If we have the preferred non-composite bias, use that
642643
{
643644
tcxoClockBias_ms = fugroTimeSystems[index].RxClkBias_ms;
645+
tcxoClockDrift_ppm = fugroTimeSystems[index].RxClkDrift_ppm;
644646
fugroTimeSystems[index].updated = false;
645647
snprintf(rxClkBiasSource, sizeof(rxClkBiasSource), fugroTimeSystems[index].name);
646648
}

Firmware/GNSSDO_Firmware/GNSSDO_Firmware.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ float gnssAltitude_m = 0.0;
140140
uint8_t gnssTimeSys = 255; // Unknown
141141
uint8_t gnssError = 255; // Unknown
142142
double gnssClockBias_ms = 0.0;
143+
float gnssClockDrift_ppm = 0.0;
143144

144145
// IPStatus 4058
145146
uint8_t ethernetMACAddress[6] = { 0,0,0,0,0,0 }; // Display this address in the system menu

Firmware/GNSSDO_Firmware/Tasks.ino

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,11 @@ void processConsumerMessage(PARSE_STATE *parse, uint8_t type)
628628
uint64_t unsigned64;
629629
} dblUnsigned64;
630630

631+
union {
632+
float flt;
633+
uint32_t unsigned32;
634+
} fltUnsigned32;
635+
631636
dblUnsigned64.unsigned64 = 0;
632637
for (int i = 0; i < 8; i++)
633638
dblUnsigned64.unsigned64 |= ((uint64_t)parse->buffer[16 + i]) << (i * 8);
@@ -658,6 +663,15 @@ void processConsumerMessage(PARSE_STATE *parse, uint8_t type)
658663
if (gnssClockBias_ms > 999.999)
659664
gnssClockBias_ms = 999.999;
660665

666+
fltUnsigned32.unsigned32 = 0;
667+
for (int i = 0; i < 4; i++)
668+
fltUnsigned32.unsigned32 |= ((uint32_t)parse->buffer[68 + i]) << (i * 8);
669+
gnssClockDrift_ppm = fltUnsigned32.flt;
670+
if (gnssClockDrift_ppm < -999999.999)
671+
gnssClockDrift_ppm = -999999.999;
672+
if (gnssClockDrift_ppm > 999999.999)
673+
gnssClockDrift_ppm = 999999.999;
674+
661675
gnssTimeSys = parse->buffer[72];
662676
}
663677
else if ((parse->message & 0x1FFF) == 4058) // IPStatus
@@ -686,21 +700,35 @@ void processConsumerMessage(PARSE_STATE *parse, uint8_t type)
686700
uint8_t SysUsage = parse->buffer[20 + (b * SBLength) + 0];
687701
uint8_t TimeSystem = parse->buffer[20 + (b * SBLength) + 2];
688702

703+
// Convert uint64_t to double
689704
union {
690705
double dbl;
691706
uint64_t unsigned64;
692707
} dblUnsigned64;
693708

709+
// Extract RxClkBias_ms
694710
dblUnsigned64.unsigned64 = 0;
695711
for (int i = 0; i < 8; i++)
696712
dblUnsigned64.unsigned64 |= ((uint64_t)parse->buffer[20 + (b * SBLength) + 4 + i]) << (i * 8);
697713

714+
// Convert uint32_t to float
715+
union {
716+
float flt;
717+
uint32_t unsigned32;
718+
} fltUnsigned32;
719+
720+
// Extract RxClkDrift_ppm
721+
fltUnsigned32.unsigned32 = 0;
722+
for (int i = 0; i < 4; i++)
723+
fltUnsigned32.unsigned32 |= ((uint32_t)parse->buffer[20 + (b * SBLength) + 12 + i]) << (i * 8);
724+
698725
// If this block contains a non-composite clock indicator, store it
699726
for (int TS = 0; TS < NUM_FUGRO_CLK_BIASES; TS++)
700727
{
701728
if (fugroTimeSystems[TS].SysUsage == SysUsage)
702729
{
703730
fugroTimeSystems[TS].RxClkBias_ms = dblUnsigned64.dbl;
731+
fugroTimeSystems[TS].RxClkDrift_ppm = fltUnsigned32.flt;
704732
fugroTimeSystems[TS].updated = true;
705733
break;
706734
}

Firmware/GNSSDO_Firmware/menuSystem.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ void printCurrentConditions(bool CSV)
584584
{
585585
if (firstTime)
586586
{
587-
systemPrintln("YYYY/MM/DD,HH:MM:SS,Epoch,Lat,Lon,Alt,TimeSys,Error,Fine,PPS,Bias,Source,TCXO,Pk,Ik");
587+
systemPrintln("YYYY/MM/DD,HH:MM:SS,Epoch,Lat,Lon,Alt,TimeSys,Error,Fine,PPS,Bias,Drift,Source,TCXO,Pk,Ik");
588588
firstTime = false;
589589
}
590590

@@ -620,6 +620,8 @@ void printCurrentConditions(bool CSV)
620620

621621
systemPrintf(",%.3e", tcxoClockBias_ms / 1000.0); // Display clock bias in seconds
622622

623+
systemPrintf(",%.3e", tcxoClockDrift_ppm / 1000000.0); // Display clock drift in parts
624+
623625
systemPrint(",");
624626
systemPrint((const char *)rxClkBiasSource),
625627

@@ -669,6 +671,8 @@ void printCurrentConditions(bool CSV)
669671
systemPrintf(", Bias: %.3fns",
670672
(float)(tcxoClockBias_ms * 1000000.0));
671673

674+
systemPrintf(", Drift: %.3e", tcxoClockDrift_ppm / 1000000.0);
675+
672676
systemPrint(", Source: ");
673677
systemPrint((const char *)rxClkBiasSource),
674678

Firmware/GNSSDO_Firmware/settings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ typedef struct {
8484
const uint8_t SysUsage;
8585
const char name[8];
8686
double RxClkBias_ms;
87+
float RxClkDrift_ppm;
8788
bool updated;
8889
} fugroTimeSystem;
8990

@@ -131,6 +132,7 @@ uint8_t mosaicTimeSystemIndexFromName(const char *name)
131132
return 0; // This should never happen
132133
}
133134
double tcxoClockBias_ms; // Updated by updateTCXOClockBias
135+
float tcxoClockDrift_ppm;
134136
char rxClkBiasSource[8];
135137

136138
const char *const mosaicPVTErrorTable[] = {

0 commit comments

Comments
 (0)