Skip to content

Commit f5ba284

Browse files
author
neil.hamilton
committed
More work on ps6000aExamples/ps6000aStreamingModeExample.py
1 parent 60745d5 commit f5ba284

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

ps6000aExamples/ps6000aStreamingModeExample.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# This data is then plotted as mV against time in ns.
77

88
import ctypes
9-
import numpy as np
9+
# import numpy as np
1010
from picosdk.ps6000a import ps6000a as ps
1111
from picosdk.PicoDeviceEnums import picoEnum as enums
1212
from picosdk.PicoDeviceStructs import picoStruct as structs
@@ -40,8 +40,7 @@
4040
channel = x
4141
status["setChannel", x] = ps.ps6000aSetChannelOff(chandle, channel)
4242
assert_pico_ok(status["setChannel", x])
43-
44-
43+
4544
# Set number of samples to be collected
4645
noOfPreTriggerSamples = 100000
4746
noOfPostTriggerSamples = 900000
@@ -61,8 +60,7 @@
6160
# create buffers
6261
maxBuffers = 10
6362

64-
65-
bufferA = ((ctypes.c_int16 * nSamples)*10)()
63+
bufferA = ((ctypes.c_int16 * nSamples) * 10)()
6664

6765
print(bufferA)
6866
# Set data buffers
@@ -103,20 +101,20 @@
103101
picoOk = PICO_STATUS["PICO_OK"]
104102

105103
while count <= maxBuffers:
106-
104+
107105
status["getStreamingLatestValues"] = ps.ps6000aGetStreamingLatestValues(chandle, ctypes.byref(streamData), 1,
108106
ctypes.byref(streamTrigger))
109-
107+
110108
if status["getStreamingLatestValues"] == picoOk:
111109
# do nothing
112110
time.sleep(0.01)
113111
else:
114-
count = count+1
112+
count = count + 1
115113
if count <= maxBuffers:
116-
status["setDataBuffer"] = ps.ps6000aSetDataBuffer(chandle, channelA, ctypes.byref(bufferA[count-1]),
117-
nSamples, dataType, waveform, downSampleMode, actionB)
118-
assert_pico_ok(status["setDataBuffer"])
119-
print(count)
114+
status["setDataBuffer"] = ps.ps6000aSetDataBuffer(chandle, channelA, ctypes.byref(bufferA[count - 1]),
115+
nSamples, dataType, waveform, downSampleMode, actionB)
116+
assert_pico_ok(status["setDataBuffer"])
117+
print(count)
120118

121119
print("streaming finished")
122120

@@ -128,9 +126,10 @@
128126
assert_pico_ok(status["getAdcLimits"])
129127

130128
# convert ADC counts data to mV
131-
bufferAmV=((ctypes.c_int16 * nSamples)*10)()
129+
bufferAmV = ((ctypes.c_int16 * nSamples) * 10)()
132130
for j in range(0, 9):
133-
bufferAmV[j] = adc2mV(bufferA[j], channelRange, maxADC)
131+
A = bufferA[j]
132+
bufferAmV[j] = adc2mV(A, channelRange, maxADC)
134133

135134
# Close the scope
136135
status["closeunit"] = ps.ps6000aCloseUnit(chandle)

0 commit comments

Comments
 (0)