NanoVNA-D
NanoVNA-D copied to clipboard
Feature request: allow also 100 points (and 400 for H4 version)
101 points is perfect if you sweep a small band of e.g. 140..150 MHz, this gives 140.0, 140.1, 140.2,... 150.0 MHz. But if you want to do a broadband sweep, e.g. 20k .. 2 M for a switching application filter you get odd steps of 20.0, 39.8, 59.6,... 1989.2, 2000.0 kHz, while 100 points yield nice frequencies of 20.0, 40.0,... 2000 kHz. What do you think about my quick solution?
diff --git a/nanovna.h b/nanovna.h
index 36268c8..8dc97fd 100644
--- a/nanovna.h
+++ b/nanovna.h
@@ -248,20 +248,20 @@ typedef uint32_t freq_t;
// Optional sweep point (in UI menu)
#if POINTS_COUNT >=401
-#define POINTS_SET_COUNT 5
-#define POINTS_SET {51, 101, 201, 301, POINTS_COUNT}
+#define POINTS_SET_COUNT 6
+#define POINTS_SET {51, 101, 201, 301, POINTS_COUNT-1, POINTS_COUNT}
#define POINTS_COUNT_DEFAULT POINTS_COUNT
#elif POINTS_COUNT >=301
-#define POINTS_SET_COUNT 4
-#define POINTS_SET {51, 101, 201, POINTS_COUNT}
+#define POINTS_SET_COUNT 5
+#define POINTS_SET {51, 101, 201, POINTS_COUNT-1, POINTS_COUNT}
#define POINTS_COUNT_DEFAULT POINTS_COUNT
#elif POINTS_COUNT >=201
-#define POINTS_SET_COUNT 3
-#define POINTS_SET {51, 101, POINTS_COUNT}
+#define POINTS_SET_COUNT 4
+#define POINTS_SET {51, 101, POINTS_COUNT-1, POINTS_COUNT}
#define POINTS_COUNT_DEFAULT POINTS_COUNT
#elif POINTS_COUNT >=101
-#define POINTS_SET_COUNT 2
-#define POINTS_SET {51, POINTS_COUNT}
+#define POINTS_SET_COUNT 3
+#define POINTS_SET {51, POINTS_COUNT-1, POINTS_COUNT}
#define POINTS_COUNT_DEFAULT POINTS_COUNT
#endif
Hmm X+1 pints give X intervals between points (frequency step) If span = 1k then step = 1k / x and for 101 point result 1k/100 = 10 Hz step look good So need use N * 100 span for get good step Your solution not give good resut, most good enter point count keyboard for input any value, but i think better use correct span (again need use N * 100 Hz, for 101 points)
So need use N * 100 span for get good step
This is what I wrote, for span = 1 MHz (e.g. 20..21 MHz) 101 points -> 100 steps -> ok. But if I do a sweep starting almost at zero (e.g. 10 kHz..1MHz, because 0..1MHz is not possible) -> span of 990 kHz -> 99 steps of 10k (=100 points) is perfect -> 10k, 20k, 30k,...1000k looks good (or 20, 40, 60,...2000k as seen in my screenshot above). The 100 points instead of 101 compensates the first missing 0Hz sample.
100 solve problem only for N*99 Hz span, wny only this? Why not N * 98 ot others? Best solution add point input keyboard as on V2
Best solution add point input keyboard as on V2
Or automatic solution for my special case of sweeping from (near) DC is: If start = 0Hz then skip this 1st point and reduce points by one internally.
Set points=101, start=0, stop=1MHz -> sweep 100 points: 10k, 20k, ... 1000k
I allow input custom points number from keyboard in last commit
Nice, think you.