Skip to content

Commit 7980406

Browse files
committed
extend frequency range to 10kHz
1 parent 47b2b83 commit 7980406

File tree

4 files changed

+136
-13
lines changed

4 files changed

+136
-13
lines changed

common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ typedef int64_t freqHz_t;
4242
#define PLATFORM_NAME "BARE METAL"
4343

4444

45-
#define FREQUENCY_MIN 50000
45+
#define FREQUENCY_MIN 10000
4646
#define FREQUENCY_MAX 4400000000
4747
#define SWEEP_POINTS_MIN 2
4848
#define SWEEP_POINTS_MAX 201

main2.cpp

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,37 @@ void adf4350_update(freqHz_t freqHz) {
224224
synthesizers::adf4350_set(adf4350_rx, freqHz + lo_freq, adf4350_freqStep);
225225
}
226226

227+
// automatically set IF frequency depending on rf frequency and board parameters
228+
void updateIFrequency(freqHz_t txFreqHz) {
229+
// adf4350 freq step and thus IF frequency must be a divisor of the crystal frequency
230+
if(xtalFreqHz == 20000000 || xtalFreqHz == 40000000) {
231+
// 6.25/12.5kHz IF
232+
if(txFreqHz >= 100000) {
233+
lo_freq = 12500;
234+
adf4350_freqStep = 12500;
235+
vnaMeasurement.setCorrelationTable(sinROM24x2, 48);
236+
} else {
237+
lo_freq = 6250;
238+
adf4350_freqStep = 6250;
239+
vnaMeasurement.setCorrelationTable(sinROM48x1, 48);
240+
}
241+
} else {
242+
// 6.0/12.0kHz IF
243+
if(txFreqHz >= 100000) {
244+
lo_freq = 12000;
245+
adf4350_freqStep = 12000;
246+
vnaMeasurement.setCorrelationTable(sinROM25x2, 50);
247+
} else {
248+
lo_freq = 6000;
249+
adf4350_freqStep = 6000;
250+
vnaMeasurement.setCorrelationTable(sinROM50x1, 50);
251+
}
252+
}
253+
}
227254

228255
// set the measurement frequency including setting the tx and rx synthesizers
229256
void setFrequency(freqHz_t freqHz) {
257+
updateIFrequency(freqHz);
230258
if(freqHz > 2500000000)
231259
rfsw(RFSW_BBGAIN, RFSW_BBGAIN_GAIN(2));
232260
else if(freqHz > 140000000)
@@ -802,18 +830,6 @@ void measurement_setup() {
802830
vnaMeasurement.nPeriods = MEASUREMENT_NPERIODS_NORMAL;
803831
vnaMeasurement.init();
804832

805-
// adf4350 freq step and thus IF frequency must be a divisor of the crystal frequency
806-
if(xtalFreqHz == 20000000 || xtalFreqHz == 40000000) {
807-
// 12.5kHz IF
808-
lo_freq = 12500;
809-
adf4350_freqStep = 12500;
810-
vnaMeasurement.setCorrelationTable(sinROM24x2, 48);
811-
} else {
812-
// 12.0kHz IF
813-
lo_freq = 12000;
814-
adf4350_freqStep = 12000;
815-
vnaMeasurement.setCorrelationTable(sinROM25x2, 50);
816-
}
817833
setVNASweepToUI();
818834
}
819835

sin_rom.cpp

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,108 @@
77
// that is a convolution between a rect with width of one IF period
88
// and a gaussian window.
99

10+
const int16_t sinROM50x1[100] = {
11+
32767, 0,
12+
32509, -4107,
13+
31738, -8149,
14+
30466, -12062,
15+
28714, -15786,
16+
26509, -19260,
17+
23886, -22431,
18+
20886, -25247,
19+
17557, -27666,
20+
13952, -29648,
21+
10126, -31163,
22+
6140, -32187,
23+
2057, -32702,
24+
-2057, -32702,
25+
-6140, -32187,
26+
-10126, -31163,
27+
-13952, -29648,
28+
-17557, -27666,
29+
-20886, -25247,
30+
-23886, -22431,
31+
-26509, -19260,
32+
-28714, -15786,
33+
-30466, -12062,
34+
-31738, -8149,
35+
-32509, -4107,
36+
-32767, 0,
37+
-32509, 4107,
38+
-31738, 8149,
39+
-30466, 12062,
40+
-28714, 15786,
41+
-26509, 19260,
42+
-23886, 22431,
43+
-20886, 25247,
44+
-17557, 27666,
45+
-13952, 29648,
46+
-10126, 31163,
47+
-6140, 32187,
48+
-2057, 32702,
49+
2057, 32702,
50+
6140, 32187,
51+
10126, 31163,
52+
13952, 29648,
53+
17557, 27666,
54+
20886, 25247,
55+
23886, 22431,
56+
26509, 19260,
57+
28714, 15786,
58+
30466, 12062,
59+
31738, 8149,
60+
32509, 4107};
61+
62+
const int16_t sinROM48x1[96] = {
63+
32767, 0,
64+
32487, -4277,
65+
31650, -8481,
66+
30273, -12539,
67+
28377, -16383,
68+
25996, -19947,
69+
23170, -23170,
70+
19947, -25996,
71+
16384, -28377,
72+
12539, -30273,
73+
8481, -31650,
74+
4277, -32487,
75+
0, -32767,
76+
-4277, -32487,
77+
-8481, -31650,
78+
-12539, -30273,
79+
-16383, -28377,
80+
-19947, -25996,
81+
-23170, -23170,
82+
-25996, -19947,
83+
-28377, -16383,
84+
-30273, -12539,
85+
-31650, -8481,
86+
-32487, -4277,
87+
-32767, 0,
88+
-32487, 4277,
89+
-31650, 8481,
90+
-30273, 12539,
91+
-28377, 16384,
92+
-25996, 19947,
93+
-23170, 23170,
94+
-19947, 25996,
95+
-16384, 28377,
96+
-12539, 30273,
97+
-8481, 31650,
98+
-4277, 32487,
99+
0, 32767,
100+
4277, 32487,
101+
8481, 31650,
102+
12539, 30273,
103+
16384, 28377,
104+
19947, 25996,
105+
23170, 23170,
106+
25996, 19947,
107+
28377, 16384,
108+
30273, 12539,
109+
31650, 8481,
110+
32487, 4277};
111+
10112
const int16_t sinROM25x2[100] = {
11113
464, 0,
12114
1018, -261,

sin_rom.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#pragma once
22
#include <stdint.h>
33

4+
// period = 50; 1 period
5+
extern const int16_t sinROM50x1[100];
6+
7+
// period = 48, 1 period
8+
extern const int16_t sinROM48x1[96];
49

510
// period = 25; 2 periods
611
extern const int16_t sinROM25x2[100];

0 commit comments

Comments
 (0)