Triggers

Overview

Summary

Triggers are used to stream based on signals, or to output signals based on streaming. For example, a trigger can be used to send a set number of samples on each pulse, or to output high whenever a channel is transmitting. There is a global trigger, connected via SMA, that is shared electrically by all channels, but each channel can be configured to interact with it independently.

See txrx_advanced_trigger.cpp for an example of how to use the UHD trigger API. Modifying the trigger settings through the state tree is deprecated. To simulate a trigger input, you can physically connect the PPS SMA port to the TRIG (in) SMA port to practice. See trigger_options.hpp and trigger_configure in multi_usrp.hpp for a complete list of options and behaviour.

trigger_configure takes:

Input triggers

Input triggers cause the device to transmit/receive when a trigger is active. Edge mode triggers activate for a programmable duration on a rising/falling edge. Level mode triggers are active while a given trigger signal is active. You can set whether the trigger is active high/rising edge or active low/falling edge. For TX you can set whether to consume samples according to stream commands (normal operation) but blank the output when triggers are not active (output gating), or to only consume samples when stream commands and triggers say to stream (DSP gating).

When combining triggers, stream commands and all enabled input triggers are processed individually and ANDed together at the end. Streaming will only occur when all of them say to stream.

Output triggers

Output triggers send a signal depending on the device’s streaming state. Edge mode activates for a programmable duration at the start of streaming. Level mode is active while streaming. You can program whether the trigger is active high or active low.

When multiple output triggers use the same pin (the global SMA trigger), they are processed individually and ORed together at the end.

Usage notes

Specific Pins/Triggers

Global (SMA) Trigger

The global SMA trigger on Crimson/Calamine uses a single bidirectional pin. Cyan/Chestnut have separate input and output pins, however each individual channel can only use one at a time. Channels set to output on the SMA are processed individually and the final result is ORed together. Recommended: always set the direction to pin_direction_t::derive, which selects it based on whether active_trigger_t::sma_input or active_trigger_t::sma_output is present in trigger_rx_t::trig_sel/trigger_tx_t::trig_sel.

Per Channel (U.FL) Trigger

Every channel has an individual bidirectional trigger pin, however using it requires additional hardware. Please contact us for more information on this optional hardware upgrade.

Examples

See txrx_advanced_trigger.cpp for an example of how to use the new trigger API.

Options

The following are the arguments contained within the structs passed to trigger_configure.

Setup mode

How to perform the trigger configuration. The only mode supported as of uhdpv 4.10.0.14 is setup_mode_t::standard, which disables all channels without specific settings, and disables all channels without hot_configure enabled while applying the configuration. Note that disabling a channel will result in any stream commands or samples being lost.

Error handling

What to do after an error. As of uhdpv 4.10.0.14, failure_handling_t::disable_all_after_validation and failure_handling_t::flexible exist. disable_all_after_validation attempts to disable all channels if a failure occurs after validation, and does nothing if a failure occurs while validating arguments. flexible simply stops, leaving the device in whatever state it was in when the failure occurred. Neither guarantees the state of the device after a failure. In general you should use flexible when only getting the configuration or setting one value, and disable_all_after_validation for all other cases.

Error detection/warning messages

Bits set in enable_strict_errors enable errors depending on the flags set. Bits set in disable_warnings disable warnings depending on the flags set. Errors added after the initial release will usually default to disabled for compatibility. New warnings are enabled by default. Note that errors are enabled when their bit is set, but warnings are disabled when their bit is set. Unlike all other fields, unrecognized bits are ignored instead of causing a uhd::value_error.

Electrical pin direction

The electrical direction of the pin(s). They can be input, output, separate, or derived. Separate is used because some configurations have separate input and output pins, while others have a single bidirectional pin. The global SMA is bidirectional on Crimson/Calamine and separate on Cyan/Chestnut. The per channel U.FL is bidirectional on both. Recommended: use pin_direction_t::derive for the global SMA setting, which derives it from trig_sel, to keep your code compatible between Crimson and Cyan.

Polarity

Whether a trigger is active high or active low. For input triggers this influences how a signal is interpreted and is applied before anything else, which is why the term “active” is used in this document instead of high or low. In output mode, polarity is applied to the final output. Output triggers in edge mode still activate for a duration at the start of streaming when set to negative polarity; the polarity only determines whether that output is high or low while the trigger is active.

SMA override

When enabled, the trigger acts as if it is always receiving a HIGH input. It is primarily used for debugging.

Output edge pulse length

How long, in samples, to keep an output trigger active. The global sma_output_pulse_length is applied to each channel individually, and its duration is based on each channel’s sample rate.

Edge backoff

