Pulsewidthqualifier not working (Python + 2204A)

Discussion forum for the Picoscope 6 Linux software
Post Reply
evanamelrooij
User
User
Posts: 2
Joined: Tue Jan 12, 2021 1:18 pm

Pulsewidthqualifier not working (Python + 2204A)

Post by evanamelrooij »

Hi,

I am working on a trigger on a pulse width using a RPi4, the python wrappers and a picoscope 2204A I have managed to get the drivers working and had to add some stuff to the original ps2000.py because it was simply missing... (see this earlier post ).

Everything works except the PWQ. Changing the lowerlimit of the PWQ from 0 to several thousands does not have any effect. I have read somewhere that it is not possible to use the PS2000_THRESHOLD_DIRECTION_RISING for both the PWQ and the trigger channel direction, however, I don't see the other option called RISING_LOWER which I actually need. On the other hand, the code I am using now does not raise any errors so the PWQ must be set succesfully.

So the first part of the code up until the PWQ looks like this:

Code: Select all


Any help would be very appreciated

# Create status ready for use
status = {}
# Open 2000 series PicoScope
# Returns handle to chandle for use in future API functions
status["openUnit"] = ps.ps2000_open_unit()
assert_pico2000_ok(status["openUnit"])

# Create chandle for use
chandle = ctypes.c_int16(status["openUnit"])

# Set up channel A
chARange = 2
status["setChA"] = ps.ps2000_set_channel(chandle, 0, 1, 0, chARange)
assert_pico2000_ok(status["setChA"])

status["setChB"] = ps.ps2000_set_channel(chandle, 1, 0, 0, chARange)
assert_pico2000_ok(status["setChB"])

#Set advanced trigger channel conditions
triggerConditions = ps.PS2000_TRIGGER_CONDITIONS(1,0,0,0,0,1) #only channel A and a pulse width qualifier
status["ps2000SetAdvTriggerChannelConditions"] = ps.ps2000SetAdvTriggerChannelConditions(chandle,ctypes.byref(triggerConditions), 1)
assert_pico2000_ok(status["ps2000SetAdvTriggerChannelConditions"])

# Pulse height trigger
thrMajor = 20 #mV
thrMajorBit = int(2**16 * (thrMajor)/100)
hysteresis = int(2.5 /100 * thrMajorBit )
thresholdMode = ps.PS2000_THRESHOLD_MODE["PS2000_LEVEL"]
triggerProperties = ps.PS2000_TRIGGER_CHANNEL_PROPERTIES(thrMajorBit,0,hysteresis,0,thresholdMode)

# Set advanced trigger channel properties
status["ps2000SetAdvTriggerChannelProperties"] = ps.ps2000SetAdvTriggerChannelProperties(chandle, ctypes.byref(triggerProperties),1, 0)
assert_pico2000_ok(status["ps2000SetAdvTriggerChannelProperties"])

# Set advanced trigger channel directions
triggerDirection = ps.PS2000_THRESHOLD_DIRECTION["PS2000_THRESHOLD_DIRECTION_RISING"]
status["ps2000SetAdvTriggerChannelDirections"] = ps.ps2000SetAdvTriggerChannelDirections(chandle,triggerDirection,0,0,0,0)
assert_pico2000_ok(status["ps2000SetAdvTriggerChannelDirections"])


#Set pulse width qualifier
pwqConditions = ps.tPS2000PwqConditions(1,0,0,0,0)
pwqDirections = ps.PS2000_THRESHOLD_DIRECTION["PS2000_THRESHOLD_DIRECTION_RISING"]
pwqProperties = ps.PS2000_PULSE_WIDTH_TYPE["PS2000_PW_TYPE_GREATER_THAN"]
PW_lowerlim = ctypes.c_uint32(20000)
PW_upperlim = ctypes.c_uint32(0)
status["setPulseWidthQualifier"] = ps.ps2000SetPulseWidthQualifier(chandle, ctypes.byref(pwqConditions), 1, pwqDirections, PW_lowerlim, PW_upperlim, pwqProperties)
assert_pico2000_ok(status["setPulseWidthQualifier"])
Any help would be very appreciated

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

Re: Pulsewidthqualifier not working (Python + 2204A)

Post by evanamelrooij »

It keeps changing the link in the post when I try to edit it but this is the other post: https://www.picotech.com/support/topic40520.html

Post Reply