Advanced Trigger: Logical AND between 2 channels

Post general discussions on using our drivers to write your own software here
Post Reply
soniya_
Newbie
Posts: 0
Joined: Fri Sep 03, 2021 10:28 am

Advanced Trigger: Logical AND between 2 channels

Post by soniya_ »

I would like to acquire a block of data from two channels with an advanced trigger described with a Logical AND between the channels, using a PicoScope 5000 series oscilloscope. Channel A is a positive pulse and channel B is a negative pulse. I've been using the ps5000aBlockAdvancedTriggerExample.py as reference, where I have defined the trigger using the following functions:
ps5000aSetTriggerChannelPropertiesV2(),
ps5000aSetTriggerChannelDirectionsV2(),
ps5000aSetTriggerChannelConditionsV2()

I've combined the Properties and Directions for channel A and B into 2 arrays, which is passed into the first 2 functions specified above. But I am having an issue with the ps5000aSetTriggerChannelConditionsV2(). Since I want to ensure that the conditions on A and B are combined in a Logical AND I only call this function once, but I get the following error message at the assert_pico_ok function call:
File "C:\muon\picosdk-python-wrappers\ps5000-Scripts\DataAcquisition-Edit.py", line 109, in DataAcquisition
assert_pico_ok(status["setTriggerChannelConditions"])
File "C:\programdata\anaconda3\envs\mypython3\lib\site-packages\picosdk\functions.py", line 160, in assert_pico_ok
raise PicoSDKCtypesError("PicoSDK returned '{}'".format(PICO_STATUS_LOOKUP[status]))
picosdk.errors.PicoSDKCtypesError: PicoSDK returned 'PICO_INVALID_TRIGGER_STATES'

I've attached the relevant part of the code, I would very much appreciate any advice.
Attachments
DataAcquisition-Script.txt
(3.96 KiB) Downloaded 230 times

bennog
Advanced User
Advanced User
Posts: 100
Joined: Mon Nov 26, 2012 9:16 am
Location: Netherlands

Re: Advanced Trigger: Logical AND between 2 channels

Post by bennog »

do you have an example in picoscope software and can you post a .psdata of the triggered data.

Because edges never occur exactly at the same time.

Benno

soniya_
Newbie
Posts: 0
Joined: Fri Sep 03, 2021 10:28 am

Re: Advanced Trigger: Logical AND between 2 channels

Post by soniya_ »

I've attached the full script (CoincidenceTrigger.py) I'm running and a .psdata file that contains an example of the kind of waveforms I want to trigger. Channel A (blue) are negative pulses from a PMT and channel B (red) are positive pulses from a photodiode. To create the .psdata file, I used Picoscope 6 with the advanced trigger set to LOGICAL AND:
A threshold: Below, -50 mV
B threshold: Above, 20 mV

In my script, at present I've just turned on the conditions for channel B only (triggerConditionsB) as specified on line 91. If I comment line 91 and uncomment line 90, I get the error message I sent in my previous post.

I very much appreciate any help you can provide!
Attachments
CoincidenceTrigger.py
(9.78 KiB) Downloaded 242 times
20210906-0001.psdata
(8.83 KiB) Downloaded 261 times

Martyn
Site Admin
Site Admin
Posts: 4052
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Advanced Trigger: Logical AND between 2 channels

Post by Martyn »

The trigger conditions array will need PS5000A_CONDITION_DONT_CARE states for all the other channels

Code: Select all

typedef struct tPS5000ATriggerConditions
{
PS5000A_TRIGGER_STATE channelA;
PS5000A_TRIGGER_STATE channelB;
PS5000A_TRIGGER_STATE channelC;
PS5000A_TRIGGER_STATE channelD;
PS5000A_TRIGGER_STATE external;
PS5000A_TRIGGER_STATE aux;
PS5000A_TRIGGER_STATE pulseWidthQualifier;
} PS5000A_TRIGGER_CONDITIONS
Martyn
Technical Support Manager

soniya_
Newbie
Posts: 0
Joined: Fri Sep 03, 2021 10:28 am

Re: Advanced Trigger: Logical AND between 2 channels

Post by soniya_ »

Thanks for your response. I've set the PS5000A_CONDITION for all other channels with the PS5000A_CONDITION_DONT_CARE flag as per your suggestion, however I still get the same error. I've attached a modified version of the script that produces the error.

I noticed that the struct you have mentioned is an argument for the ps5000aSetTriggerChannelConditions() function. The function I am using is ps5000aSetTriggerChannelConditionsV2(), which (I think) doesn't include this particular struct. In the latter V2 function, the arguments calls for a PS5000A_CONDITION but for the former function the argument calls for a PS5000A_TRIGGER_CONDITIONS, which includes that struct you mentioned. But, perhaps there is something I am not understanding properly.

When I change:
s5000aSetTriggerChannelConditionsV2() to ps5000aSetTriggerChannelConditions() in line 100, the error message I get now changes to:

