aboutsummaryrefslogtreecommitdiffstats
path: root/host/docs/calibration.dox
blob: b5f747bd3c51c8080192604a3cd5eba7cd7e85ff (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*! \page page_calibration Device Calibration

\tableofcontents

\section calibration_self Self-Calibration

UHD software comes with several self-calibration utilities for
minimizing IQ imbalance and DC offset. These utilities perform
calibration sweeps using transmit leakage into the receive path (special
equipment is not required). The results from a calibration are written
to a file in the user's home directory. UHD software will
automatically apply corrections at runtime when the user re-tunes the
daughterboard LO. Calibration results are specific to an individual RF
board.

<b>Note:</b> When a calibration table is present, and the user wishes to
override the calibration settings through the API: the user should
re-apply the desired setting every time the LO is re-tuned.

UHD software comes with the following calibration utilities:

-   **uhd_cal_rx_iq_balance:** - minimizes RX IQ imbalance vs. LO
    frequency
-   **uhd_cal_tx_dc_offset:** - minimizes TX DC offset vs. LO
    frequency
-   **uhd_cal_tx_iq_balance:** - minimizes TX IQ imbalance vs. LO
    frequency

The following RF frontends are supported by the self-calibration
utilities:

-   RFX Series transceiver boards
-   WBX Series transceiver boards
-   SBX Series transceiver boards
-   CBX Series transceiver boards
-   UBX Series transceiver boards
-   USRP N320

\subsection calibration_self_utils Calibration Utilities

UHD software installs the calibration utilities into
`<install-path>/bin`. **Disconnect** any external hardware from the
RF antenna ports, and run the following from the command line. Each
utility will take several minutes to complete:

    uhd_cal_rx_iq_balance --verbose --args=<optional device args>
    uhd_cal_tx_iq_balance --verbose --args=<optional device args>
    uhd_cal_tx_dc_offset --verbose --args=<optional device args>

See the output given by `--help` for more advanced options, such as
manually choosing the frequency range and step size for the sweeps.

<b>Note:</b> Your daughterboard needs a serial number to run a calibration
utility. Some older daughterboards may not have a serial number. If this
is the case, run the following command to burn a serial number into the
daughterboard's EEPROM:

    <install dir>/lib/uhd/utils/usrp_burn_db_eeprom --ser=<desired serial> --args=<optional device args>

\subsection calibration_data Calibration Data

By default, calibration files are stored in the user's home/application
directory (`$XDG_DATA_HOME`):

-   **Linux:** `${HOME}/.local/share/uhd/cal/`
-   **Windows:** `%LOCALAPPDATA%\uhd\cal\`

Calibration files are binary files with a `.cal` file extension.

If you would like to specify a custom directory, you can do so with the
`$UHD_CAL_DATA_PATH` environment variable.

Calibration files can easily be moved from one machine to another by copying the
"cal" directory, or individual files therein.  Re-running a calibration utility
will replace the existing calibration file. The old calibration file will be
renamed so it may be recovered by the user.

\subsection modify_cal_data Modify Calibration Data

There might be reasons to analyse or modify the calibration data outside UHDs
calibration process. Because the data is stored using FlatBuffers this can be
done without relying on UHD. UHD provides all FlatBuffer schema files in
`<install-path>/share/uhd/cal`.

First, install FlatBuffers. The package can be obtained from
https://google.github.io/flatbuffers/.
Once installed, `.cal` files can be converted to JSON using

	flatc --strict-json -t <install dir>/share/uhd/cal/<flatbuffer>.fbs -- <data>.cal
	
where `<flatbuffer>.fbs` is the scheme file used for the data,
e.g. `pwr_cal.fbs` for power calibration. `data.cal` is a calibration file in
your working directory. This will generate a `<data>.json` in the same
directory.

The JSON data can be converted back to binary using

	flatc -b <install dir>/include/uhd/cal/<flatbuffer>.fbs <data>.json
	
This generates a `<data>.bin` that can be read by the calibration routines
of UHD. To make UHD reading these files you need to rename it to `<data>.cal`.
	
\subsection calibration_data_csv Converting UHD 3.x calibration data to UHD 4

Older versions of UHD used a CSV-based format for storing calbration data for
IQ imbalance and DC offset correction on some devices (e.g., X300, N200
motherboards and WBX/SBX/CBX/UBX daughterboards).

Going forward, all calibration data is stored as binary, to facilitate storing
it on device's flash memory, among other reasons. Running the `uhd_cal_*`
utilities will automatically generate the calibration data in the new format.

To convert existing calbration data to the new format, use the convert_cal_data.py
utility. By default, it will convert all existing data. Use `convert_cal_data.py --help`
to get a full list of command line options.
The tool is installed with the other utilities, for example into `/usr/share/lib/uhd/utils`,
depending on your OS and CMake settings.


\subsection ignore_cal_file Ignoring Calibration Files

At runtime, the user can choose to ignore a daughterboard's calibration file by
adding "ignore-cal-file" to the arguments. With the UHD API, it can be done as
follows:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
    auto usrp = uhd::usrp::multi_usrp::make("type=x300,ignore-cal-file=1");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Using tx_waveforms as an example, the user can apply this argument as follows:

    tx_waveforms --args="addr=192.168.10.2,ignore-cal-file=1" --freq=100e6 --rate=1e6

*/
// vim:ft=doxygen: