Skip to content

Fix set_trigger_channel_properties function (API break)#185

Open
jcafhe wants to merge 1 commit into
picotech:mainfrom
jcafhe:fix-trigger-props
Open

Fix set_trigger_channel_properties function (API break)#185
jcafhe wants to merge 1 commit into
picotech:mainfrom
jcafhe:fix-trigger-props

Conversation

@jcafhe

@jcafhe jcafhe commented Jul 3, 2026

Copy link
Copy Markdown

Hi,

I'm creating a pull request here because it seems the issue tracker isn't available for this repo. Please feel free to remove this PR if you think this is inapropriate.

Issue

We are actually working with a ps3417E and the recommended psopsa API. We need to trigger on a falling edge either on channel A or channel B. As described in the programmer's guide, we have called two times the set_trigger_channel_conditions() function (OR behaviour), then set_trigger_channel_directions() function, and finally the set_trigger_channel_properties() function.

Unfortunatly the latter is not alligned with the programmer's guide and only allows the user to configure the properties of a single channel. We tried to call this function twice - once for channel A and once for channel B - but it seems to just write/overwrite the same internal states. In fact, when calling any run_xxx function, an error is raised indicating that the conditions were set correctly but the properties were not.

Pseudo code example:

import pypicosdk as psdk
from pypicosdk.constants import (
    CHANNEL,
    TRIGGER_STATE,
    ACTION,
    THRESHOLD_DIRECTION,
    THRESHOLD_MODE,
)

# Picoscope PS3417E Initialisation
pico: psdk.psospa.psospa = psdk.psospa()
pico.open_unit()

# Enable channel A and B.
pico.set_channel(channel=CHANNEL.A)
pico.set_channel(channel=CHANNEL.B)

# Set trigger conditions.
# We want to trigger an acquisition either on A or B falling edge.
pico.set_trigger_channel_conditions(
    conditions=[(CHANNEL.A, TRIGGER_STATE.TRUE), (CHANNEL.B, TRIGGER_STATE.DONT_CARE)],
    action=ACTION.ADD,
) 
pico.set_trigger_channel_conditions(
    conditions=[(CHANNEL.A, TRIGGER_STATE.DONT_CARE), (CHANNEL.B, TRIGGER_STATE.TRUE)],
    action=ACTION.ADD,
) 

# Set trigger directions (falling edge).
pico.set_trigger_channel_directions(
    channel=[CHANNEL.A, CHANNEL.B],
    direction=[THRESHOLD_DIRECTION.FALLING,  THRESHOLD_DIRECTION.FALLING],
    threshold_mode=[THRESHOLD_MODE.LEVEL, THRESHOLD_MODE.LEVEL],
)

# Set trigger channel properties for channel A.
pico.set_trigger_channel_properties(
    threshold_upper=10000,
    hysteresis_upper=0,
    threshold_lower=0,
    hysteresis_lower=0,
    channel=CHANNEL.A,
    aux_output_enable=0,
    auto_trigger_us=0,
)

# Set trigger channel properties for channel B.
pico.set_trigger_channel_properties(
    threshold_upper=10000,
    hysteresis_upper=0,
    threshold_lower=0,
    hysteresis_lower=0,
    channel=CHANNEL.B,
    aux_output_enable=0,
    auto_trigger_us=0,
)

...

# Raise an error telling that the conditions were set but not the properties.
pico.run_simple_rapid_block_capture(...)

Proposal

The current pull request changes the function signature and allows the user to set properties for multiple channels in one call. Thus, the user is able to use conditions with multiple channels. The downside is that it breaks the current pyPicoSDK API.

Example:

# properties argument is a list of tuples containing:
# (threshold_upper, hysteresis_upper, threshold_lower, hysteresis_lower, CHANNEL)

pico.set_trigger_channel_properties(
    properties=[
        (10000, 0, 0, 0, CHANNEL.A),
        (10000, 0, 0, 0, CHANNEL.B),
    ],
    aux_output_enable=0,
    auto_trigger_us=0,
)

@JamesPicoTech JamesPicoTech added the bug Something isn't working label Jul 8, 2026
@JamesPicoTech

Copy link
Copy Markdown
Collaborator

Hi @jcafhe we'll look over this and get it approved/implemented this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants