Last active
December 3, 2024 20:54
-
-
Save germanescobar/215bffc740a087837d9b0a5134e57a3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This works | |
status = ps5000a.ps5000aSetSimpleTrigger( | |
self.handle, # handle | |
ctypes.c_int16(1), # enable | |
ps5000a.PS5000A_CHANNEL['PS5000A_EXTERNAL'], | |
ctypes.c_int16(800), | |
ps5000a.PS5000A_THRESHOLD_DIRECTION[f'PS5000A_RISING'], | |
ctypes.c_uint32(0), | |
ctypes.c_int16(1000) | |
) | |
assert_pico_ok(status) | |
# THIS IS NOT WORKING, it will just capture anything like it was disabled | |
channel_external = ps5000a.PS5000A_CHANNEL['PS5000A_EXTERNAL'] | |
class TRIGGER_CONDITION(ctypes.Structure): | |
_fields_ = [ | |
("source", ctypes.c_int16), | |
("condition", ctypes.c_int16) | |
] | |
condition_external = TRIGGER_CONDITION(channel_external, ps5000a.PS5000A_TRIGGER_STATE['PS5000A_CONDITION_TRUE']) | |
conditions = (TRIGGER_CONDITION * 1)(condition_external) | |
status = ps5000a.ps5000aSetTriggerChannelConditionsV2( | |
self.handle, | |
ctypes.byref(conditions), | |
len(conditions), # nConditions | |
1, # clear | |
) | |
assert_pico_ok(status) | |
# Set up external trigger properties | |
trigger_external = ps5000a.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2( | |
13107, # thresholdUpper | |
0, # thresholdUpperHysteresis | |
0, # thresholdLower | |
0, # thresholdLowerHysteresis | |
channel_external, # channel - now using the specified source | |
) | |
triggers = (ps5000a.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2 * 1)(trigger_external) | |
status = ps5000a.ps5000aSetTriggerChannelPropertiesV2( | |
self.handle, | |
ctypes.byref(triggers), | |
len(triggers), # nProperties | |
0, # auxOutputEnable | |
) | |
assert_pico_ok(status) | |
# Set trigger direction | |
directions = { | |
'ABOVE': ps5000a.PS5000A_THRESHOLD_DIRECTION['PS5000A_ABOVE'], | |
'BELOW': ps5000a.PS5000A_THRESHOLD_DIRECTION['PS5000A_BELOW'], | |
'RISING': ps5000a.PS5000A_THRESHOLD_DIRECTION['PS5000A_RISING'], | |
'FALLING': ps5000a.PS5000A_THRESHOLD_DIRECTION['PS5000A_FALLING'] | |
} | |
class PS5000A_DIRECTION_V2(ctypes.Structure): | |
_fields_ = [ | |
("channel", ctypes.c_int32), | |
("direction", ctypes.c_int32) | |
] | |
direction_external = PS5000A_DIRECTION_V2(channel_external, directions['RISING']) | |
# Create array of direction structures | |
directions = (PS5000A_DIRECTION_V2 * 1)(direction_external) | |
status = ps5000a.ps5000aSetTriggerChannelDirectionsV2( | |
self.handle, | |
ctypes.byref(directions), | |
len(directions) # number of directions being set | |
) | |
assert_pico_ok(status) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment