PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
@CFUNCTYPE(None, c_int16,c_int32,c_uint32,c_int16,c_uint32,c_int16,c_int16,c_int32)
def callBackStreaming(handle,noOfSamples,startIndex,overflow,triggerAt,triggered,autoStop,pParameter):
pass
Code: Select all
m = ps.ps4000aGetStreamingLatestValues(self.handle, callBackStreaming, byref(pCallBack))
m = ps.ps4000aGetStreamingLatestValues(self.handle, callback, c_void_p())
ctypes.ArgumentError: argument 2:: wrong type
Code: Select all
@ctypes.CFUNCTYPE(None, ctypes.c_int16, ctypes.c_int32, ctypes.c_uint32, ctypes.c_int16, ctypes.c_uint32, ctypes.c_int16, ctypes.c_int16, ctypes.c_int32)
def callback_py2(handle, nSamples, startIdx, overflow, triggerAt, triggered, autoStop, param):
# Update global variables
global block_offset, block_samples, sample_count, called_back, trigger_flag, overflow_flag
if overflow != 0:
overflow_flag = True
if triggered != 0:
trigger_flag = True
block_offset, block_samples, trig_offset = startIdx, nSamples, triggerAt
srce_addr = ctypes.addressof(bufferA) + block_offset*2 + trig_offset*2
dest_addr = ctypes.addressof(data_buffer) + sample_count*2
ctypes.memmove(dest_addr, srce_addr, block_samples*2)
sample_count += block_samples
called_back = True
I've been trying to set up python streaming with a digital trigger in python. I'm using a 5443D, and my code is in python 2.7, and my machine is running Ubuntu 16.Anders_Eriksson wrote: ↑Wed Apr 15, 2020 12:49 pmHi!
I have a 3204D MSO scope.
I have been experimenting with ps3000aStreamingExample.py
and added digital trig on bit D5 negativ edge
chA has a triangle waveform with 1Hz, +- 200mv pk-pk, blue signal
chB is connect with a 10times probe to the same digital waveform that is connected to D5 (3.3V => approx 330mV), red (or perhaps orange)
D5 * 100 + 100 is the green signal
Sampling at 1Mhz for 1sec, trigger position 40%
Hope this can be helpful, I would like more examples of this kind of more "advanced features" .
Thanks,
Anders
I have attached the complete code, but below are some "key parts" where I have also removed "the diagnostic logging".
Note especially how the "triggerAt" param is used :
nextSample -= triggerAt
Thanks to this (in my test; the triggeAt had the value of 2091) the trigger position is correct within a sample, that can be seen in the attached "zoomin_at_trigger_pos_40_percent.png"
from collections import deque
bufferCompleteA = deque(np.zeros(shape=totalSamples, dtype=np.int16), maxlen=totalSamples)
bufferCompleteB = deque(np.zeros(shape=totalSamples, dtype=np.int16), maxlen=totalSamples)
bufferCompleteDPort0 = deque(np.zeros(shape=totalSamples, dtype=np.int16), maxlen=totalSamples)
def streaming_callback(handle, noOfSamples, startIndex, overflow, triggerAt, triggered, autoStop, param):
global nextSample, autoStopOuter, wasCalledBack, post_trig
wasCalledBack = True
if triggered:
post_trig = True
nextSample -= triggerAt
sourceEnd = startIndex + noOfSamples
bufferCompleteA.extend(bufferAMax[startIndex:sourceEnd])
bufferCompleteB.extend(bufferBMax[startIndex:sourceEnd])
bufferCompleteDPort0.extend(bufferDPort0Max[startIndex:sourceEnd])
if autoStop:
autoStopOuter = True
if post_trig or nextSample < maxPreTriggerSamples:
nextSample += noOfSamples
streaming_with_digital_trig.PNG