Configuration

After an xTDC4 device has been initialized (see Initialization), it must be configured before it can acquire data.

To configure an xTDC4 device:

The following example shows a basic configuration of an already initialized xTDC4 device using the default configuration parameters. A complete coding example can be found on github.com/cronologic-de/xtdc_babel or in Section Code Example.

// get a default set of configuration parameters
xtdc4_configuration config;
status = xtdc4_get_default_configuration(device, &config);
if (status != XTDC4_OK) { /* handle error */ }

// configure the device
status = xtdc4_configure(device, &config);
if (status != XTDC4_OK) { /* handle error */ }

xtdc4_configure

int xtdc4_configure(xtdc4_device *device, xtdc4_configuration *config)

Configures an xTDC4 device.

Parameters:
  • device – Pointer to an xTDC4 device.

  • config – Pointer to an xtdc4_configuration struct used for the configuration.

Returns:

Status code: XTDC4_OK, XTDC4_INVALID_DEVICE, XTDC4_HARDWARE_FAILURE, or XTDC4_INVALID_CONFIG_PARAMETERS.

xtdc4_get_default_configuration

int xtdc4_get_default_configuration(xtdc4_device *device, xtdc4_configuration *config)

Obtain a default set of configuration parameters.

Parameters:
  • device – Pointer to an xTDC4 device.

  • config – Pointer to an xtdc4_configuration struct that will be filled.

Returns:

Status code: XTDC4_OK, XTDC4_INVALID_DEVICE, or XTDC4_CRONO_INVALID_ARGUMENTS.

xtdc4_get_current_configuration

int xtdc4_get_current_configuration(xtdc4_device *device, xtdc4_configuration *config)

Obtain the current set of configuration parameters of an already configured xTDC4 device.

Parameters:
  • device – Pointer to a configured xTDC4 device.

  • config – Pointer to a xtdc4_configuration struct that will be filled.

Returns:

Status code: XTDC4_OK, or XTDC4_INVALID_DEVICE.

xtdc4_configuration

struct xtdc4_configuration

This struct is used to configure an xTDC4 device using xtdc4_configure().

int size

The number of bytes this struct occupies.

int version

Version number of this struct. It is increased when the definition of the struct changes.

int tdc_mode

Operational mode of the TDC.

Must be equal to the following:

XTDC4_TDC_MODE_GROUPED

Operate in grouped mode.

Classical Common-Start operation. See also Grouping and Events.

crono_bool_t start_rising

Selects whether the rising or falling edge of the start signal is used to start a group.

double dc_offset[XTDC4_TDC_CHANNEL_COUNT + 1]

Set the threshold voltage for the input channels S, A–D.

See also Figure 4.

  • dc_offset[0]: Threshold for channel Start.

  • dc_offset[1-4]: Thresholds for Stop channels A–D.

The supported range is –1.27 to 1.13 V.

The threshold should be close to 50% of the height of the input pulse.

The effective resolution is about \(\pm\) 4 mV.

Note

The inputs are AC coupled. Thus, the absolute voltage is not important for pulse inputs. It is the relative pulse amplitude that causes the input circuit to switch. The parameter must be set to the relative switching voltage for the input standard in use.

If the pulses are negative, a negative switching threshold must be set and vice versa.

Attention

The supported range changed for driver release 1.10.7. That means, if you use a value for dc_offset outside the new supported range in your source code, the device configuration will adjust it automatically to the new supported range (e.g., a value of 1.18 V will be reduced to 1.13 V).

Values for various signaling standards are provided as macros:

XTDC4_DC_OFFSET_P_NIM

DC offset is set to 0.35 V.

XTDC4_DC_OFFSET_P_CMOS

DC offset is set to 1.13 V.

XTDC4_DC_OFFSET_P_LVCMOS_33

DC offset is set to 1.13 V.

XTDC4_DC_OFFSET_P_LVCMOS_25

DC offset is set to 1.13 V.

XTDC4_DC_OFFSET_P_LVCMOS_18

DC offset is set to 0.90 V.

XTDC4_DC_OFFSET_P_TTL

