Skip to content

Commit

Permalink
extend frequency range to 10kHz
Browse files Browse the repository at this point in the history
  • Loading branch information
nanovna committed May 7, 2020
1 parent 47b2b83 commit 7980406
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 13 deletions.
2 changes: 1 addition & 1 deletion common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 28 additions & 12 deletions main2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}

Expand Down
102 changes: 102 additions & 0 deletions sin_rom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions sin_rom.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#pragma once
#include <stdint.h>

// 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];
Expand Down

0 comments on commit 7980406

Please sign in to comment.