|
38 | 38 |
|
39 | 39 | # Set up channel A |
40 | 40 | # handle = chandle |
41 | | -channel = ps.PS5000A_CHANNEL["PS5000A_CHANNEL_A"] |
| 41 | +channelA = ps.PS5000A_CHANNEL["PS5000A_CHANNEL_A"] |
42 | 42 | # enabled = 1 |
43 | 43 | coupling_type = ps.PS5000A_COUPLING["PS5000A_DC"] |
44 | | -chARange = ps.PS5000A_RANGE["PS5000A_20V"] |
| 44 | +chARange = ps.PS5000A_RANGE["PS5000A_2V"] |
45 | 45 | # analogue offset = 0 V |
46 | | -status["setChA"] = ps.ps5000aSetChannel(chandle, channel, 1, coupling_type, chARange, 0) |
| 46 | +status["setChA"] = ps.ps5000aSetChannel(chandle, channelA, 1, coupling_type, chARange, 0) |
47 | 47 | assert_pico_ok(status["setChA"]) |
48 | 48 |
|
49 | 49 | # Set up channel B |
50 | 50 | # handle = chandle |
51 | | -channel = ps.PS5000A_CHANNEL["PS5000A_CHANNEL_B"] |
| 51 | +channelB = ps.PS5000A_CHANNEL["PS5000A_CHANNEL_B"] |
52 | 52 | # enabled = 1 |
53 | 53 | # coupling_type = ps.PS5000A_COUPLING["PS5000A_DC"] |
54 | 54 | chBRange = ps.PS5000A_RANGE["PS5000A_2V"] |
55 | 55 | # analogue offset = 0 V |
56 | | -status["setChB"] = ps.ps5000aSetChannel(chandle, channel, 1, coupling_type, chBRange, 0) |
| 56 | +status["setChB"] = ps.ps5000aSetChannel(chandle, channelB, 1, coupling_type, chBRange, 0) |
57 | 57 | assert_pico_ok(status["setChB"]) |
58 | 58 |
|
59 | 59 | # find maximum ADC count value |
|
63 | 63 | status["maximumValue"] = ps.ps5000aMaximumValue(chandle, ctypes.byref(maxADC)) |
64 | 64 | assert_pico_ok(status["maximumValue"]) |
65 | 65 |
|
66 | | -# Set up single trigger |
67 | | -# handle = chandle |
68 | | -# enabled = 1 |
69 | | -source = ps.PS5000A_CHANNEL["PS5000A_CHANNEL_A"] |
70 | | -threshold = int(mV2adc(500,chARange, maxADC)) |
71 | | -# direction = PS5000A_RISING = 2 |
72 | | -# delay = 0 s |
73 | | -# auto Trigger = 1000 ms |
74 | | -status["trigger"] = ps.ps5000aSetSimpleTrigger(chandle, 1, source, threshold, 2, 0, 1000) |
75 | | -assert_pico_ok(status["trigger"]) |
| 66 | +# Parameters |
| 67 | +chA=0 # channel A |
| 68 | +chB=1 # channel B |
| 69 | +maxADC = ctypes.c_int16(32767) |
| 70 | +NB=2 #NB=nConditions=nDirections=nChannelProperties |
| 71 | +rg=2000 # range of voltage in millivolt |
| 72 | +threshold=1000 |
| 73 | +thresholdLower=0 |
| 74 | +hyteresis=0 |
| 75 | +window=False |
| 76 | +direction=2 # Rising |
| 77 | + |
| 78 | +#CONDITIONS |
| 79 | +conditions = (ps.PS5000A_CONDITION * NB)() |
| 80 | +clear=0x00000001 |
| 81 | +add=0x00000002 |
| 82 | +cond_info=clear|add |
| 83 | +a = ps.PS5000A_TRIGGER_STATE["PS5000A_CONDITION_TRUE"] |
| 84 | +conditions[0]= ps.PS5000A_CONDITION(channelA, ps.PS5000A_TRIGGER_STATE["PS5000A_CONDITION_TRUE"]) |
| 85 | +conditions[1]= ps.PS5000A_CONDITION(channelB, ps.PS5000A_TRIGGER_STATE["PS5000A_CONDITION_TRUE"]) |
| 86 | +status["maximumValue_"] = ps.ps5000aMaximumValue(chandle, ctypes.byref(maxADC)) |
| 87 | +assert_pico_ok(status["maximumValue_"]) |
| 88 | +status["setTriggerChannelConditions_"] = ps.ps5000aSetTriggerChannelConditionsV2(chandle, |
| 89 | + ctypes.byref(conditions), |
| 90 | + NB, |
| 91 | + cond_info) |
| 92 | +assert_pico_ok(status["setTriggerChannelConditions_"]) |
| 93 | + |
| 94 | +# DIRECTIONS |
| 95 | +if window==True: |
| 96 | + th_mode=ps.PS5000A_THRESHOLD_MODE["PS5000A_WINDOW"] |
| 97 | +else: |
| 98 | + th_mode=ps.PS5000A_THRESHOLD_MODE["PS5000A_LEVEL"] |
| 99 | +triggerDirections=(ps.PS5000A_DIRECTION * NB)() |
| 100 | +triggerDirections[0] = ps.PS5000A_DIRECTION(chA, direction, th_mode) |
| 101 | +triggerDirections[1] = ps.PS5000A_DIRECTION(chB, direction, th_mode) |
| 102 | +status["setTriggerChannelDirections_"] = ps.ps5000aSetTriggerChannelDirectionsV2(chandle, ctypes.byref(triggerDirections), NB) |
| 103 | +assert_pico_ok(status["setTriggerChannelDirections_"]) |
| 104 | + |
| 105 | +# PROPERTIES |
| 106 | +thUpper = mV2adc(threshold, chARange, maxADC) |
| 107 | +thLower = mV2adc(thresholdLower, chARange, maxADC) |
| 108 | +hysteresis=0 |
| 109 | +triggerProperties = (ps.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2 * NB)() |
| 110 | +triggerProperties[0] = ps.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2(thUpper, |
| 111 | + hysteresis, |
| 112 | + thLower, |
| 113 | + hysteresis, |
| 114 | + 0) |
| 115 | +triggerProperties[1] = ps.PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2(thUpper, |
| 116 | + hysteresis, |
| 117 | + thLower, |
| 118 | + hysteresis, |
| 119 | + 1) |
| 120 | +status["setTriggerChannelProperties_"] = ps.ps5000aSetTriggerChannelPropertiesV2(chandle, ctypes.byref(triggerProperties), NB, 0) |
| 121 | +assert_pico_ok(status["setTriggerChannelProperties_"]) |
76 | 122 |
|
77 | 123 | # Set number of pre and post trigger samples to be collected |
78 | 124 | preTriggerSamples = 2500 |
|
0 commit comments