How-to
GNU Octave
In GNU Octave the vortarian MEX file receives both links on its own threads, aligns them by the datagram headers and returns a contiguous block of all four channels as an int16 matrix.
Requirements
| Item | Value |
|---|---|
| Host | Linux x86-64 (the MEX file uses recvmmsg) |
| GNU Octave | tested with 8.4; no additional packages |
| Binary | vortarian.mex: vortarian-octave releases |
| Example scripts | host-tools |
| Host settings | Host setup |
Put the MEX file in one folder with the scripts and add the folder to the path:
addpath('~/vortarian');
vortarian('version')
Calls
| Call | Function |
|---|---|
vortarian('version') | Version of the MEX file. |
vortarian('config', 'host', '192.168.67.2') | Sets the defaults for the following calls. |
txt = vortarian('cmd', 'adc 1 nco 375000000') | Sends a command, or a cell array of commands, and returns the answer. Commands: Board control. |
[iq, info] = vortarian('rx', N) | Captures N contiguous samples per channel from the running streams. |
[iq, info] = vortarian('rx', N, ...) | The same with the options below. |
Option of 'rx' | Meaning |
|---|---|
'on', 'debug on' | Command sent before the capture: starts the streams. |
'off', 'debug off' | Command sent after the capture: stops the streams. |
'ports', 10700 | One link only: iq has four columns. |
'margin', M | Datagrams kept per link while waiting for the other link; default 8192 (67 MB per link). |
Returned data
Column of iq | Content |
|---|---|
| 1, 2 | I, Q of RX A |
| 3, 4 | I, Q of RX B |
| 5, 6 | I, Q of RX C |
| 7, 8 | I, Q of RX D |
- int16; full scale 32768.
- Row k is the same sampling instant in all four channels.
- The block is always contiguous. When a datagram is lost, the block restarts after the gap.
inforeports the datagrams lost before the block was complete.
Conversion to complex samples of all four channels:
x = complex(double(iq(:, 1:2:end)), double(iq(:, 2:2:end))) / 32768;
Memory
| Quantity | Size |
|---|---|
| 1 s of all four channels, as datagrams | 1 GB per link |
| 1 s of all four channels, complex double | 8 GB |
| Socket buffer requested per link | 256 MB |
Process long records in parts.
Timing
- The capture start is a software event: its timing against the outside world varies by milliseconds.
- Within a block, the samples are spaced exactly 1/fs = 8 ns.
- Each
vortarian('rx', N)call opens the sockets, takes the next N contiguous samples and closes the sockets; the datagrams between two calls are not received. - When the sockets open, one link can start about 1 ms after the other. With repeated calls on running streams use
'margin', 1024. - A call for 262 144 samples (2.1 ms) takes about 10 to 15 ms on the test host.
Minimal capture
vortarian('config', 'host', '192.168.67.2');
vortarian('cmd', 'init'); % once after power-up
vortarian('cmd', {'adc 1 nco 375000000', 'adc 2 nco 375000000'});
iq = vortarian('rx', 2^21, 'on', 'debug on', 'off', 'debug off');
x = complex(double(iq(:, 1:2:end)), double(iq(:, 2:2:end))) / 32768;
Example scripts
| Script | Function |
|---|---|
vortarian_spectrogram.m | Spectrogram of one channel: 221 samples (16.8 ms), 1024-point Hann FFT, dBFS, IF and RF axes. |
vortarian_spectrogram_4ch.m | Spectrograms of all four channels from one capture, common colour scale. |
optimize_eth_config.sh | Host interface settings. |
The same scripts run in MATLAB unchanged; only the default colour map differs. Scaling of the spectra: Spectrum scaling.
vortarian_spectrogram_4ch.m with the 4R2C-2G5 front-end (2450 MHz at IF 375 MHz), RF gain 20 dB, antennas on RX A and RX B, none on RX C and RX D. Wi-Fi frames of several transmitters between 2400 and 2470 MHz, with different levels on the two antennas; a pulsed carrier at 2450.5 MHz, one pulse about every 510 µs, with the frequency sweep of its switch-off as dashes up to 2485 MHz. The colour scale runs from 10 dB below the median to the maximum of the capture, here −104.6 to −45.9 dBFS.
Signal in the time domain
A narrow-band signal is taken out of the capture by mixing it to 0 Hz, filtering and decimating. With x from the minimal capture (NCO 375 MHz at RF 2450 MHz), the Bluetooth Low Energy advertising channel on 2402 MHz of RX A:
fs = 125e6; D = 5;
n = (0:size(x, 1) - 1)';
y = x(:, 1) .* exp(-2i * pi * (2402e6 - 2450e6) / fs * n); % 2402 MHz to 0 Hz
h = conv(ones(50, 1), ones(50, 1)); % low-pass, about 2 MHz wide
y = filter(h / sum(h), 1, y); y = y(1:D:end); % 25 MS/s
level = 20 * log10(abs(y) + 1e-9); % envelope [dBFS]
f = angle(y(2:end) .* conj(y(1:end-1))) * (fs / D) / (2 * pi); % instantaneous frequency [Hz]
The filter is two moving averages of 50 samples in series; it needs no toolbox or package.
One advertising packet, antenna on RX A, RF gain 20 dB, drawn in GNU Octave. Top: envelope, −29.3 dBFS; the transmitter is on for about 400 µs. Middle: I and Q of the first 44 µs. Bottom: instantaneous frequency, GFSK at 1 Mbit/s with about ±230 kHz deviation; the 8 preamble bits and the 32 bits of the advertising access address 0x8E89BED6 can be read directly. The bit labels were added for the figure.
A detail of a pulsed signal, with a zoomed spectrogram: Python.
Error messages
| Message | Cause |
|---|---|
vortarian:busy | Another client holds the control port: board console, a second Octave session, GNU Radio. |
vortarian:board | The board answered with an error, for example “Board initialization has not been run”: init has not run since power-up. |
vortarian:nodata, timeout | No datagrams arrive: links, host addresses, firewall for UDP 10700 and 10701. |
no ... contiguous packets present in all streams | Datagrams lost on the host: MTU, ring size, pause frames, net.core.rmem_max; or raise 'margin'. |