DC offset is set to 1.13 V.

XTDC4_DC_OFFSET_P_LVTTL_33

DC offset is set to 1.13 V.

XTDC4_DC_OFFSET_P_LVTTL_25

DC offset is set to 1.13.

XTDC4_DC_OFFSET_P_SSTL_3

DC offset is set to 1.13 V.

XTDC4_DC_OFFSET_P_SSTL_2

DC offset is set to 1.13 V.

XTDC4_DC_OFFSET_N_NIM

DC offset is set to –0.35 V.

XTDC4_DC_OFFSET_N_CMOS

DC offset is set to –1.27 V.

XTDC4_DC_OFFSET_N_LVCMOS_33

DC offset is set to –1.27 V.

XTDC4_DC_OFFSET_N_LVCMOS_25

DC offset is set to –1.25 V.

XTDC4_DC_OFFSET_N_LVCMOS_18

DC offset is set to –0.90 V.

XTDC4_DC_OFFSET_N_TTL

DC offset is set to –1.27 V.

XTDC4_DC_OFFSET_N_LVTTL_33

DC offset is set to –1.27 V.

XTDC4_DC_OFFSET_N_LVTTL_25

DC offset is set to –1.25 V.

XTDC4_DC_OFFSET_N_SSTL_3

DC offset is set to –1.27 V.

XTDC4_DC_OFFSET_N_SSTL_2

DC offset is set to –1.25 V.

xtdc4_trigger trigger[XTDC4_TRIGGER_COUNT]

Configuration of the polarity of the external trigger sources.

External trigger sources are used as inputs for the TiGer blocks and as inputs to the time measurement unit.

Index 0 refers to the Start channel, indices 1 through 4 to the Stop channels A through D.

xtdc4_tiger_block tiger_block[XTDC4_TIGER_COUNT]

Configuration of the Timing Generators.

Index 0 refers to the TiGer connected to the Start channel, indices 1 through 4 to the TiGer-Units connected to the Stop channels A through D.

xtdc4_channel channel[XTDC4_TDC_CHANNEL_COUNT]

Configuration of the Stop channels.

Indices 0 through 3 refer to the Stop channels A through D.

xtdc4_lowres_channel lowres_channel[XTDC4_LOWRES_CHANNEL_COUNT]

Configures additional digital low-res inputs.

Only applicable to the xTDC4-S.

uint32_t auto_trigger_period

Configure the base frequency of the auto trigger function generator.

See also auto_trigger_random_exponent.

uint32_t auto_trigger_random_exponent

Configure the randomness of the auto trigger function generator.

There is no enable or reset of the auto trigger.

Given the two parameters auto_trigger_period (M) and auto_trigger_random_exponent (N), the frequency T of the auto trigger function generator will be

\[T = M + [1 \dots 2^N] - 1\]

with 6 ≤ M < 232 and 0 ≤ N < 32.

M and N are given in units of xtdc4_static_info.auto_trigger_ref_clock.

Note

The auto trigger can be used as a source of the TiGer blocks (xtdc4_tiger_block.sources).

xtdc4_trigger

struct xtdc4_trigger

Configure if rising or falling or both edges create a trigger event for xtdc4_tiger_block.

Select which edge(s) trigger an event inside the FPGA.

The xTDC4 can output measurements with a reduced bin size of 5/6 ≈ 833.3 ps for one or both edges of the input signal. Use xtdc4_channel.rising to select which edge is measured with full resolution.

Attention

The edge that is selected for full-resolution measurements must also be enabled for a low-resolution measurement, here.

See Handling of Difficult Hits for more information on hits with varying resolution.

crono_bool_t falling

Falling edges will trigger an event.

crono_bool_t rising

Rising edges will trigger an event.

xtdc4_tiger_block

struct xtdc4_tiger_block

This struct configures the Timing Generators [see also Timing Generators (TiGer)].

crono_bool_t enable

Activates the TiGer.

Note

To use a TiGer, make sure to also set enable_lemo_output to true.

crono_bool_t negate

Inverts the output polarity.

Default is false.

