ps2204a API trigger conditions

Having problems ? let us know the details here
Post Reply
chubby23280
User
User
Posts: 4
Joined: Wed Apr 22, 2020 11:06 am

ps2204a API trigger conditions

Post by chubby23280 »

Hi,

I've been trying to set up an advanced trigger on the picoscope 2204a using the python sdk. When writing a modified version of your block capture example program I have set the PS2000_TRIGGER_CONDITIONS, PS2000_TRIGGER_CHANNEL_PROPERTIES, and the PS2000_PWQ_CONDITIONS structures as mentioned in the 2000 series programming guide. Unfortunately when running the program I get the following error:

'Ps2000lib' object has no attribute 'PS2000_TRIGGER_CONDITIONS'

I checked the ps2000.py file and these structures have not been declared there like they are in the ps2000a.py file. Is there an alternative file I need to include or does this file need to be modified?

Kevin

chubby23280
User
User
Posts: 4
Joined: Wed Apr 22, 2020 11:06 am

Re: ps2204a API trigger conditions

Post by chubby23280 »

I had a look at the ps2000a.py and ps6000.py files and I pieced together what seems to be missing. I'm quite new to python so it may not be perfect but this seems to be missing from the ps2000.py file:

class PS2000_TRIGGER_CONDITIONS(Structure):
_pack_ = 1
_fields_ = [("channelA", c_int32),
("channelB", c_int32),
("channelC", c_int32),
("channelD", c_int32),
("external", c_int32),
("pulseWidthQualifier", c_int32)]

ps2000.PS2000_TRIGGER_CONDITIONS = PS2000_TRIGGER_CONDITIONS

ps2000.PS2000_TRIGGER_STATE = make_enum([
"PS2000_CONDITION_DONT_CARE",
"PS2000_CONDITION_TRUE",
"PS2000_CONDITION_FALSE"
])

class PS2000_TRIGGER_CHANNEL_PROPERTIES(Structure):
_pack_ = 1
_fields_ = [("thresholdUpper", c_int16),
("thresholdHysteresis", c_uint16),
("thresholdLower", c_int16),
("thresholdLowerHysteresis", c_uint16),
("channel", c_int32),
("thresholdMode", c_int32)]

ps2000.PS2000_TRIGGER_CHANNEL_PROPERTIES = PS2000_TRIGGER_CHANNEL_PROPERTIES

ps2000.PS2000_THRESHOLD_MODE = make_enum([
"PS2000_LEVEL",
"PS2000_WINDOW",
])

ps2000.PS2000_THRESHOLD_DIRECTION = make_enum([
"PS2000_THRESHOLD_DIRECTION_ABOVE",
"PS2000_THRESHOLD_DIRECTION_BELOW",
"PS2000_THRESHOLD_DIRECTION_RISING",
"PS2000_THRESHOLD_DIRECTION_FALLING",
"PS2000_THRESHOLD_DIRECTION_RISING_OR_FALLING",
"PS2000_THRESHOLD_DIRECTION_INSIDE",
"PS2000_THRESHOLD_DIRECTION_OUTSIDE",
"PS2000_THRESHOLD_DIRECTION_ENTER",
"PS2000_THRESHOLD_DIRECTION_EXIT",
"PS2000_THRESHOLD_DIRECTION_ENTER_OR_EXIT",
"PS2000_HRESHOLD_DIRECTION_NONE",
])

def _define_threshold_direction():
ps2000_above = 0
ps2000_below = 1
ps2000_rising = 2
ps2000_falling = 3
ps2000_rising_or_falling = 4
ps2000_inside = ps2000_above
ps2000_outside = ps2000_below
ps2000_enter = ps2000_rising
ps2000_exit = ps2000_falling
ps2000_enter_or_exit = ps2000_rising_or_falling
ps2000_none = ps2000_rising

return {k.upper(): v for k, v in locals().items() if k.startswith("ps2000")}

ps2000.PS2000_THRESHOLD_DIRECTION = _define_threshold_direction()

ps2000.PICO_THRESHOLD_DIRECTION = {
k[8:]: v for k, v in ps2000.PS2000_THRESHOLD_DIRECTION.items()
}

class tPS2000PwqConditions(Structure):
_pack_ = 1
_fields_ = [("channelA", c_int32),
("channelB", c_int32),
("channelC", c_int32),
("channelD", c_int32),
("external", c_int32)]

ps2000.tPS2000PwqConditions = tPS2000PwqConditions

ps2000.PS2000_PULSE_WIDTH_TYPE = make_enum([
"PS2000_PW_TYPE_NONE",
"PS2000_PW_TYPE_LESS_THAN",
"PS2000_PW_TYPE_GREATER_THAN",
"PS2000_PW_TYPE_IN_RANGE",
"PS2000_PW_TYPE_OUT_OF_RANGE"
])

Hope its helpful
Kevin

evanamelrooij
User
User
Posts: 2
Joined: Tue Jan 12, 2021 1:18 pm

Re: ps2204a API trigger conditions

Post by evanamelrooij »

Very helpful, been struggling with this for a while now. Thanks Kevin!

evanamelrooij
User
User
Posts: 2
Joined: Tue Jan 12, 2021 1:18 pm

Re: ps2204a API trigger conditions

Post by evanamelrooij »

If you have time, could you post your code as an example?

Post Reply