From 7980406e007db261c58415f4b6b6501283f7fa2c Mon Sep 17 00:00:00 2001 From: nanovna <54525305+nanovna@users.noreply.github.com> Date: Thu, 7 May 2020 09:44:01 +0000 Subject: [PATCH] extend frequency range to 10kHz --- common.hpp | 2 +- main2.cpp | 40 ++++++++++++++------- sin_rom.cpp | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++ sin_rom.hpp | 5 +++ 4 files changed, 136 insertions(+), 13 deletions(-) diff --git a/common.hpp b/common.hpp index 5c4febf..5b90bd1 100644 --- a/common.hpp +++ b/common.hpp @@ -42,7 +42,7 @@ typedef int64_t freqHz_t; #define PLATFORM_NAME "BARE METAL" -#define FREQUENCY_MIN 50000 +#define FREQUENCY_MIN 10000 #define FREQUENCY_MAX 4400000000 #define SWEEP_POINTS_MIN 2 #define SWEEP_POINTS_MAX 201 diff --git a/main2.cpp b/main2.cpp index aa57817..b37dc05 100644 --- a/main2.cpp +++ b/main2.cpp @@ -224,9 +224,37 @@ void adf4350_update(freqHz_t freqHz) { synthesizers::adf4350_set(adf4350_rx, freqHz + lo_freq, adf4350_freqStep); } +// automatically set IF frequency depending on rf frequency and board parameters +void updateIFrequency(freqHz_t txFreqHz) { + // adf4350 freq step and thus IF frequency must be a divisor of the crystal frequency + if(xtalFreqHz == 20000000 || xtalFreqHz == 40000000) { + // 6.25/12.5kHz IF + if(txFreqHz >= 100000) { + lo_freq = 12500; + adf4350_freqStep = 12500; + vnaMeasurement.setCorrelationTable(sinROM24x2, 48); + } else { + lo_freq = 6250; + adf4350_freqStep = 6250; + vnaMeasurement.setCorrelationTable(sinROM48x1, 48); + } + } else { + // 6.0/12.0kHz IF + if(txFreqHz >= 100000) { + lo_freq = 12000; + adf4350_freqStep = 12000; + vnaMeasurement.setCorrelationTable(sinROM25x2, 50); + } else { + lo_freq = 6000; + adf4350_freqStep = 6000; + vnaMeasurement.setCorrelationTable(sinROM50x1, 50); + } + } +} // set the measurement frequency including setting the tx and rx synthesizers void setFrequency(freqHz_t freqHz) { + updateIFrequency(freqHz); if(freqHz > 2500000000) rfsw(RFSW_BBGAIN, RFSW_BBGAIN_GAIN(2)); else if(freqHz > 140000000) @@ -802,18 +830,6 @@ void measurement_setup() { vnaMeasurement.nPeriods = MEASUREMENT_NPERIODS_NORMAL; vnaMeasurement.init(); - // adf4350 freq step and thus IF frequency must be a divisor of the crystal frequency - if(xtalFreqHz == 20000000 || xtalFreqHz == 40000000) { - // 12.5kHz IF - lo_freq = 12500; - adf4350_freqStep = 12500; - vnaMeasurement.setCorrelationTable(sinROM24x2, 48); - } else { - // 12.0kHz IF - lo_freq = 12000; - adf4350_freqStep = 12000; - vnaMeasurement.setCorrelationTable(sinROM25x2, 50); - } setVNASweepToUI(); } diff --git a/sin_rom.cpp b/sin_rom.cpp index 177c86d..dc52037 100644 --- a/sin_rom.cpp +++ b/sin_rom.cpp @@ -7,6 +7,108 @@ // that is a convolution between a rect with width of one IF period // and a gaussian window. +const int16_t sinROM50x1[100] = { +32767, 0, +32509, -4107, +31738, -8149, +30466, -12062, +28714, -15786, +26509, -19260, +23886, -22431, +20886, -25247, +17557, -27666, +13952, -29648, +10126, -31163, +6140, -32187, +2057, -32702, +-2057, -32702, +-6140, -32187, +-10126, -31163, +-13952, -29648, +-17557, -27666, +-20886, -25247, +-23886, -22431, +-26509, -19260, +-28714, -15786, +-30466, -12062, +-31738, -8149, +-32509, -4107, +-32767, 0, +-32509, 4107, +-31738, 8149, +-30466, 12062, +-28714, 15786, +-26509, 19260, +-23886, 22431, +-20886, 25247, +-17557, 27666, +-13952, 29648, +-10126, 31163, +-6140, 32187, +-2057, 32702, +2057, 32702, +6140, 32187, +10126, 31163, +13952, 29648, +17557, 27666, +20886, 25247, +23886, 22431, +26509, 19260, +28714, 15786, +30466, 12062, +31738, 8149, +32509, 4107}; + +const int16_t sinROM48x1[96] = { +32767, 0, +32487, -4277, +31650, -8481, +30273, -12539, +28377, -16383, +25996, -19947, +23170, -23170, +19947, -25996, +16384, -28377, +12539, -30273, +8481, -31650, +4277, -32487, +0, -32767, +-4277, -32487, +-8481, -31650, +-12539, -30273, +-16383, -28377, +-19947, -25996, +-23170, -23170, +-25996, -19947, +-28377, -16383, +-30273, -12539, +-31650, -8481, +-32487, -4277, +-32767, 0, +-32487, 4277, +-31650, 8481, +-30273, 12539, +-28377, 16384, +-25996, 19947, +-23170, 23170, +-19947, 25996, +-16384, 28377, +-12539, 30273, +-8481, 31650, +-4277, 32487, +0, 32767, +4277, 32487, +8481, 31650, +12539, 30273, +16384, 28377, +19947, 25996, +23170, 23170, +25996, 19947, +28377, 16384, +30273, 12539, +31650, 8481, +32487, 4277}; + const int16_t sinROM25x2[100] = { 464, 0, 1018, -261, diff --git a/sin_rom.hpp b/sin_rom.hpp index 1ec7248..91ac42f 100644 --- a/sin_rom.hpp +++ b/sin_rom.hpp @@ -1,6 +1,11 @@ #pragma once #include +// period = 50; 1 period +extern const int16_t sinROM50x1[100]; + +// period = 48, 1 period +extern const int16_t sinROM48x1[96]; // period = 25; 2 periods extern const int16_t sinROM25x2[100];