crono_bool_t retrigger

Enables re-triggering.

If re-triggering is enabled, the following applies: After an event triggered the TiGer output, another event that is detected before the stop value is reached will extend the TiGer output for a time stop minus start.

crono_bool_t extend

Not applicable for the xTDC4.

crono_bool_t enable_lemo_output

Enables the LEMO output.

Drive the TiGer signal to the corresponding LEMO connector as an output.

Pulses created by the TiGer are visible at the corresponding input and can be used to get their exact timing.

Attention

The output is DC coupled. Make sure to not connect any devices to the corresponding input, as this may damage the device or the xTDC4.

uint_32_t start

Configure the duration when the TiGer output is enabled relative to the trigger.

See also stop.

uint_32_t stop

Configure the duration when the TiGer output is enabled relative to the trigger.

In multiplies of 20 ns / 3 ≈ 6.67 ns.

The range is 0 ≤ startstop < 216.

After a trigger event, a timer starts. Once the timer reaches start, the TiGer activates. Once the timer reaches stop, the TiGer deactivates.

If another trigger event is detected before the timer reaches stop and retrigger is true, the timer resets to start.

int sources

A bitmask with a bit set for all trigger sources that can trigger this TiGer block.

Default is XTDC4_TRIGGER_SOURCE_S.

Possible trigger sources are:

XTDC4_TRIGGER_SOURCE_NONE

0x00000000. No sources will trigger the TiGer block.

XTDC4_TRIGGER_SOURCE_S

0x00000001. If this bit is set, the Start channel can trigger the TiGer block.

XTDC4_TRIGGER_SOURCE_A

0x00000002. If this bit is set, Stop channel A can trigger the TiGer block.

XTDC4_TRIGGER_SOURCE_B

0x00000004. If this bit is set, Stop channel B can trigger the TiGer block.

XTDC4_TRIGGER_SOURCE_C

0x00000008. If this bit is set, Stop channel C can trigger the TiGer block.

XTDC4_TRIGGER_SOURCE_D

0x00000010. If this bit is set, Stop channel D can trigger the TiGer block.

XTDC4_TRIGGER_SOURCE_AUTO

0x00004000. If this bit is set, the auto trigger function generator can trigger the TiGer block.

XTDC4_TRIGGER_SOURCE_ONE

0x00008000. If this bit is set, the TiGer block is triggered every clock cycle.

For example, if you want the Start channel and the auto trigger to trigger the TiGer block:

int bitmask = XTDC4_TRIGGER_SOURCE_S | XTDC4_TRIGGER_SOURCE_AUTO;
config.tiger_block[i].sources = bitmask;

xtdc4_channel

struct xtdc4_channel
crono_bool_t enabled

Enable the TDC channel.

crono_bool_t rising

Select which edge of the signal is used for full-resolution measurements.

For selecting a signal edge for low-resolution measurements, xtdc4_trigger.rising and xtdc4_trigger.falling are used.

Attention

The edge that is select for full-resolution measurements here must also be selected for low-resolution measurements.

See Handling of Difficult Hits for more information on hits with varying resolution.

crono_bool_t cc_enable

Enable Delay-Line TDC.

This is set to true by default and should be left unchanged.

crono_bool_t cc_same_edge

Sets whether the Delay-Line TDC records the same or the opposite edge as the full-resolution TDC chip.

If the same edge is selected, the Delay-Line TDC acts as a backup if the full-resolution TDC chip misses hits due to FIFO overflows or short input pulses.

If opposite edges are selected, both edges of a pulse can be measured with reasonable resolution.

See Handling of Difficult Hits for more information on hits with varying resolution.

crono_bool_t ths788_disable

Disable full-resolution timestamps.

This is set to false by default and should be left unchanged.

uint32_t start

Start value for the grouping functionality.

In multiples of xtdc4_param_info.binsize.

See also stop and Grouping and Events.

uint32_t stop

Stop value for the grouping functionality.

In multiples of xtdc4_param_info.binsize.

Only hits between start and stop are read out.

The range is 0 ≤ startstop < 230.

See also Grouping and Events.