|
10 | 10 | from picosdk.ps4000a import ps4000a as ps |
11 | 11 | import matplotlib.pyplot as plt |
12 | 12 | from picosdk.functions import adc2mV, assert_pico_ok, mV2adc |
| 13 | +from math import * |
13 | 14 |
|
14 | 15 | # Create chandle and status ready for use |
15 | 16 | chandle = ctypes.c_int16() |
|
56 | 57 |
|
57 | 58 | # Set up dropout trigger |
58 | 59 | # set trigger condtions for channel A and pulse width qualifier |
59 | | -conditions =[ps.PS4000A_CONDITION() for i in range (2)] |
60 | | -print(conditions) |
61 | | -conditions[0].source = ps.PS4000A_CHANNEL["PS4000A_CHANNEL_A"] |
62 | | -conditions[0].condition = ps.PS4000A_TRIGGER_STATE["PS4000A_TRUE"] |
63 | | -conditions[1].source = ps.PS4000A_CHANNEL["PS4000A_PULSE_WIDTH_SOURCE"] |
64 | | -conditions[1].condition = ps.PS4000A_TRIGGER_STATE["PS4000A_TRUE"] |
| 60 | +class RECT(ctypes.Structure): |
| 61 | + _fields_ = [("channelA",ps.PS4000A_CONDITION), |
| 62 | + ("pwq",ps.PS4000A_CONDITION)] |
| 63 | + |
| 64 | + #conditions =[ps.PS4000A_CONDITION() for i in range (2)] |
| 65 | + |
| 66 | +channelAConditions = ps.PS4000A_CONDITION(ps.PS4000A_CHANNEL["PS4000A_CHANNEL_A"],ps.PS4000A_TRIGGER_STATE["PS4000A_TRUE"]) |
| 67 | +#conditions.channelA.condition = ps.PS4000A_TRIGGER_STATE["PS4000A_TRUE"] |
| 68 | +pulseWidthConditions = ps.PS4000A_CONDITION(ps.PS4000A_CHANNEL["PS4000A_PULSE_WIDTH_SOURCE"],ps.PS4000A_TRIGGER_STATE["PS4000A_TRUE"]) |
| 69 | +#conditions.pwq.condition = ps.PS4000A_TRIGGER_STATE["PS4000A_TRUE"] |
| 70 | + |
| 71 | +conditions = RECT(channelAConditions,pulseWidthConditions) |
| 72 | + |
65 | 73 |
|
66 | 74 | nConditions = 2 |
67 | 75 | info = ps.PS4000A_CONDITIONS_INFO["PS4000A_ADD"] |
|
80 | 88 | maxADC = ctypes.c_int16(32767) |
81 | 89 |
|
82 | 90 | # set trigger properties for channel ADC |
83 | | -thresholdUpper = mV2adc(500, c, maxADC) |
84 | | -channelProperties = ps.PS4000A_TRIGGER_CHANNEL_PROPERTIES(thresholdUpper, (thresholdUpper * 0.05), (thresholdUpper * -1), (thresholdUpper * 0.05), ps.PS4000A_CHANNEL["PS4000A_CHANNEL_A"], ps.PS4000A_THRESHOLD_MODE["PS4000A_WINDOW"]) |
| 91 | +thresholdUpper = mV2adc(500, 7, maxADC) |
| 92 | +channelProperties = ps.PS4000A_TRIGGER_CHANNEL_PROPERTIES(thresholdUpper, floor(thresholdUpper * 0.05), (thresholdUpper * -1), floor(thresholdUpper * 0.05), ps.PS4000A_CHANNEL["PS4000A_CHANNEL_A"], ps.PS4000A_THRESHOLD_MODE["PS4000A_WINDOW"]) |
85 | 93 | nChannelProperties = 1 |
86 | 94 | autoTriggerms = 10000 |
87 | 95 | status["setTriggerChannelProperties"] = ps.ps4000aSetTriggerChannelProperties(chandle, ctypes.byref(channelProperties), nChannelProperties, 0, autoTriggerms) |
88 | 96 | assert_pico_ok(status["setTriggerChannelProperties"]) |
89 | 97 |
|
90 | 98 | # set pulse width qualifier conditions |
91 | | -pwqConditions = conditions[1] |
92 | 99 | pwqNConditions = 1 |
93 | | -status["setPulseWidthQualifierConditions"] = ps.ps4000aSetPulseWidthQualifierConditions(chandle, ctypes.byref(pwqConditions), pwqNConditions, info) |
| 100 | +status["setPulseWidthQualifierConditions"] = ps.ps4000aSetPulseWidthQualifierConditions(chandle, ctypes.byref(pulseWidthConditions), pwqNConditions, info) |
94 | 101 | assert_pico_ok(status["setPulseWidthQualifierConditions"]) |
95 | 102 |
|
96 | 103 | # set pulse width qualifier properties |
97 | | -direction = ps.PS4000A_DIRECTION[""] |
| 104 | +direction = ps.PS4000A_THRESHOLD_DIRECTION["PS4000A_ENTER"] |
98 | 105 | lower = 15 |
99 | 106 | upper = 100 |
100 | 107 | type = ps.PS4000A_PULSE_WIDTH_TYPE["PW_TYPE_IN_RANGE"] |
|
0 commit comments