@@ -304,7 +304,7 @@ void updateErrorLED()
304304
305305void updateLockLED ()
306306{
307- digitalWrite (pin_lockLED, ( fabs (tcxoClockBias_ms) < settings. rxClkBiasLockLimit_ms ) ? HIGH : LOW);
307+ digitalWrite (pin_lockLED, systemState >= STATE_GNSS_PHASE_LOCK ? HIGH : LOW);
308308}
309309
310310// Depending on platform and previous power down state, set system state
@@ -506,6 +506,8 @@ void pinI2C2Task(void *pvParameters)
506506 case SFE_GNSSDO_OSC_STP3593LF: {
507507 systemPrintf (" 0x%02x - STP3593LF TCXO\r\n " , addr);
508508 presentSTP3593LF = true ;
509+ presentTcxoTemperature = true ;
510+ presentTcxoSaveControl = true ;
509511 i2cTCXO = i2c_2;
510512 break ;
511513 }
@@ -525,7 +527,7 @@ void pinI2C2Task(void *pvParameters)
525527 vTaskDelete (nullptr ); // Delete task once it has run once
526528}
527529
528- void beginTCXO (TwoWire *i2cBus)
530+ void beginTCXO (TwoWire *i2cBus, bool printOCXO )
529531{
530532 if (myTCXO != nullptr )
531533 {
@@ -556,12 +558,21 @@ void beginTCXO(TwoWire *i2cBus)
556558 {
557559 // Update the default P and I terms to match a new oscillator
558560 settings.lastSeenTCXO = SFE_GNSSDO_OSC_STP3593LF;
559- settings.Pk = myTCXO->getDefaultFrequencyByBiasPTerm ();
560- settings.Ik = myTCXO->getDefaultFrequencyByBiasITerm ();
561+ settings.PkSteer = 0.2 ;
562+ settings.IkSteer = 0.5 ;
563+ settings.PkRamp = 0.4 ;
564+ settings.IkRamp = 0.4 ;
565+ settings.Pk = (1.0 / 6.25 );
566+ settings.Ik = ((1.0 / 6.25 ) / 150.0 );
567+ settings.tcxoRampRateLimit_sps = 250.0e-9 ;
568+ settings.tcxoRampStepSize_s = 0.5e-9 ;
569+ settings.tcxoRampAsymmetry = 1.0 ;
570+ settings.minimumRampRepeats = 2 ;
561571 recordSystemSettings ();
562572 }
563573
564- systemPrintln (" Using STP3593LF OCXO" );
574+ if (printOCXO)
575+ systemPrintln (" Using STP3593LF OCXO" );
565576 strncpy (oscillatorType, " STP3593LF OCXO" , sizeof (oscillatorType));
566577 }
567578 else if (presentSIT5811)
@@ -574,13 +585,23 @@ void beginTCXO(TwoWire *i2cBus)
574585 if (settings.lastSeenTCXO != SFE_GNSSDO_OSC_SIT5811)
575586 {
576587 // Update the default P and I terms to match a new oscillator
588+ // *** TODO ***
577589 settings.lastSeenTCXO = SFE_GNSSDO_OSC_SIT5811;
578- settings.Pk = myTCXO->getDefaultFrequencyByBiasPTerm ();
579- settings.Ik = myTCXO->getDefaultFrequencyByBiasITerm ();
590+ settings.PkSteer = 0.5 ;
591+ settings.IkSteer = 0.1 ;
592+ settings.PkRamp = 0.5 ;
593+ settings.IkRamp = 0.1 ;
594+ settings.Pk = 0.5 ;
595+ settings.Ik = 0.1 ;
596+ settings.tcxoRampRateLimit_sps = 250.0e-9 ;
597+ settings.tcxoRampStepSize_s = 1.0e-9 ;
598+ settings.tcxoRampAsymmetry = 1.0 ;
599+ settings.minimumRampRepeats = 1 ;
580600 recordSystemSettings ();
581601 }
582602
583- systemPrintln (" Using SiT5811 OCXO" );
603+ if (printOCXO)
604+ systemPrintln (" Using SiT5811 OCXO" );
584605 strncpy (oscillatorType, " SiT5811 OCXO" , sizeof (oscillatorType));
585606 }
586607 else if (presentSIT5358)
@@ -594,12 +615,21 @@ void beginTCXO(TwoWire *i2cBus)
594615 {
595616 // Update the default P and I terms to match a new oscillator
596617 settings.lastSeenTCXO = SFE_GNSSDO_OSC_SIT5358;
597- settings.Pk = myTCXO->getDefaultFrequencyByBiasPTerm ();
598- settings.Ik = myTCXO->getDefaultFrequencyByBiasITerm ();
618+ settings.PkSteer = 0.63 ;
619+ settings.IkSteer = 0.151 ;
620+ settings.PkRamp = 0.63 ;
621+ settings.IkRamp = 0.5 ;
622+ settings.Pk = 0.63 ;
623+ settings.Ik = 0.151 ;
624+ settings.tcxoRampRateLimit_sps = 500.0e-9 ;
625+ settings.tcxoRampStepSize_s = 1.0e-9 ;
626+ settings.tcxoRampAsymmetry = 1.0 ;
627+ settings.minimumRampRepeats = 1 ;
599628 recordSystemSettings ();
600629 }
601630
602- systemPrintln (" Using SiT5358 TCXO" );
631+ if (printOCXO)
632+ systemPrintln (" Using SiT5358 TCXO" );
603633 strncpy (oscillatorType, " SiT5358 TCXO" , sizeof (oscillatorType));
604634 }
605635 else
@@ -616,12 +646,24 @@ void beginTCXO(TwoWire *i2cBus)
616646 online.tcxo = true ;
617647}
618648
619- // This function updates the TCXO to discipline the frequency
649+ // This function updates the TCXO to discipline the frequency using the latest bias
620650void updateTCXO ()
651+ {
652+ updateTCXO (tcxoClockBias_ms);
653+ }
654+
655+ // This function updates the TCXO using the specified bias and the P&I terms from settings
656+ void updateTCXO (double bias_ms)
657+ {
658+ updateTCXO (bias_ms, settings.Pk , settings.Ik );
659+ }
660+
661+ // This function updates the TCXO using the specified bias and P&I terms
662+ void updateTCXO (double bias_ms, double P, double I)
621663{
622664 if (online.tcxo )
623665 {
624- myTCXO->setFrequencyByBiasMillis (tcxoClockBias_ms, settings. Pk , settings. Ik );
666+ myTCXO->setFrequencyByBiasMillis (bias_ms, P, I );
625667 }
626668}
627669
@@ -645,7 +687,7 @@ int64_t getFrequencyControlWord()
645687}
646688
647689// This function updates the tcxoClockBias_ms used to discipline the TCXO frequency
648- // updateTCXOClockBias is only called by STATE_GNSS_FINETIME when gnssPVTUpdated was true
690+ // updateTCXOClockBias is only called by (e.g.) STATE_GNSS_FINETIME when gnssPVTUpdated was true
649691// So we know that gnssClockBias_ms is valid
650692// Use gnssClockBias_ms as the default
651693// If we have non-composite GPS from FugroTimeOffset, use that - if enabled
0 commit comments