Traceback (most recent call last):
File "C:\muon\picosdk-python-wrappers\ps5000-Scripts\CoincidenceTrigger.py", line 102, in
assert_pico_ok(status["setTriggerChannelConditionsV2"])
File "C:\programdata\anaconda3\envs\mypython3\lib\site-packages\picosdk\functions.py", line 160, in assert_pico_ok
raise PicoSDKCtypesError("PicoSDK returned '{}'".format(PICO_STATUS_LOOKUP[status]))
picosdk.errors.PicoSDKCtypesError: PicoSDK returned 'PICO_CONDITIONS'

Apologies if this is simple, but how do I implement your suggestion using the tPS5000ATriggerConditions struct with ps5000aSetTriggerChannelConditionsV2() correctly?
Attachments
CoincidenceTrigger .py
(11.04 KiB) Downloaded 241 times

Martyn
Site Admin
Site Admin
Posts: 4052
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Advanced Trigger: Logical AND between 2 channels

Post by Martyn »

I haven't used the v2 function and I don't have a 5000D series device to test this on. Moving from PICO_INVALID_TRIGGER_STATES in your first post to PICO_CONDITIONS in this one is positive. So can you try just working with the analog channels

Code: Select all

triggerConditionsA = ps.PS5000A_CONDITION(ps.PS5000A_CHANNEL["PS5000A_CHANNEL_A"],
                                                           ps.PS5000A_TRIGGER_STATE["PS5000A_CONDITION_TRUE"])                   
triggerConditionsB = ps.PS5000A_CONDITION(ps.PS5000A_CHANNEL["PS5000A_CHANNEL_B"],
                                                           ps.PS5000A_TRIGGER_STATE["PS5000A_CONDITION_TRUE"])
triggerConditionsC = ps.PS5000A_CONDITION(ps.PS5000A_CHANNEL["PS5000A_CHANNEL_C"],
                                                           ps.PS5000A_TRIGGER_STATE["PS5000A_CONDITION_DONT_CARE"])
triggerConditionsD = ps.PS5000A_CONDITION(ps.PS5000A_CHANNEL["PS5000A_CHANNEL_D"],
                                                           ps.PS5000A_TRIGGER_STATE["PS5000A_CONDITION_DONT_CARE"])
                                                           
Conditions = ps.PS5000A_CONDITION*4
triggerConditions = Conditions(triggerConditionsA, triggerConditionsB, triggerConditionsC, triggerConditionsD)                                                         
clear = 1
add = 2
num_elems = 4
														   
status["setTriggerChannelConditionsV2"] = ps.ps5000aSetTriggerChannelConditionsV2(chandle, ctypes.byref(triggerConditions), num_elems, (clear + add))
Martyn
Technical Support Manager

soniya_
Newbie
Posts: 0
Joined: Fri Sep 03, 2021 10:28 am

Re: Advanced Trigger: Logical AND between 2 channels

Post by soniya_ »

Hi Martyn, I implemented the change you suggested however it still returns the PICO_INVALID_TRIGGER_STATES error message. Upon experimenting with this SetTriggerChannelsV2 function, if I pass a triggerConditions array, containing multiple conditions all on the same channel, the function runs. However, when the multiple conditions are all on different channels that's when the error message comes up. I chose to use the V2 functions as in the documentation (https://www.picotech.com/download/manua ... -guide.pdf) in Section 4.67 it specifies the following regarding ps5000aSetTriggerChannelConditions:

THIS FUNCTION IS NOT RECOMMENDED FOR NEW APPLICATIONS. In new applications please use ps5000aSetTriggerChannelConditionsV2 instead.

If I instead use the ps5000aSetTriggerChannelConditions, ps5000aSetTriggerChannelDirections and ps5000aSetTriggerChannelProperties (the none V2 functions), how do I do this?
The library I am using is located: https://github.com/picotech/picosdk-pyt ... ps5000a.py which (I think) doesn't contain these none-V2 functions. There is also a https://github.com/picotech/picosdk-pyt ... /ps5000.py library, that I think does contain the none-V2 functions. I import both in my CoincidenceTrigger.py script as:
from picosdk.ps5000a import ps5000a as ps
from picosdk.ps5000 import ps5000 as ps_old

But, I'm really only using the ps library, as all the examples do.
I couldn't find any examples using the none V2 functions that I think come from ps_old so I'm not sure how to implement this.

I understand you must have a very busy schedule, but I'd very much appreciate discussing this with you via zoom. Would it be possible to arrange a meeting over email?

soniya_
Newbie
Posts: 0
Joined: Fri Sep 03, 2021 10:28 am

Re: Advanced Trigger: Logical AND between 2 channels

Post by soniya_ »

Do you have any more thoughts/suggestions on this?

Martyn
Site Admin
Site Admin
Posts: 4052
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Advanced Trigger: Logical AND between 2 channels

Post by Martyn »

I am currently on leave, will be back on 20th and will pick up then.
Martyn
Technical Support Manager

Post Reply