Trigger#

The trigger module provides classes for defining trigger conditions that can be used with both hardware captures and synthetic triggers.

Overview#

This module defines the trigger settings that determine when a capture should start or how a capture should be split. It currently supports edge triggers, which detect when a signal crosses a specified voltage threshold.

Classes#

EdgeTriggerDirection#

An enumeration that defines the direction of an edge trigger:

class EdgeTriggerDirection(enum.Enum):
    RISING = "rising"   # Trigger when signal rises above threshold
    FALLING = "falling" # Trigger when signal falls below threshold

EdgeTrigger#

A dataclass that defines an edge trigger configuration:

@dataclass
class EdgeTrigger:
    channel_index: Optional[int] = None
    channel_name: Optional[str] = None
    threshold_volts: float = 0.0
    direction: EdgeTriggerDirection = EdgeTriggerDirection.RISING

Parameters:

  • channel_index: The channel number to trigger on (0-based index)

  • channel_name: The name of the channel to trigger on

  • threshold_volts: The voltage threshold that the signal must cross

  • direction: Whether to trigger on rising or falling edges

  • holdoff: Support coming soon!

Note: Either channel_index or channel_name must be provided, but not both. If both are provided, a warning will be logged.

Example Usage#

from saleae import mso_api


# Create a trigger for rising edges on channel 1 at 0V
trigger = mso_api.EdgeTrigger(
    channel_index=1,
    threshold_volts=0,
    direction=mso_api.EdgeTriggerDirection.RISING
)

Usage with Capture Configuration#

Edge triggers can also be used with the CaptureConfig class to configure hardware-triggered captures:

from saleae import mso_api


# Create a configuration for a triggered capture
config = mso_api.CaptureConfig(
    enabled_channels=[mso_api.AnalogChannel(channel=0, name="data")],
    analog_settings=mso_api.AnalogSettings(sample_rate=100e6),
    capture_settings=mso_api.AnalogTriggered(
        trigger=mso_api.EdgeTrigger(channel_name="data", threshold_volts=0),
        pre_trigger_seconds=0.0005,
        post_trigger_seconds=0.0005,
        timeout_seconds=1.0
    )
)