Skip to content

Programming interface

Every function of the instrument is a standard Linux Industrial I/O (IIO) device. The same interface is used locally on the instrument and over the network through iiod, from the libiio library in C, Python, C#, MATLAB and other languages, or from the nlab Python package.

Connection

Transport libiio URI
Ethernet, by name ip:nucliflare-001ec0ade4c7.local
Ethernet, by address ip:192.168.10.128 (port 30431 is the default)
USB network ip:192.168.3.1
On the instrument local:

Use libiio 0.x (0.26 is the tested version). Command-line tools:

iio_info -s                                        # discover instruments
iio_info -u ip:192.168.3.1                         # list devices, channels and attributes
iio_attr -u ip:192.168.3.1 -d vdpp_lm_frame        # read device attributes

IIO devices

IIO name Instances Function
vdpp_scope 2 waveform capture, pulse viewer and waveform DMA
vdpp_afe_dac 1 analog baseline offset of both inputs
vdpp_input_filter 2 input FIR filter, temperature correction, DC blocker, IIR current
vdpp_pulse_processor 2 MCA configuration, counters, histogram, diagnostic signals
vdpp_lm_frame 2 list-mode event stream (128-bit records) through DMA
vdpp_sync_trigger 1 common start of both channels
ads5407 1 ADC control, converter temperature
ltc6951 1 clock generator status
xadc 1 FPGA voltages and temperature
ad5686r, mcp3564r, tmp117 — HAT: HV setpoint DAC, HV readback ADC, board temperature

Per-channel devices carry a read-only attribute channel_index (0 = channel A / CH0, 1 = channel B / CH1). Pair devices by this attribute, not by the iio:deviceN number, which depends on probe order.

Time base and data

Sampling 500 MS/s, one sample every 2 ns
FPGA clock 125 MHz, 4 samples per 8 ns clock
Scope frame 64-bit words of four 16-bit samples; word 0 is the trigger time stamp (8 ns ticks)
Sample scale datapath sample = ADC code × 16
List-mode record 16 bytes; frames of 1024 records (16 KiB)

Example: discover the channels

import iio

ctx = iio.Context("ip:192.168.3.1")
for dev in ctx.devices:
    if dev.name in ("vdpp_scope", "vdpp_pulse_processor", "vdpp_lm_frame"):
        print(dev.name, dev.id, "channel", dev.attrs["channel_index"].value.strip())

Using the nlab package

The nlab application can also be used as a Python library on top of this interface. A minimal example is kept up to date in the nlab wiki: Minimal programmatic connection; threads, DMA lifecycle and device discovery are described in Architecture.

Rules for reliable programs

  1. Stop before configuring. Most settings are refused with EBUSY while a core is enabled. Use try/finally so that an interrupted script stops the acquisition.
  2. One owner per data path. Only one client may own a channel's DMA buffer. After STOP, drain the buffer and destroy it before starting another acquisition on that channel.
  3. Keep the raw data. Store raw codes, channels and time stamps; apply calibrations as metadata.
  4. Switch the high voltage off in your cleanup code if your program switched it on.

The complete attribute reference (units, ranges, refusals and frame formats) is maintained with the Linux drivers and is available from support for integration projects. The nlab source code is a working reference implementation of the whole interface: nlab-digitizer-community.