Skip to content

Commit 7e2111e

Browse files
author
neil.hamilton
committed
Add advanced trigger structures to ps5000a class in picosdk/ps5000a.py
1 parent 574e597 commit 7e2111e

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

picosdk/ps5000a.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,15 @@ class PS5000A_DIGITAL_CHANNEL_DIRECTIONS(Structure):
187187
_fields_ = [("channel", c_int32),
188188
("direction", c_int32)]
189189

190+
ps5000a.PS5000A_DIGITAL_CHANNEL_DIRECTIONS = PS5000A_DIGITAL_CHANNEL_DIRECTIONS
190191

191192
class PS5000A_DIRECTION(Structure):
192193
_pack_ = 1
193194
_fields_ = [("channel", c_int32),
194195
("direction", c_int32),
195196
("mode", c_int32)]
197+
198+
ps5000a.PS5000A_DIRECTION = PS5000A_DIRECTION
196199

197200

198201
class PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2(Structure):
@@ -202,12 +205,16 @@ class PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2(Structure):
202205
("thresholdLower", c_int16),
203206
("thresholdLowerHysteresis", c_uint16),
204207
("channel", c_int32)]
208+
209+
ps5000a.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2 = PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2
205210

206211

207212
class PS5000A_CONDITION (Structure):
208213
_pack_ = 1
209214
_fields_ = [("source", c_int32),
210215
("condition", c_int16)]
216+
217+
ps5000a.PS5000A_CONDITION PS5000A_CONDITION
211218

212219

213220

ps5000aExamples/ps5000aBlockAdvancedTriggerExample.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,28 @@
6565

6666
# Set up an advanced trigger
6767
adcTriggerLevel = mV2adc(500, chARange, maxADC)
68-
triggerProperties = PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2(adcTriggerLevel,
68+
69+
triggerProperties = ps.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2(adcTriggerLevel,
6970
10,
7071
0,
7172
10,
7273
ps.PS5000A_CHANNEL["PS5000A_CHANNEL_A"])
7374

74-
status["setTriggerChannelPropertiesV2"] = ps.ps5000aSetTriggerChannelPropertiesV2(chandle, triggerProperties, length(triggerProperties), 0)
75+
status["setTriggerChannelPropertiesV2"] = ps.ps5000aSetTriggerChannelPropertiesV2(chandle, ctypes.byref(triggerProperties), 1, 0)
7576

76-
triggerConditions = PS5000A_CONDITION(ps.PS5000A_CHANNEL["PS5000A_CHANNEL_A"],
77+
triggerConditions = ps.PS5000A_CONDITION(ps.PS5000A_CHANNEL["PS5000A_CHANNEL_A"],
7778
ps.PS5000A_TRIGGER_STATE["PS5000A_CONDITION_TRUE"])
7879

7980
clear = 1
8081
add = 2
8182

82-
status["setTriggerChannelConditionsV2"] = ps.ps5000aSetTriggerChannelConditionsV2(chandle, triggerConditions, length(triggerConditions), (clear + add))
83+
status["setTriggerChannelConditionsV2"] = ps.ps5000aSetTriggerChannelConditionsV2(chandle, ctypes.byref(triggerConditions), 1, (clear + add))
8384

84-
triggerDirections = PS5000A_DIRECTION(ps.PS5000A_CHANNEL["PS5000A_CHANNEL_A"], ps.PS5000A_THRESHOLD_DIRECTION["PS5000A_RISING"], ps.PS5000A_THRESHOLD_MODE["PS5000A_LEVEL"])
85+
triggerDirections = ps.PS5000A_DIRECTION(ps.PS5000A_CHANNEL["PS5000A_CHANNEL_A"],
86+
ps.PS5000A_THRESHOLD_DIRECTION["PS5000A_RISING"],
87+
ps.PS5000A_THRESHOLD_MODE["PS5000A_LEVEL"])
8588

86-
status["setTriggerChannelDirections"] = ps5000aSetTriggerChannelDirectionsV2(chandle, triggerDirections, length(triggerDirections))
89+
status["setTriggerChannelDirections"] = ps5000aSetTriggerChannelDirectionsV2(chandle, ctypes.byref(triggerDirections), 1)
8790

8891

8992
# Set number of pre and post trigger samples to be collected

0 commit comments

Comments
 (0)