-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
72 lines (55 loc) · 2.83 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
///////////////////////////////////////////////////////////////////////////////
// 04_log_frequency_sweep //
// Copyright © 2023 AAI Robotics Ltd. //
// MIT License. See LICENSE.txt for terms. //
// //
// Runs a sweep where the frequency of the measurement points increases //
// exponentially, using the (interpolated) factory calibration, and prints //
// the results in re/im format.
// //
///////////////////////////////////////////////////////////////////////////////
#include <vna/cxx/VNA.h>
#include "printing.h"
int main()
{
/// Connect to the VNA
////////////////////////////////////////////
vna::Device instrument = vna::Device::openAny();
// Or if you don't have a VNA...
//vna::Device instrument = vna::Device::openDemo();
/// Query VNA model information and print the serial of the connected instrument
////////////////////////////////
vna::DeviceInfo instrumentInfo = instrument.getInfo();
printf("Instrument connected: %s\n", instrumentInfo.serial.c_str());
/// Configure the measurement
////////////////////////////////////////////
// We do not explicitly load a user calibration, therefore the measurement will be performed using the
// interpolated factory calibration.
vna::MeasurementConfiguration cfg{};
double measurementFrequencyHz{ 0.3E6 };
// Add measurement points to the configuration with exponentially increasing frequency until
// we get the maximum frequency supported by the instrument
while (measurementFrequencyHz < instrumentInfo.maxSweepFrequencyHz)
{
vna::MeasurementPoint pt{};
pt.frequencyHz = measurementFrequencyHz;
pt.powerLeveldBm = 0.0;
pt.bandwidthHz = 10000; // 10 kHz
cfg.addPoint(pt);
measurementFrequencyHz *= 1.01;
}
// check that we've not exceeded the 10,001 point limit for the number of measurement points
if (cfg.getPoints().size() > 10001)
{
printf("ERROR: sweep exceeds 10,001 points in length. Exiting without performing sweep.");
return 1;
}
/// Do the measurement (synchronously)
////////////////////////////////////////////
printf("--------------------------------------------- Sweeping ------------------------------------------\n");
// Run the sweep to completion, synchronously, and print the results.
std::vector<vna::SParameterMeasurementPoint> result = instrument.performMeasurement(cfg);
printMeasurementPoints(result);
printf("--------------------------------------------- Done ------------------------------------------\n");
return 0;
}