This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
resources:eval:user-guides:ad9081_fmca_ebz:radar [07 Sep 2021 12:01] – [System deep dive] David Winter | resources:eval:user-guides:ad9081_fmca_ebz:radar [30 Jan 2023 01:51] (current) – Joyce Velasco | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== gr-ofdmradar - OFDM Radar on MxFE Platforms using IIO ===== | + | ====== gr-ofdmradar - OFDM Radar on MxFE Platforms using IIO ====== |
This page is dedicated to the details of building an OFDM radar on a ZCU102 + AD9081 with GNURadio and IIO. | This page is dedicated to the details of building an OFDM radar on a ZCU102 + AD9081 with GNURadio and IIO. | ||
+ | |||
+ | This was based on a paper pressented at: | ||
+ | * {{youtube> | ||
+ | * [[https:// | ||
If you just want to get the software and hardware running, the following section covers the setup instructions: | If you just want to get the software and hardware running, the following section covers the setup instructions: | ||
- | ==== Software / Hardware Quickstart ==== | + | ===== Software / Hardware Quickstart |
To get started, in terms of hardware you will need: | To get started, in terms of hardware you will need: | ||
Line 17: | Line 21: | ||
* A development device running x86_64 Linux | * A development device running x86_64 Linux | ||
- | * Vivado 2020.2 (Or whatever the current hdl master branch requires) | + | * Vivado 2020.2 (Or whatever the current hdl master branch requires), the Vitis SDK and a License for MPSoC parts (Included with evaluation kit) |
* A recent software build toolchain. (Usually provided by your Linux distribution. build-essential on debian stable+, base-devel on ArchLinux, etc.) | * A recent software build toolchain. (Usually provided by your Linux distribution. build-essential on debian stable+, base-devel on ArchLinux, etc.) | ||
- | === Preparing the ZCU102 boot files === | + | ==== Preparing the ZCU102 boot files ==== |
- | It is usually a good idea to start out by installing a recent image of [[resources: | + | It is usually a good idea to start out by installing a recent image of [[:resources: |
- | == Linux Kernel == | + | === Linux Kernel |
Depending on the age of your release, you may need to build a more recent kernel: | Depending on the age of your release, you may need to build a more recent kernel: | ||
Line 45: | Line 49: | ||
# Finally you can copy arch/ | # Finally you can copy arch/ | ||
- | cp arch/ | + | cp arch/ |
</ | </ | ||
Line 58: | Line 62: | ||
# Copy to ZCU102 boot directory | # Copy to ZCU102 boot directory | ||
- | cp arch/ | + | cp arch/ |
</ | </ | ||
<note important> | <note important> | ||
- | == Building the HDL == | + | === Building the HDL === |
< | < | ||
Line 83: | Line 87: | ||
The HDL build should take around 15 - 30 mins, and leave you with a projects/ | The HDL build should take around 15 - 30 mins, and leave you with a projects/ | ||
- | This guide describes how you can use the system_top.xsa to build the BOOT.BIN, which also needs to be copied into the sdcard' | + | This guide describes how you can use the system_top.xsa to build the BOOT.BIN, which also needs to be copied into the sdcard' |
Once you've got an updated linux Image, BOOT.BIN and system.dtb installed and the AD9081 eval board mounted on the ZCU102, you can start to hook up a receive and transmit antenna / or other RF components. | Once you've got an updated linux Image, BOOT.BIN and system.dtb installed and the AD9081 eval board mounted on the ZCU102, you can start to hook up a receive and transmit antenna / or other RF components. | ||
- | === Building GNU Radio === | + | ==== Building GNU Radio ==== |
To use the gr-iio AD9081 and TDD blocks, you will have to build this GNU Radio fork/ | To use the gr-iio AD9081 and TDD blocks, you will have to build this GNU Radio fork/ | ||
Line 120: | Line 124: | ||
</ | </ | ||
- | === Building gr-ofdmradar === | + | ==== Building gr-ofdmradar |
On account of being a GNU Radio module, the process to build gr-ofdmradar is quite similar: | On account of being a GNU Radio module, the process to build gr-ofdmradar is quite similar: | ||
Line 126: | Line 130: | ||
< | < | ||
# Checkout code | # Checkout code | ||
- | git clone https:// | + | git clone https:// |
cd gr-ofdmradar | cd gr-ofdmradar | ||
Line 150: | Line 154: | ||
</ | </ | ||
- | === Testing the OFDM Radar === | + | ==== Testing the OFDM Radar ==== |
- | == Simulation == | + | === Simulation |
To validate that the ofdm radar module has been installed properly, you can launch the ofdmradar_test example in the examples directory of gr-ofdmradar: | To validate that the ofdm radar module has been installed properly, you can launch the ofdmradar_test example in the examples directory of gr-ofdmradar: | ||
Line 162: | Line 166: | ||
{{: | {{: | ||
- | == On ZCU102 / AD9081 == | + | === On ZCU102 / AD9081 |
To test the OFDM radar with real hardware and signals, open the ofdmradar_ad9081.grc flowgraph in the gr-ofdmradar example directory. | To test the OFDM radar with real hardware and signals, open the ofdmradar_ad9081.grc flowgraph in the gr-ofdmradar example directory. | ||
Line 172: | Line 176: | ||
{{: | {{: | ||
- | The following video shows a test where we covered a distance of 30-40m: | + | The following video shows a test where we covered a distance of ~35m: |
{{youtube> | {{youtube> | ||
- | === Useful resources === | + | ==== Useful resources |
For more details in general about the theoretical underpinnings of OFDM radar, please check out Martin Brauns dissertation: | For more details in general about the theoretical underpinnings of OFDM radar, please check out Martin Brauns dissertation: | ||
- | For more information about gr-ofdmradar system parameters check out the [[https:// | + | For more information about gr-ofdmradar system parameters check out the [[https:// |
- | * [[https:// | + | * [[https:// |
* [[https:// | * [[https:// | ||
---- | ---- | ||
- | ==== System deep dive ==== | + | ===== Using the OFDM Radar ===== |
+ | |||
+ | This section will describe how you can use the OFDM radar to get some actual returns, how you can tune the system and choose your parameters. | ||
+ | |||
+ | Before going on, please make yourself familiar with the basic operating principles of an OFDM radar, and the meaning of the system parameters: https:// | ||
+ | |||
+ | To reinforce your understanding, | ||
+ | |||
+ | {{: | ||
+ | |||
+ | * The complex system sample rate is '' | ||
+ | * the FFT Size '' | ||
+ | * a frame has '' | ||
+ | * and the cyclic prefix length '' | ||
+ | * and '' | ||
+ | |||
+ | thus | ||
+ | |||
+ | * the total TX frame length is '' | ||
+ | * the frame duration is '' | ||
+ | * the (non-oversampled), | ||
+ | * the (non-oversampled) doppler resolution is '' | ||
+ | * the true system bandwidth is '' | ||
+ | * the final processing gain '' | ||
+ | * and finally the covered distance spread: '' | ||
+ | |||
+ | This leaves us with a couple flowgraph parameters that should be discussed: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | * The '' | ||
+ | * The '' | ||
+ | * '' | ||
+ | * The '' | ||
+ | |||
+ | Now lets take a look at the OFDM radar screen as you may see it when opening the simulation example in gr-ofdmradar: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | There are still four parameters left to be explained, that control visualization parameters (But don't change anything about the signals themselves): | ||
+ | |||
+ | * The range slider controls range which is shown, and can be thought of as an inverted zoom slider: If you want to zoom in the range dimension, move the slider to the left. | ||
+ | * The doppler range slider works similarly, but reduces the doppler ranges which are shown. This isn't usually too much of an issue. | ||
+ | |||
+ | To explain the min and max value sliders, we need to take a look at how the visualization code works: | ||
+ | |||
+ | * The input values to the gui widget have already been fully processed and can be thought of as a complex 2D matrix over range and doppler. To visualize this matrix we first take the energy of each value, then use a mapping function like the following to map those energy values to something between 0 and 1, where '' | ||
+ | |||
+ | < | ||
+ | def mapv(x): | ||
+ | x = (x-minV)/ | ||
+ | return max(min(x, 1.0), 0.0) | ||
+ | </ | ||
+ | |||
+ | This value is then fed though the turbo color map and shown on screen. For more information see the fragment shader in which all of this is happening: https:// | ||
+ | |||
+ | To really get an understanding of the max and min sliders you may need to play around with them in a simulation, but at least now you should have an idea of what they' | ||
+ | |||
+ | ---- | ||
+ | ===== System deep dive ===== | ||
The system deep dive is meant to cover the details of the entire radar system from top to bottom. Unless you're trying to recreate a similar system from scratch or trying to debug an issue, this section may not be too interesting. | The system deep dive is meant to cover the details of the entire radar system from top to bottom. Unless you're trying to recreate a similar system from scratch or trying to debug an issue, this section may not be too interesting. | ||
Line 193: | Line 256: | ||
* The Transceiver / RF ADC/DAC (AD9081) | * The Transceiver / RF ADC/DAC (AD9081) | ||
- | * Hardware, | + | * Hardware, HDL |
* Linux drivers | * Linux drivers | ||
* gr-ofdmradar and its blocks | * gr-ofdmradar and its blocks | ||
- | Before getting started with the implementation details, we need to establish | + | ==== ZCU102 / AD9081 ==== |
+ | |||
+ | Some notes on the device that were used: | ||
+ | |||
+ | The [[adi> | ||
+ | |||
+ | ==== Problem statement ==== | ||
+ | |||
+ | Before getting started with the implementation details, we need to establish | ||
{{: | {{: | ||
- | In this monostatic setup, the transmitter produces a small pulse, and then listens for the return signal. To determine the distance to the target, the time of flight is calculated by taking the time at which the signal returned, and subtracting that from the transmit time. More information like the doppler shift, RCS estimation, etc. can be estimated later on in the signal chain, but these aren't relevant right now. In this situation only the time of flight is actually | + | In this monostatic setup, the transmitter produces a small pulse, and then listens for the return signal. To determine the distance to the target, the time of flight is calculated by taking the time at which the signal returned, and subtracting that from the transmit time. More information like the doppler shift, RCS estimation, etc. can be estimated later on in the signal chain, but these aren't relevant right now. In this situation only the time of flight is actually |
- | === ZCU102 / AD9081 | + | For the remainder of this page, we will assume that the default |
- | The [[adi> | + | * 4 RX + 4 TX channels active @ 250 MS/s, 32-bit complex samples |
+ | * => '' | ||
- | === The HDL === | + | While the memory links and the FPGA can deal with these rates, the processing system and/or the Gigabit ethernet link clearly cannot. |
- | As of writing this document, not all HDL changes have made it into the [[repo> | + | {{:resources:eval: |
+ | An issue that result from this bandwidth bottleneck should be fairly obvious: We cannot transmit or receive a continuous sample stream from GNU Radio. This problem isn't unique to the direct RF platform we're working with here, but also applies to many other devices like the Pluto SDR, for all sample rates exceeding the ~3-8 MS/s (?) supported by the USB 2.0 link. | ||
+ | <note tip>The following section assumes you have a basic understanding of iio buffers. If you'd like a refresher, take a look at the | ||
+ | [[: | ||
+ | </ | ||
+ | |||
+ | So what are the guarantees provided by iio? | ||
+ | |||
+ | * All samples which are part of a single buffer will be played as a continuous stream. | ||
+ | * Buffers will not be reordered | ||
+ | |||
+ | By default this will result in a situation like the following, where RX and TX buffers are sampled completely independently, | ||
+ | |||
+ | {{: | ||
+ | |||
+ | To summarize, the two issues which we need to address: | ||
+ | |||
+ | * The data rates supported by the link make continuous transmissions impossible, we need to work with individual buffers | ||
+ | * When not transmitting continuously, | ||
+ | |||
+ | The first issue may be addressed fairly easily by increasing buffer sizes. On one hand this means that our entire transmit and receive waveform need to fit into memory at once, on the other we are guaranteed that this waveform will be continuous! | ||
+ | |||
+ | The second problem is much more tricky to solve, and requires modifications to the HDL. The basic idea is as follows: What if we don't stream continuously at the hardware level, but only in small bursts at predetermined times. This means that we're effectively using hardware to cut out small windows of the transmit and receive signals and only allowing those to pass onto the DMA (Or from the DMA to the signal chain). This results in a greatly reduced data rates (in a controlled manner), and known relationships between RX and TX. The following picture illustrates what this system should do (Which is very similar to the triggering mechanism in an oscilloscope): | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ==== The HDL ==== | ||
+ | |||
+ | <note tip>As of writing this document, not all HDL changes have made it into the [[repo> | ||
+ | </ | ||
+ | |||
+ | On the HDL side we will be using a Timing Division Duplexing (TDD) core, which was originally developed to control the [[adi> | ||
+ | |||
+ | Because the TDD engine was previously not available as a standalone IP core, i created a small wrapper which just references the existing tdd files from the util and/or common directory: [[repo> | ||
+ | |||
+ | <note tip> | ||
+ | |||
+ | === The data offload engine === | ||
+ | |||
+ | Now we should take a look at the "data offload", | ||
+ | The data offload is a rather complex block that offers a multitude of functions and configuration options, for more information see the readme: [[https:// | ||
+ | |||
+ | The interesting part for us are the synchronization modes, which allows the data offload to remain in a waiting state, until it is triggered either by a write to a register or externally. The integration into the HDL is as follows: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | <note tip> | ||
+ | |||
+ | As you can tell, the '' | ||
+ | |||
+ | For a more detailed look at the datapath with the M=8, L=4 configuration, | ||
+ | {{ : | ||
+ | |||
+ | Synchronization on the RX side is a little more involved, to explain why we need to take a look at the data packing format and the cpack cores. Imagine the following situation (Which will be quite common ;) ), you've got the default JESD configuration running (Four complex channels), but only one of those channels is actually in use. It would obviously be a waste to transfer data which isn't used, which is why the [cu]pack cores take a parallel stream of samples (All four channels, no matter which are in use) and turn that into an interleaved stream of a lower rate. That is if only a single channel out of four is active, in the above situation the output of the CPACK core will be valid only once for every four samples, and that one valid sample of 128-bit will contain all 4 complex samples for that single channel. Because the cpack core is located before the data offload in the sample stream, this means that we can store more samples when fewer channels are active. | ||
+ | |||
+ | Now finally the problem i've been trying to hint at: The tdd synchronization signal is not in any way related to the cpacks sample timer. That is depending on where the cpack core is in its process of collecting four samples compared to when the sync signal arrives, we may receive an apparently random shift of zero to three samples. To correct for this phenomenon, currently the cpack core is just reset with every sync signal. While this certainly isn't a great solution, it was the least invasive. | ||
+ | |||
+ | ==== Linux Drivers ==== | ||
+ | |||
+ | There are two drivers which may be interesting to take a look at here, the data offload and TDD driver, though obviously from the system perspective more than those two are involved. | ||
+ | |||
+ | === Data Offload === | ||
+ | |||
+ | The [[linux.github> | ||
+ | |||
+ | The second part of the driver is the integration into [[linux.github> | ||
+ | |||
+ | === TDD === | ||
+ | |||
+ | The [[linux.github> | ||
+ | |||
+ | < | ||
+ | 4 channels found: | ||
+ | data1: | ||
+ | 6 channel-specific attributes found: | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | data1: | ||
+ | 6 channel-specific attributes found: | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | data0: | ||
+ | 6 channel-specific attributes found: | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | data0: | ||
+ | 6 channel-specific attributes found: | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | 10 device-specific attributes found: | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | attr | ||
+ | 1 debug attributes found: | ||
+ | debug attr 0: direct_reg_access value: 0x10061 | ||
+ | No trigger on this device | ||
+ | </ | ||
+ | |||
+ | ==== GNU Radio Integration ==== | ||
+ | |||
+ | The GNU Radio integration consists of two parts: | ||
+ | |||
+ | * Hardware control blocks, part of in-tree gr-iio | ||
+ | * Hardware **independent** signal processing blocks, part of gr-ofdmradar | ||
+ | |||
+ | === gnuradio/ | ||
+ | |||
+ | These are: | ||
+ | |||
+ | * AD9081 Source / Sink | ||
+ | * TDD Engine Control | ||
+ | |||
+ | == AD9081 Source / Sink == | ||
+ | |||
+ | These work like pretty much any other source and sink blocks, but with a small twist: We always assume to be working with bursty data, where one burst is the size of one iio buffer. Burst / buffer boundaries are indicated by a packet length tag like this: | ||
+ | |||
+ | < | ||
+ | -> [... x-2, x-1, x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, ... ] | ||
+ | ^ ^ | ||
+ | | { packet_len: 10 } | { packet_len: 10 } | ||
+ | |||
+ | </ | ||
+ | |||
+ | Now because all iio buffers from one source will always have the same size, the length tags are somewhat redundant, but allow other blocks which cannot make these assumptions to work with those streams. | ||
+ | |||
+ | <note important> | ||
+ | |||
+ | The attributes which are available in GR boil down to the following: | ||
+ | |||
+ | * IIO context uri | ||
+ | * IIO buffer size | ||
+ | * Packet length tag | ||
+ | * NCO attributes | ||
+ | |||
+ | With some additional source/sink specific attributes: | ||
+ | |||
+ | * Sink: Cyclic Mode | ||
+ | * Source: Nyquist Zone (Odd / Even) | ||
+ | * Source: Programmable hardware FIR filter file | ||
+ | |||
+ | **AD9081 Sink Block** | ||
+ | |||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | |||
+ | **AD9081 Source Block** | ||
+ | |||
+ | {{: | ||
+ | {{: | ||
+ | |||
+ | <note tip>Note the use of '' | ||
+ | |||
+ | == TDD Control == | ||
+ | |||
+ | The TDD control block does not have any stream io, and only provides easy access to the underlying IIO attributes: | ||
+ | |||
+ | {{: | ||
+ | {{: | ||
+ | |||
+ | === gr-ofdmradar === | ||
+ | |||
+ | gr-ofdmradar is where all the interesting signal processing is happening. gr-ofdmradar ships with two categories of blocks: Those implementing OFDM Radar, and those implementing direction of arrival (DoA) for a linear array. | ||
+ | |||
+ | == OFDM Radar Blocks == | ||
+ | |||
+ | Many of the system parameters are shared between the TX, RX and GUI blocks, thus these are stored in a separate "OFDM Radar System Parameters" | ||
+ | |||
+ | {{: | ||
+ | |||
+ | The '' | ||
+ | |||
+ | {{: | ||
+ | |||
+ | The '' | ||
+ | |||
+ | {{: | ||
+ | |||
+ | <note tip>The `Buffer Size` parameter determines how many samples will be expected / ofdm frame. While the amount of samples which is actually processed is determined by the ofdm system parameters, the block can consume (and discard) additional samples to align frame boundaries to the iio buffers for example. The amount of discarded samples after each received ofdm frame can be determined as '' | ||
+ | |||
+ | Finally the '' | ||
+ | {{: | ||
+ | |||
+ | **For more information on the parameters and OFDM radar algorithm, take a look at the [[https:// | ||
+ | |||
+ | == DoA Blocks == | ||
+ | |||
+ | The Doa blocks are less integrated, but also don't come with many parameters. The implicit assumption is that we're working with a linear array and '' | ||
+ | |||
+ | ** DoA Autocorrelator ** | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ** DoA Calibration Block ** | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ** DoA MUSIC Estimator ** | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ** DoA ESPRIT Estimator ** | ||
+ | |||
+ | {{: | ||
+ |