From 5ba812054fa5e9c62bc4f823813d4ba78b9a515b Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 17 Nov 2026 18:29:07 +0100 Subject: [PATCH] Spur check: program the planned LO also when the clearing move is zero Inside a hysteresis stretch the LO sits up to 50 kHz off the target and a product can be inside D only because of that error. The nearest clearing plan is then the target itself, which the check recorded as a zero shift and skipped, leaving the line (ZS406, 1603.6 MHz family, RBW 30k, 15 kHz step). Apply the plan whenever one was found; shift the IF only when the move is nonzero. --- sa_core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sa_core.c b/sa_core.c index 2014d58..1f52195 100644 --- a/sa_core.c +++ b/sa_core.c @@ -4811,13 +4811,17 @@ again: // Spur redu retune = LO_retune(target_f); if (retune) ADF4351_plan_frequency(target_f, &plan); - } else if (best_s != 0) { + } else if (best_cost != INT32_MAX || best_a > (o < 0 ? -o : o)) { + // A planned LO that clears D (or the budget edge that helps most). Program it even when the move is + // zero: the product was inside D only because the hysteresis holds the LO off the target. if (debug_avoid) stored_t[i] = -60.0; // Display when to do spur shift in the stored trace - local_IF += best_s; - LO_spur_shifted = true; + if (best_s != 0) { + local_IF += best_s; + LO_spur_shifted = true; + } target_f = best_f; plan = best_plan; - retune = true; // a shifted point programs its planned LO: the hysteresis would keep the old one + retune = true; } } if (retune) { // as set_freq(ADF4351_LO, target_f)