|
137 | 137 |
|
138 | 138 | %% Set number of samples to be collected |
139 | 139 |
|
140 | | -numPreTriggerSamples = 10000; |
141 | | -numPostTriggerSamples = 90000; |
| 140 | +numPreTriggerSamples = 1000000; |
| 141 | +numPostTriggerSamples = 9000000; |
142 | 142 | totalSamples = numPreTriggerSamples + numPostTriggerSamples; |
143 | 143 |
|
144 | 144 | %% Create Buffers |
145 | 145 |
|
146 | | -pBufferA =libpointer('int16Ptr', zeros(totalSamples, 1, 'int16')); |
147 | | -pBufferB =libpointer('int16Ptr', zeros(totalSamples, 1, 'int16')); |
| 146 | +bufferAMax = zeros(totalSamples, 1, 'int16'); |
| 147 | +bufferBMax = zeros(totalSamples, 1, 'int16'); |
| 148 | +bufferAMin = zeros(totalSamples, 1, 'int16'); |
| 149 | +bufferBMin = zeros(totalSamples, 1, 'int16'); |
| 150 | +pBufferAMax =libpointer('int16Ptr', bufferAMax); |
| 151 | +pBufferBMax =libpointer('int16Ptr', bufferBMax); |
| 152 | +pBufferAMin =libpointer('int16Ptr', bufferAMin); |
| 153 | +pBufferBMin =libpointer('int16Ptr', bufferBMin); |
148 | 154 |
|
149 | 155 | dataType = ps6000aEnumInfo.enPicoDataType.PICO_INT16_T; |
150 | 156 | waveform = 0; |
151 | 157 | downSampleRatioMode = ps6000aEnumInfo.enPicoRatioMode.PICO_RATIO_MODE_AVERAGE; |
152 | | -action = bitor(ps6000aEnumInfo.enPicoAction.PICO_CLEAR_ALL, ps6000aEnumInfo.enPicoAction.PICO_ADD); |
| 158 | +actionA = bitor(ps6000aEnumInfo.enPicoAction.PICO_CLEAR_ALL, ps6000aEnumInfo.enPicoAction.PICO_ADD); |
| 159 | +actionB = ps6000aEnumInfo.enPicoAction.PICO_ADD; |
153 | 160 |
|
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); |
| 161 | +[status.setBufferA] = invoke(ps6000aDeviceObj, 'ps6000aSetDataBuffers', channelA, pBufferAMax, ... |
| 162 | + pBufferAMin, totalSamples, dataType, waveform, downSampleRatioMode, actionA); |
| 163 | +[status.setBufferB] = invoke(ps6000aDeviceObj, 'ps6000aSetDataBuffers', channelB, pBufferBMax, ... |
| 164 | + pBufferBMin, totalSamples, dataType, waveform, downSampleRatioMode, actionB); |
158 | 165 |
|
159 | 166 | %% Run Block Capture |
160 | 167 |
|
|
185 | 192 | [status.getValues] = invoke(ps6000aDeviceObj,'ps6000aGetValues', startIndex,... |
186 | 193 | pSamplesCollected, downSampleRatio, downSampleRatioMode, segmentIndex, pOverflow); |
187 | 194 |
|
| 195 | +samplesCollected = pSamplesCollected.Value; |
| 196 | + |
| 197 | +disp('Data Retrieved') |
| 198 | + |
| 199 | +%% Convert Data from ADC counts to mV |
| 200 | + |
| 201 | +bufferAMax = pBufferAMax.Value; |
| 202 | +bufferAMin = pBufferAMin.Value; |
| 203 | +bufferBMax = pBufferBMax.Value; |
| 204 | +bufferBMin = pBufferBMin.Value; |
| 205 | + |
| 206 | +pMinValue = libpointer('int16Ptr',0); |
| 207 | +pMaxValue = libpointer('int16Ptr',0); |
| 208 | + |
| 209 | +[status.getAdcLimits] = invoke(ps6000aDeviceObj, 'ps6000aGetAdcLimits', resolution, pMinValue, pMaxValue); |
| 210 | + |
| 211 | +minValue = pMinValue.Value; |
| 212 | +maxValue = pMaxValue.Value; |
| 213 | + |
| 214 | +voltageRange = 5000; %mV |
| 215 | + |
| 216 | +bufferAMax = adc2mv(bufferAMax,voltageRange,double(maxValue)); |
| 217 | +bufferBMax = adc2mv(bufferBMax,voltageRange,double(maxValue)); |
| 218 | + |
| 219 | +disp('Data converted to mV') |
| 220 | + |
| 221 | +%% Plot Collected Data |
| 222 | + |
| 223 | +maxTime = (double(samplesCollected) * timeInterval); |
| 224 | +time = linspace(0,maxTime,samplesCollected); |
| 225 | + |
| 226 | +figure(1) |
| 227 | +plot(time,bufferAMax); |
| 228 | +hold on |
| 229 | +plot(time,bufferBMax); |
| 230 | +ylabel('Voltage (mV)'); |
| 231 | +xlabel('Time (s)'); |
| 232 | +hold off |
| 233 | + |
188 | 234 | %% Disconnect scope |
189 | 235 |
|
190 | 236 | disconnect(ps6000aDeviceObj); |
|
0 commit comments