PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
chandle = ctypes.c_int16()
status = {}
powerStatus = 0
status["openunit"] = ps.ps4000aOpenUnit(ctypes.byref(chandle), None)
try:
assert_pico_ok(status["openunit"])
except: # PicoNotOkError:
powerStatus = status["openunit"]
if powerStatus == 286:
status["changePowerSource"] = ps.ps4000aChangePowerSource(chandle, powerStatus)
elif powerStatus == 282:
status["changePowerSource"] = ps.ps4000aChangePowerSource(chandle, powerStatus)
else:
pass
setCh = "setChA"
setDataBuffers = "setDataBuffersA"
chRange = 10
status[setCh] = ps.ps4000aSetChannel(chandle, 0, 1, 1, chRange, 0)
assert_pico_ok(status[setCh])
preTriggerSamples = 100
postTriggerSamples = 100
maxSamples = preTriggerSamples + postTriggerSamples
timebase = 3999
timeIntervalns = ctypes.c_float()
returnedMaxSamples = ctypes.c_int32()
oversample = ctypes.c_int16(1)
status["getTimebase2"]= ps.ps4000aGetTimebase2(chandle,timebase,maxSamples, ctypes.byref(timeIntervalns), ctypes.byref(returnedMaxSamples), 0)
assert_pico_ok(status["getTimebase2"])
status["runBlock"] = ps.ps4000aRunBlock(chandle, preTriggerSamples, postTriggerSamples, timebase, None, 0, None, None)
assert_pico_ok(status["runBlock"])
ready = ctypes.c_int16(0)
check = ctypes.c_int16(0)
while ready.value == check.value:
status["isReady"] = ps.ps4000aIsReady(chandle, ctypes.byref(ready))
bufferMax = (ctypes.c_int16 * maxSamples)()
bufferMin = (ctypes.c_int16 * maxSamples)()
status[setDataBuffers] = ps.ps4000aSetDataBuffers(chandle, 0, ctypes.byref(bufferMax), ctypes.byref(bufferMin), maxSamples, 0 , 0)
assert_pico_ok(status[setDataBuffers])
overflow = ctypes.c_int16()
cmaxSamples = ctypes.c_int32(maxSamples)
status["getValues"] = ps.ps4000aGetValues(chandle, 0, ctypes.byref(cmaxSamples), 0, 0, 0, ctypes.byref(overflow))
assert_pico_ok(status["getValues"])
maxADC = ctypes.c_int16(32767)
adc2mVChAMax = adc2mV(bufferMax, chRange, maxADC)
# Create time data
time = np.linspace(0, (cmaxSamples.value) * timeIntervalns.value, cmaxSamples.value)
# plot data from channel A
plt.plot(time, adc2mVChAMax[:])
plt.xlabel('Time (ns)')
plt.ylabel('Voltage (mV)')
plt_name = "CHA"
plt.title(plt_name)
plt.show()
status["stop"] = ps.ps4000aStop(chandle)
assert_pico_ok(status["stop"])
status["close"] = ps.ps4000aCloseUnit(chandle)
assert_pico_ok(status["close"])
Thanks for your description.Martyn wrote: ↑Wed Jun 07, 2023 9:24 amYou are correct a timebase of 3999 should give a sampling speed of 20000Samples/sec for a 4425A
I am not in the office and don't have that device to hand so can't check. I would suggest trying to set this up in PicoScope 7 and see what you get, the rule of thumb is that if it works in PicoScope then it should work in your own application.
For the 5203 I would suggest using the ps5000GetTimebase call and see what is returned for the sample interval.