How long, in ticks, to reject edges on the input trigger after an edge. Does nothing in level mode or for output triggers. Its primary role is debouncing. Crimson/Calamine usually have a tick rate of 162.5 MHz, but may have a rate of 150 MHz. Cyan/Chestnut always have a tick rate of 250 MHz.

Channel

The physical channel to apply this configuration to. The order does not matter. Channels not in any trigger_rx_t or trigger_tx_t passed to trigger_configure will be disabled.

Input edge sample count

How long, in samples, to keep a trigger active after receiving an edge on the input trigger. Applies to edges on the global SMA and per channel U.FL independently. Remember that all active triggers and stream commands are ANDed together, so you may not receive all the samples asked for by this value.

Trigger selection

A bitmask of which triggers to listen/output to. active_trigger_t::sma_input and active_trigger_t::sma_output enable the global SMA trigger for the channel. Even on Cyan, which has separate SMA input and output pins, each channel can only use one at a time. Whether active_trigger_t::channel_ufl is an input or output trigger depends on the electrical direction of the pin.

When combining input triggers, they are processed independently and the final result (along with stream commands) is ANDed together. When combining output triggers from multiple channels on the same pin (the global SMA trigger), they are processed independently and the final result is ORed together.

Note that the bits in trig_sel on the server are different between Crimson/Calamine and Cyan/Chestnut. UHDPV will translate to the correct bit mappings for the device. Make sure you update to the new system properly if converting from old server writes for trig_sel.

Trigger sensitivity mode

Determines whether the trigger is in edge or level mode. An output trigger in level mode is active while the channel is streaming. An input trigger in level mode is active while its signal is active. An output trigger in edge mode is active for the output edge pulse length when the channel starts streaming. An input trigger in edge mode is active for the input edge sample count. Polarity determines whether the signal is active high or active low.

Hot configuration

By default channels are disabled while the configuration is being applied (even if only getting values). This also results in any samples or stream commands being lost. With hot_configure enabled, channels will not be disabled while the configuration is being applied. The order in which settings are applied is not guaranteed, so you risk spurious activations. Recommended: only use this when changing one setting relevant to the channel, or only getting values.

Enable

Enables or disables the channel. All channels with disable requested are disabled before any other settings are applied. All channels with enable requested are enabled after all other settings are applied. Remember that without hot_configure all channels will be disabled while the configuration is being applied. Disabling a channel, even the temporary disabling during configuration, will clear all samples and stream commands.

TX gating

With gating_t::dsp, samples are consumed only when all input triggers are active. With gating_t::output, samples are consumed normally, but the final output is blanked unless all input triggers are active. Has no effect if no input triggers are enabled.

When using DSP gating, call tx_streamer->enable_blocking_fc(uint64_t blocking_setpoint) so that the streamer knows samples will only be consumed by triggers. Otherwise it will assume samples are consumed at the same rate/time as with no input triggers enabled, causing overflows. Note that enable_blocking_fc(uint64_t blocking_setpoint) will greatly reduce your maximum achievable sample rate.

State tree based API

Deprecated

This section details the old API, which involved manual writes to the state tree. It is kept for people maintaining existing code that relies on it. Not for new programs.

Global (SMA) Trigger Overview

Deprecated

This section is kept for the purposes of old documentation and learning resources that point to it. See Summary for an updated overview.

The global trigger is bi-directional and may be used to specify when to start transmitting or receiving samples, and also indicate when specific channels are transmitting or receiving data. When using the global trigger, you must specify a direction (input or output) and polarity (active high, active low), which applies across all radio channels.

Though the direction and polarity is universal, each radio channel may have a unique sensitivity (level, edge) to the global trigger. Each radio channel may have a unique global trigger sensitivity (edge, level), and trigger selection (trigger disabled, global trigger, per-channel trigger, or both). Whether a specific radio channel contributes to the global trigger is specified with the trig_sel parameter, which specifies the applicable triggers for a given radio channel.

Global Trigger Direction and Channel Applicability

Deprecated

This section is kept for the purposes of old documentation and learning resources that point to it. See Summary for an updated overview.

When specifying the global trigger direction as an input, an active trigger will serve to start broadcasting user provided samples over the corresponding Tx channel, or else indicate when the receive chain should start receiving RF data and send it to the user application over the SFP+ ports. A global input trigger is applied simultaneously on all applicable radio channels (as specified by the trig_sel).

Selecting a global trigger output direction serves to indicate when the Tx channel is starting to broadcast data over the air, or when the Rx channel is processing RF data and sending it to the user application. The global trigger with an output direction is the result of OR’ing applicable radio channel triggers (as specified by trig_sel), such that the triggering of the specified condition on any channel will assert the global SMA trigger.

Per Channel (U.Fl) Triggers

Deprecated

NonstandardOption The default (Cyan/Crimson TNG) unit does not expose per channel triggers; please contact us for more information on this optional hardware upgrade.

Per Channel triggers operate similarly to the global trigger, except that there is one unique trigger per radio channel. This hardware option provides for a unique trigger to be specified, along with direction and polarity, per radio channel.

Trigger Parameter Summary

Deprecated

fpga/trigger/
                           sma_dir
                           sma_pol
rx/{a,b,c,d}/trigger/
                           edge_sample_num
                           edge_backoff
                           sma_mode
                           trig_sel
                           ufl_dir
                           ufl_mode
                           ufl_pol
tx/{a,b,c,d}/trigger/
                           edge_sample_num
                           edge_backoff
                           gating
                           sma_mode
                           trig_sel
                           ufl_dir
                           ufl_mode
                           ufl_pol

Trigger Parameter Descriptions

Deprecated

The following provides a more detailed description of all the trigger parameters.

sma_dir

Deprecated

Old path state/fpga/trigger/sma_dir
New option Electrical pin direction
Legal Values in, out
Default Value out
Description Specifies direction of Global SMA Trigger port, with respect to the FPGA.

Additional Information To export a trigger, for example, to indicate you are transmitting samples, specify the direction as output - with Cyan/Crimson TNG effectively generating a trigger on the specified event. To receive a trigger, such as when you want to specify the initial receipt of samples, set this direction to input. When the trigger is set as an input, it is AND’d across all channels. When using an output trigger, the global trigger is OR’d across all applicable channels, such that the trigger condition on any given channel will trigger it.

sma_pol

Deprecated

Old path state/fpga/trigger/sma_pol
New option Polarity
Legal Values positive, negative
Default Value positive
Description Specify Global SMA Trigger assertion state as VCC (positive) or GND (negative)

Additional Information This indicates what voltage level constitutes a logically high trigger. If the value is “positive”, then the untriggered state shall be specified with GND at the SMA, and the triggered state by VCC (active high). If the value is “negative”, then the trigger shall be reversed (active low).

NOTE: The trigger input has a fixed, weak, pull-up. The polarity is set using FPGA logic. This means that you must actively sink the trigger input to GND for proper operation during blanking periods; a floating or unconnected source will not work effectively.

Warning

Laboratory Use Only EXCEEDING SPECIFIED IO LEVELS MAY RESULT IN DAMAGE OR INJURY The trigger is directly connected to the FPGA; violating the specified voltage range may damage the unit.
edge_sample_num

Deprecated

Old path state/{rx,tx}/{a,b,c,d}/trigger/edge_sample_num
New option Input edge sample count
Legal Values 0..(\(2^64\)-1)
Default Value 0
Description Number of samples to transmit or receive after receiving trigger. (0=continuous)
Note Only applicable when in edge mode on input triggers.

Additional Information A 64-bit unsigned integer, representing the number of samples (based on the user specified sample rate after decimation), to collect and send to the host PC, on receipt of a trigger. A value of 0 indicates to immediately start sending samples indefinitely (no count is used). The number of samples to transmit corresponds to the number of samples provided by the user at the user specified sample-rate.

edge_backoff

Deprecated

Old path state/{rx,tx}/{a,b,c,d}/trigger/edge_backoff
New option Edge backoff
Legal Values 0..(\(2^31\)-1)
Default Value 0
Description Timeout after trigger to debounce or reduce ringing.
Note Only applicable when in edge mode.

Additional Information A 32-bit unsigned integer, representing the duration, as measured in intervals of 162.5MHz, to ignore further transitions of the trigger. This may be used to reduce ringing or bouncing.

sma_mode

Deprecated

Old path state/{rx,tx}/{a,b,c,d}/trigger/sma_mode
New option Trigger sensitivity mode
Legal Values edge, level
Default Value level
Description Trigger mode associated with TRIG SMA port.

Additional Information This specifies whether the SMA trigger should be edge or level sensitive. A level sensitive trigger is asserted on the leading edge of an input, and remains asserted for as long as the level remains high. On Rx radio channels, the trigger gates at the interface of the converter device, prior to decimation. On Tx radio channels, the gating property modifies the gate to operate on either the interface between the interpolation stages and the interpolator, similar to a blanking signal, or between where the user provided data is passed to the internal DSP interpolation stages. Edge sensitive trigger behaviour is further specified by the edge_sample_num and edge_backoff properties.

trig_sel

Deprecated

Old path state/{rx,tx}/{a,b,c,d}/trigger/trig_sel
New option Trigger selection
Legal Values {0..3}
Default Value 3
Description Select what triggers are applicable to the channel.

