PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
from ctypes import byref
from picosdk.ps2000a import ps2000a as ps, \
PS2000A_TRIGGER_CONDITIONS, PS2000A_TRIGGER_CHANNEL_PROPERTIES, \
PS2000A_TRIGGER_CHANNEL_PROPERTIES, PS2000A_PWQ_CONDITIONS
# Channel C ...
triggerConditions1 = PS2000A_TRIGGER_CONDITIONS(0, 0, 1, 0, 0, 0, 0, 0)
ps.ps2000aSetTriggerChannelConditions(chandle, byref(triggerConditions1), 2)
# ... or D.
triggerConditions2 = PS2000A_TRIGGER_CONDITIONS(0, 0, 0, 1, 0, 0, 0, 0)
ps.ps2000aSetTriggerChannelConditions(chandle, byref(triggerConditions2), 2)
upper_threshold_bits = int(2**16 * (upper_threshold) / 100)
hysteresis = int(2.5 / 100 * upper_threshold_bits)
threshold_mode = ps.PS2000A_THRESHOLD_MODE["PS2000A_LEVEL"]
triggerProperties1 = PS2000A_TRIGGER_CHANNEL_PROPERTIES(
upper_threshold_bits, hysteresis, 0, 0, ps.PS2000A_CHANNEL["PS2000A_CHANNEL_C"], threshold_mode
)
triggerProperties2 = PS2000A_TRIGGER_CHANNEL_PROPERTIES(
upper_threshold_bits, hysteresis, 0, 0, ps.PS2000A_CHANNEL["PS2000A_CHANNEL_D"], threshold_mode
)
ps.ps2000aSetTriggerChannelProperties(chandle, byref(triggerProperties1), 1, 0, 1000)
ps.ps2000aSetTriggerChannelProperties(chandle, byref(triggerProperties2), 1, 0, 1000)
triggerDirection1 = ps.PS2000A_THRESHOLD_DIRECTION["PS2000A_RISING"]
triggerDirection2 = ps.PS2000A_THRESHOLD_DIRECTION["PS2000A_RISING"]
ps.ps2000aSetTriggerChannelDirections(chandle, 0, 0, triggerDirection1, 0, 0, 0)
ps.ps2000aSetTriggerChannelDirections(chandle, 0, 0, 0, triggerDirection2, 0, 0)
Code: Select all
from picosdk.ps2000a import ps2000a as ps, PS2000A_TRIGGER_CONDITIONS, PS2000A_TRIGGER_CHANNEL_PROPERTIES, PS2000A_PWQ_CONDITIONS
# Channel A OR B Advanced Trigger with ps2000a
chandle = ctypes.c_int16()
# Trick is to duplicate conditions and property schemas
trigger_conditions_n = 2
Condition = PS2000A_TRIGGER_CONDITIONS * trigger_conditions_n
trigger_conditions = Condition(
PS2000A_TRIGGER_CONDITIONS(1, 0, 0, 0, 0, 0, 0, 0),
PS2000A_TRIGGER_CONDITIONS(0, 1, 0, 0, 0, 0, 0, 0)
)
ps.ps2000aSetTriggerChannelConditions(chandle, byref(trigger_conditions), trigger_conditions_n)
upper_threshold = 2000 # mV
upper_hysteresis = 2.5 # %
# I'm not using lower threshold and hysteresis...
threshold_bits = int(2**16 * upper_threshold / 100)
hysteresis = int(upper_hysteresis / 100 * threshold_bits)
threshold_mode = ps.PS2000A_THRESHOLD_MODE["PS2000A_LEVEL"]
trigger_properties_n = 2
Property = PS2000A_TRIGGER_CHANNEL_PROPERTIES * trigger_properties_n
trigger_properties = Property(
PS2000A_TRIGGER_CHANNEL_PROPERTIES(
threshold_bits, hysteresis, 0, 0, ps.PS2000A_CHANNEL["PS2000A_CHANNEL_A"], threshold_mode
),
PS2000A_TRIGGER_CHANNEL_PROPERTIES(
upper_threshold_bits, hysteresis, 0, 0, ps.PS2000A_CHANNEL["PS2000A_CHANNEL_B"], threshold_mode
)
)
auto_trigger_ms = 200
ps.ps2000aSetTriggerChannelProperties(chandle, byref(trigger_properties), trigger_properties_n, 0, auto_trigger_ms)
triggerDirection = ps.PS2000A_THRESHOLD_DIRECTION["PS2000A_RISING"]
# Trigger directions needs to be set separately.
ps.ps2000aSetTriggerChannelDirections(chandle, triggerDirection, 0, 0, 0, 0, 0)
ps.ps2000aSetTriggerChannelDirections(chandle, 0, triggerDirection, 0, 0, 0, 0)
Code: Select all
PS2000A_TRIGGER_CONDITIONS(1, 1, 0, 0, 0, 0, 0, 0),
Code: Select all
PS2000A_TRIGGER_CONDITIONS(1, 2, 0, 0, 0, 0, 0, 0),
PS2000A_TRIGGER_CONDITIONS(2, 1, 0, 0, 0, 0, 0, 0),