Streaming with Python

Post general discussions on using our drivers to write your own software here
Post Reply
Reynaulu
User
User
Posts: 4
Joined: Tue Nov 20, 2018 12:37 pm

Streaming with Python

Post by Reynaulu » Tue Dec 04, 2018 3:37 pm

Hello all,

I am not familiar with Python and programming with Picoscope. I would like to write a python program in order to record long sets of data (~1hour). I have a Picoscope2206BMSO for starting but I will soon move to a Picoscope 4262 if everything goes well.

Therefore I would like to use a streaming function, and somehow save all the data (time and volt) in a convenient format if possible (.txt or .csv ?). Does that sound possible ?


I started to download PicoSDK and the wrapper from the official picotech github (https://github.com/picotech/picosdk-python-wrappers) but there is no streaming example.
I found the deprecated github https://github.com/picotech/picosdk-python-examples and tried the stream_capture.py but it doesn't work (ModuleNotFoundError: No module named 'exceptions').
I found another Github from a member of this community, Mr Bentham https://github.com/jbentham/picostream where there was a streaming function. I tried it a couple of time and it works but I don't know how to save the data recorded from that software.

Did anyone tried to do streaming and record the data in a format that can be used later ?

Bests !

zipcode
Newbie
Posts: 0
Joined: Wed Dec 05, 2018 8:54 am

Re: Streaming with Python

Post by zipcode » Wed Dec 05, 2018 9:07 am

I am also having problems with streaming in Python. I'm stuck with the callback function.
First I defined the callback function as:

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
Than I make the call from the GetStreamingLatestValues as:

Code: Select all

m = ps.ps4000aGetStreamingLatestValues(self.handle, callBackStreaming, byref(pCallBack))
I get the following error:

m = ps.ps4000aGetStreamingLatestValues(self.handle, callback, c_void_p())
ctypes.ArgumentError: argument 2: : wrong type

Does someone have any idea what I am doing wrong?

zipcode
Newbie
Posts: 0
Joined: Wed Dec 05, 2018 8:54 am

Re: Streaming with Python

Post by zipcode » Wed Dec 05, 2018 9:12 am

Where do you problems with https://github.com/jbentham/picostream ?

vincenthuh
Newbie
Posts: 0
Joined: Fri Feb 08, 2019 11:07 am

Re: Streaming with Python

Post by vincenthuh » Fri Feb 08, 2019 3:08 pm

hello I have the same request with you.
I read the same github project too.
I need to save the data from pico-6 software to .csv file. The data is not big, maybe 10M.
I want to find a save function when encounter with a trigger .
I am not sure that if the block function or the streaming function would have a conflict with the software.

zipcode
Newbie
Posts: 0
Joined: Wed Dec 05, 2018 8:54 am

Re: Streaming with Python

Post by zipcode » Wed Feb 13, 2019 1:51 am

Streaming mode with python looks like is not available for now.

calaset
Newbie
Posts: 0
Joined: Mon Mar 25, 2019 7:41 pm

Re: Streaming with Python

Post by calaset » Mon Mar 25, 2019 8:05 pm

Hi all,

I'm hopping on this thread because 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.

I've successfully set up the digital trigger, and it works with block mode.

I've modified the code from https://github.com/jbentham/picostream/ ... ostream.py
for my application and I've successfully gotten it to stream data in my setup.

I'm attempting to use the triggered and triggeredAt flags in my callback function, but the triggered flag never becomes nonzero.

For reference my callback function is:

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
If you have any input on how to use the trigger with streaming, please let me know.

Thank you,
Mark

Post Reply