|
103 | 103 |
|
104 | 104 | streamTrigger = structs.PICO_STREAMING_DATA_TRIGGER_INFO(0, 0, 0) |
105 | 105 |
|
106 | | -count = 1 |
107 | | - |
108 | | - |
| 106 | +count = 0 |
109 | 107 |
|
110 | 108 | picoOk = PICO_STATUS["PICO_OK"] |
111 | 109 |
|
112 | | -while count <= maxBuffers: |
| 110 | +collectedSamples = 0 |
| 111 | + |
| 112 | +while collectedSamples < (maxBuffers*nSamples): |
113 | 113 |
|
114 | 114 | status["getStreamingLatestValues"] = ps.ps6000aGetStreamingLatestValues(chandle, ctypes.byref(streamData), 1, |
115 | 115 | ctypes.byref(streamTrigger)) |
|
119 | 119 | time.sleep(0.01) |
120 | 120 | else: |
121 | 121 | count = count + 1 |
122 | | - if count <= maxBuffers: |
123 | | - status["setDataBufferA"] = ps.ps6000aSetDataBuffer(chandle, channelA, ctypes.byref(bufferA[count - 1]), |
| 122 | + if count < maxBuffers: |
| 123 | + status["setDataBufferA"] = ps.ps6000aSetDataBuffer(chandle, channelA, ctypes.byref(bufferA[count]), |
124 | 124 | nSamples, dataType, waveform, downSampleMode, actionAdd) |
125 | 125 | assert_pico_ok(status["setDataBufferA"]) |
126 | | - status["setDataBufferB"] = ps.ps6000aSetDataBuffer(chandle, channelB, ctypes.byref(bufferB[count - 1]), |
| 126 | + status["setDataBufferB"] = ps.ps6000aSetDataBuffer(chandle, channelB, ctypes.byref(bufferB[count]), |
127 | 127 | nSamples, dataType, waveform, downSampleMode, actionAdd) |
128 | 128 | assert_pico_ok(status["setDataBufferB"]) |
129 | 129 | print(count) |
130 | | -ps.ps6000aStop(chandle) |
| 130 | + |
| 131 | + collectedSamples = collectedSamples + streamData[0].noOfSamples |
| 132 | + |
| 133 | +# stop scope streaming |
| 134 | +status["stop"] = ps.ps6000aStop(chandle) |
| 135 | +assert_pico_ok(status["stop"]) |
| 136 | + |
| 137 | +# get total number of streamed data points |
131 | 138 | noOfStreamedSamples=ctypes.c_uint64() |
132 | | -ps.ps6000aNoOfStreamingValues(chandle,ctypes.byref(noOfStreamedSamples)) |
| 139 | +status["noOfStreamedSamples"] = ps.ps6000aNoOfStreamingValues(chandle, ctypes.byref(noOfStreamedSamples)) |
| 140 | +assert_pico_ok(status["noOfStreamedSamples"]) |
| 141 | + |
133 | 142 | print("streaming finished") |
| 143 | +print("Number of samples collected during streaming") |
134 | 144 | print(noOfStreamedSamples.value) |
135 | 145 |
|
136 | 146 |
|
|
141 | 151 | status["getAdcLimits"] = ps.ps6000aGetAdcLimits(chandle, resolution, ctypes.byref(minADC), ctypes.byref(maxADC)) |
142 | 152 | assert_pico_ok(status["getAdcLimits"]) |
143 | 153 |
|
144 | | -# convert ADC counts data to mV |
145 | | -plt.plot(bufferA[5]) |
146 | | -plt.plot(bufferB[9]) |
| 154 | +# plot ADC data |
| 155 | +plt.plot(bufferA[0]) |
| 156 | +plt.plot(bufferB[0]) |
147 | 157 | plt.show() |
148 | | -# bufferAmV = ((ctypes.c_int16 * nSamples) * 10)() |
149 | | -# bufferBmV = ((ctypes.c_int16 * nSamples) * 10)() |
150 | | -# for j in range(0, 9): |
151 | | - # A = bufferA[j] |
152 | | - # bufferAmV[j] = adc2mV(A, channelRange, maxADC) |
153 | | - # B = bufferB[j] |
154 | | - # bufferBmV[j] = adc2mV(B, channelRange, maxADC) |
| 158 | + |
155 | 159 |
|
156 | 160 | # Close the scope |
157 | 161 | status["closeunit"] = ps.ps6000aCloseUnit(chandle) |
|
0 commit comments