Logical AND trigger between two channels on ps5000 series

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

Logical AND trigger between two channels on ps5000 series

Post by soniya_ »

Dear Sir/Madam,

I am trying to configure ps5000aBlockAdvancedTriggerExample.py to enable a LOGICAL AND trigger between Channels A and B, but I am experiencing issues. The aim is to record coincidences between the negative pulses on Channel A and the positive pulses on Channel B that pass certain thresholds. I am using the following functions:
ps5000aSetTriggerChannelConditionsV2()
ps5000aSetTriggerChannelPropertiesV2()
ps5000aSetTriggerChannelDirectionsV2()

So far, I have successfully enabled a LOGICAL OR trigger between these channels as shown in my code snippet below:
adcTriggerLevelA = mV2adc(PS_TRIGGER_THRESHOLD["A"], chARange, maxADC)
adcTriggerLevelB = mV2adc(PS_TRIGGER_THRESHOLD["B"], chBRange, maxADC)

Property = ps.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2*2
triggerProperties = Property(ps.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2(adcTriggerLevelA,
0,
0,
0,
ps.PS5000A_CHANNEL["PS5000A_CHANNEL_A"]),
ps.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2(adcTriggerLevelB,
0,
0,
0,
ps.PS5000A_CHANNEL["PS5000A_CHANNEL_B"]))

status["setTriggerChannelPropertiesV2"] = ps.ps5000aSetTriggerChannelPropertiesV2(chandle, ctypes.byref(triggerProperties), 2, 0)

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"])

Conditions = ps.PS5000A_CONDITION*2
triggerConditions = Conditions(triggerConditionsA, triggerConditionsB)
clear = 1
add = 2

status["setTriggerChannelConditionsV2_A"] = ps.ps5000aSetTriggerChannelConditionsV2(chandle, ctypes.byref(triggerConditions), 1, (clear + add))
#status["setTriggerChannelConditionsV2_B"] = ps.ps5000aSetTriggerChannelConditionsV2(chandle, ctypes.byref(triggerConditionsB), 1, add)
assert_pico_ok(status["setTriggerChannelConditionsV2_A"])

Direction = ps.PS5000A_DIRECTION*2
triggerDirections = Direction(ps.PS5000A_DIRECTION(ps.PS5000A_CHANNEL["PS5000A_CHANNEL_A"],
ps.PS5000A_THRESHOLD_DIRECTION["PS5000A_BELOW"],
ps.PS5000A_THRESHOLD_MODE["PS5000A_LEVEL"]),
ps.PS5000A_DIRECTION(ps.PS5000A_CHANNEL["PS5000A_CHANNEL_B"],
ps.PS5000A_THRESHOLD_DIRECTION["PS5000A_ABOVE"],
ps.PS5000A_THRESHOLD_MODE["PS5000A_LEVEL"]))

status["setTriggerChannelDirections"] = ps.ps5000aSetTriggerChannelDirectionsV2(chandle, ctypes.byref(triggerDirections), 2)

I understand that to enable a logical AND multiple conditions must be passed as an array into one call of the ps5000aSetTriggerChannelConditionsV2() function. When I attempt to do this via the following:
Conditions = ps.PS5000A_CONDITION*2
triggerConditions = Conditions(triggerConditionsA, triggerConditionsB)
status["setTriggerChannelConditionsV2_A"] = ps.ps5000aSetTriggerChannelConditionsV2(chandle, ctypes.byref(triggerConditions), 1, (clear + add))

I get the following error message on the call of asset_pico_ok with the above status:
picosdk.errors.PicoSDKCtypesError: PicoSDK returned 'PICO_INVALID_TRIGGER_STATES'

Upon investigating, it seems that ps5000aSetTriggerChannelConditionsV2() doesn't accept multiple conditions on different channels to be passed as an argument into the function. For example, if I pass:
triggerConditions = Conditions(triggerConditionsA, triggerConditionsA)
The program runs.

Therefore, my first question is how do I enable a LOGICAL AND trigger using these functions?

After further investigation, I came across this old forum post: viewtopic.php?t=25821

Where your expert describes how to set this trigger logic but using older versions of the SetTriggerChannel functions. These are available in the ps5000.py library instead of the ps5000a.py library.
My second question is, do I have to use these older functions to implement this? If so, how do I use them as I don't understand the documentation and cannot find the appropriate examples online.

Thank you for taking the time out to assist me on this. Looking forward to hearing from you soon.

Post Reply