|
74 | 74 |
|
75 | 75 | connect(ps6000aDeviceObj) |
76 | 76 |
|
| 77 | +%% Set Device Resolution |
| 78 | + |
| 79 | +resolution = ps6000aEnumInfo.enPicoDeviceResolution.PICO_DR_10BIT; |
| 80 | + |
| 81 | +[status.setResolution] = invoke(ps6000aDeviceObj, 'ps6000aSetDeviceResolution', resolution); |
| 82 | + |
| 83 | +disp('Device Resolution set to 10 bits') |
| 84 | + |
| 85 | +%% Enable Channel A + B |
| 86 | +% Enable channels A + B with +-5 V range with DC coupling and full bandwidth |
| 87 | + |
| 88 | +channelA = ps6000aEnumInfo.enPicoChannel.PICO_CHANNEL_A; |
| 89 | +channelB = ps6000aEnumInfo.enPicoChannel.PICO_CHANNEL_B; |
| 90 | +couplingDC = ps6000aEnumInfo.enPicoCoupling.PICO_DC; |
| 91 | +range = ps6000aEnumInfo.enPicoConnectProbeRange.PICO_X1_PROBE_5V; |
| 92 | +bandwidth = ps6000aEnumInfo.enPicoBandwidthLimiter.PICO_BW_FULL; |
| 93 | + |
| 94 | + |
| 95 | +[status.setChannelOn.A] = invoke(ps6000aDeviceObj, 'ps6000aSetChannelOn', channelA, couplingDC, range, 0, bandwidth); |
| 96 | +[status.setChannelOn.B] = invoke(ps6000aDeviceObj, 'ps6000aSetChannelOn', channelB, couplingDC, range, 0, bandwidth); |
| 97 | + |
| 98 | +disp('Channels A and B set') |
| 99 | + |
| 100 | +% Disable all other channels |
| 101 | +for i = (2:7) |
| 102 | + try |
| 103 | + [status.setChannelOff] = invoke(ps6000aDeviceObj, 'ps6000aSetChannelOff', i); |
| 104 | + catch |
| 105 | + |
| 106 | + end |
| 107 | +end |
| 108 | + |
| 109 | +disp('Remaining Channels disabled') |
| 110 | + |
| 111 | +%% Set Simple Trigger |
| 112 | + |
| 113 | +enable = 1; |
| 114 | +source = channelA; |
| 115 | +threshold = 1000; %mV |
| 116 | +direction = ps6000aEnumInfo.enPicoThresholdDirection.PICO_RISING; |
| 117 | +delay = 0; |
| 118 | +autoTriggerMicroSeconds = 1000000; %us |
| 119 | + |
| 120 | +[status.setSimpleTrigger] = invoke(ps6000aDeviceObj, 'ps6000aSetSimpleTrigger', enable, source, threshold, direction,... |
| 121 | + delay, autoTriggerMicroSeconds); |
| 122 | + |
| 123 | +disp('Simple Trigger set') |
| 124 | + |
| 125 | + |
| 126 | +%% Get Fastest Timebase |
| 127 | + |
| 128 | +enabledChannelFlags= ps6000aEnumInfo.enPicoChannelFlags.PICO_CHANNEL_A_FLAGS + ps6000aEnumInfo.enPicoChannelFlags.PICO_CHANNEL_B_FLAGS; |
| 129 | +pTimebase = libpointer('uint32Ptr',0); |
| 130 | +pTimeInterval = libpointer('doublePtr',0); |
| 131 | + |
| 132 | +[status.getMinimumTimebaseStateless] = invoke(ps6000aDeviceObj, 'ps6000aGetMinimumTimebaseStateless', enabledChannelFlags,... |
| 133 | + pTimebase, pTimeInterval, resolution); |
| 134 | + |
| 135 | +timebase = pTimebase.Value; |
| 136 | +timeInterval = pTimeInterval.Value; |
| 137 | + |
| 138 | +%% Set number of samples to be collected |
| 139 | + |
| 140 | +numPreTriggerSamples = 10000; |
| 141 | +numPostTriggerSamples = 90000; |
| 142 | +totalSamples = numPreTriggerSamples + numPostTriggerSamples; |
| 143 | + |
| 144 | +%% Create Buffers |
| 145 | + |
| 146 | +pBufferA =libpointer('int16Ptr', zeros(totalSamples, 1, 'int16')); |
| 147 | +pBufferB =libpointer('int16Ptr', zeros(totalSamples, 1, 'int16')); |
| 148 | + |
| 149 | +dataType = ps6000aEnumInfo.enPicoDataType.PICO_INT16_T; |
| 150 | +waveform = 0; |
| 151 | +downSampleRatioMode = ps6000aEnumInfo.enPicoRatioMode.PICO_RATIO_MODE_AVERAGE; |
| 152 | +action = bitor(ps6000aEnumInfo.enPicoAction.PICO_CLEAR_ALL, ps6000aEnumInfo.enPicoAction.PICO_ADD); |
| 153 | + |
| 154 | +[status.setBufferA] = invoke(ps6000aDeviceObj, 'ps6000aSetDataBuffer', channelA, pBufferA, ... |
| 155 | + totalSamples, dataType, waveform, downSampleRatioMode, action); |
| 156 | +[status.setBufferB] = invoke(ps6000aDeviceObj, 'ps6000aSetDataBuffer', channelB, pBufferB, ... |
| 157 | + totalSamples, dataType, waveform, downSampleRatioMode, action); |
| 158 | + |
| 159 | +%% Run Block Capture |
| 160 | + |
| 161 | +pTimeIndisposedMs = libpointer('doublePtr',0); |
| 162 | +segmentIndex = 0; |
| 163 | + |
| 164 | +disp('Collection starting...') |
| 165 | + |
| 166 | +[status.runBlock] = invoke(ps6000aDeviceObj, 'ps6000aRunBlock', numPreTriggerSamples, numPostTriggerSamples,... |
| 167 | + timebase, pTimeIndisposedMs, segmentIndex); |
| 168 | + |
| 169 | +pReady = libpointer('int16Ptr',0); |
| 170 | + |
| 171 | +while pReady.Value == 0 |
| 172 | + [status.IsReady] = invoke(ps6000aDeviceObj,'ps6000aIsReady',pReady); |
| 173 | +end |
| 174 | + |
| 175 | +disp('Collection finished') |
| 176 | + |
| 177 | +%% Retrieve Data |
| 178 | + |
| 179 | +startIndex = 0; |
| 180 | +pSamplesCollected = libpointer('uint64Ptr',totalSamples); |
| 181 | +downSampleRatio = 1; |
| 182 | +segmentIndex = 0; |
| 183 | +pOverflow = libpointer('int16Ptr',0); |
| 184 | + |
| 185 | +[status.getValues] = invoke(ps6000aDeviceObj,'ps6000aGetValues', startIndex,... |
| 186 | + pSamplesCollected, downSampleRatio, downSampleRatioMode, segmentIndex, pOverflow); |
| 187 | + |
77 | 188 | %% Disconnect scope |
78 | 189 |
|
79 | 190 | disconnect(ps6000aDeviceObj); |
|
0 commit comments