Additional Information Specifies whether the channel should contribute, or respond, to the specified triggers. This has the following values:

0 Not Triggered (Global Trigger disabled, Per-Channel U.Fl channel trigger disabled)

1 Global SMA trigger only (Per Channel U.Fl disabled)

2 Per Channel U.Fl only (Global SMA trigger disabled)

3 All Triggers on (Global SMA trigger and U.Fl Per Channel trigger enabled)

gating

Deprecated

Old path state/tx/{a,b,c,d}/trigger/gating
New option TX gating
Legal Values output, dsp
Default Value output
Description Specify gating mode for Tx triggers only.
Notes Tx only trigger option.

Additional Information This indicates where, in the Tx chain, samples are gated. The default option, output gating, means that samples are processed through the UHD and VITA packet handler, and interpolated. After interpolation, if the trigger is not active, the interpolated samples are discarded, and zero valued samples are sent to the DAC. This ensures that VITA sample count and headers may be used to ensure phase coherency.

When using dsp gating, the UHD sample count is paused, and samples discarded prior to the dsp. This provides a mechanism to queue up a number of samples in the buffer, and entirely control the timing and transmission of those samples through an external trigger. NB: Continuous operation in this mode would likely require end users to override the default flow control handler. For phase coherent operation, users must also ensure phase coherency. In most cases, it makes a lot more sense for Cyan/Crimson TNG to be responsible for phase coherency and clocking requirements.

ufl_mode

Deprecated

Old path state/{rx,tx}/{a,b,c,d}/trigger/ufl_mode
New option Trigger sensitivity mode
Legal Values edge, level
Default Value level
Description Trigger mode associated with U.Fl channel trigger ports.

NonstandardOption The default (Cyan/Crimson TNG) unit does not expose per channel triggers; please contact us for more information on this optional hardware upgrade.

Additional Information This specifies whether the U.Fl per channel triggers should be edge or level sensitive, and operates identically to the sma_mode property, except that trigger behaviour is specific and exclusive to the specified radio channel.

ufl_dir

Deprecated

Old path state/{rx,tx}/{a,b,c,d}/trigger/ufl_dir
New option Electrical pin direction
Legal Values in, out
Default Value out
Description Specifies direction of Per Channel U.Fl Trigger port, with respect to the FPGA.

NonstandardOption The default (Cyan/Crimson TNG) unit does not expose per channel triggers; please contact us for more information on this optional hardware upgrade.

Additional Information This property works similarly to the sma_dir property, except it is channel specific. To export a trigger, for example, to indicate you are transmitting samples, specify the direction as output - with (Cyan/Crimson TNG) effectively generating a trigger on the specified event. To receive a trigger, such as when you want to specify the initial receipt of samples, set this direction to input. Unlike the Global SMA trigger, the behaviour of this trigger is exclusive to its associated radio channel.

ufl_pol

Deprecated

Old path state/{rx,tx}/{a,b,c,d}/trigger/ufl_pol
New option Polarity
Legal Values positive, negative
Default Value positive
Description Per Channel U.Fl trigger assertion state as VCC (positive) or GND (negative)

NonstandardOption The default (Cyan/Crimson TNG) unit does not expose per channel triggers; please contact us for more information on this optional hardware upgrade.

Additional Information This indicates what voltage level constitutes a logically high trigger. If the value is “positive”, then the untriggered state shall be specified with GND at the SMA, and the triggered state by VCC (active high). If the value is “negative”, then the trigger shall be reversed (active low).

NOTE: The trigger input has a fixed, weak, pull-up. The polarity is set using FPGA logic. This means that you must actively sink the trigger input to GND for proper operation during blanking periods; a floating or unconnected source will not work effectively.

Warning

Laboratory Use Only EXCEEDING SPECIFIED IO LEVELS MAY RESULT IN DAMAGE OR INJURY The trigger is directly connected to the FPGA; violating the specified voltage range may result in damage or injury.

Trigger Configuration

Deprecated

New programs should use multi_usrp::trigger_configure from UHD (see Examples).

Deprecated methods (below) of configuring the trigger are:

Website

Deprecated

The universal global trigger properties (direction and polarity) may be configured from the configuration page through the website. Radio chain specific behaviour may be configured from the channel web page, under the Trigger Settings header.

SSH

Deprecated

You can directly set the trigger behaviour through the Cyan/Crimson TNG state tree. The state tree is located in /var/crimson/state. The relative path to each of the properties is specified above.

UHD

Deprecated

This section is for the deprecated method of using UHD to write to the state tree. For the new API, see Examples.

You may also get and set selected properties through UHD. Example code demonstrating this functionality is available in the UHD repository. In this mode, you can configure various paths, including trigger settings.