Streaming mode and circular buffers

Post your MATLAB discussions here
Post Reply
EthicsGradient
Newbie
Posts: 0
Joined: Tue Mar 01, 2016 11:17 am

Streaming mode and circular buffers

Post by EthicsGradient »

Hi,

I'm using a Picoscope 5442A to capture data from two channels (sampling at ~10kHz) using Matlab 2015a

The streaming mode example supplied works great, but I'm going to be collecting data for up to an hour and thus the current setup which appears to use an internal buffer to store all available data is not going to work as the available memory is eventually going to be exhausted.

What I'd like to do is look at the data as it comes in - if there is an interesting event, select out that piece of the time series and save it to disk, pull in the next available samples from the scope and repeat. The processing time required is much less than the data transfer rate so I'm not at risk of overfilling the internal memory of the picoscope.

The rapid block or block mode won't work as I risk missing an event in between block acquisitions, and streaming mode lets me get on with other tasks while the picoscope is acquiring data.

Any pointers gratefully received.

Hitesh

Re: Streaming mode and circular buffers

Post by Hitesh »

Hi,

The streaming mode example copies the data from the oscilloscope driver buffers to temporary application buffers.

The data from these temporary application buffers is plotted once converted into millivolts and also copied into a larger overall buffer for that channel.

You can adapt this to inspect the data as it is collected and there should be MATLAB functions available allowing you to process the data and you can then pull out those samples that you are interested in. What particular events are you looking for?

Regards,

EthicsGradient
Newbie
Posts: 0
Joined: Tue Mar 01, 2016 11:17 am

Re: Streaming mode and circular buffers

Post by EthicsGradient »

Hi Hitesh, thanks for your reply

I'm just searching for peaks in the data as it comes in - it seems to be working fine.

The data is pulled out using these two lines of code

Code: Select all

 
%...check data available on PS
...
%copy latest data to two holding arrays
bufferChA = streamparams.pAppBufferChA.Value(firstValuePosn:lastValuePosn);
bufferChB = streamparams.pAppBufferChB.Value(firstValuePosn:lastValuePosn);
%pull out data and save relevant bits to file
extractpeaks(bufferChA,bufferChB);
%...etc.
My question is - how to stop pAppBufferA/B getting arbitarily large over time - as I don't really care about the historic data. As I said I would be using the block mode or rapid block mode but my events maybe on the msec timescale and I don't want them lost in the interval between blocks.

Sorry if this is a basic question!

Hitesh

Re: Streaming mode and circular buffers

Post by Hitesh »

Hi EthicsGradient,

The arrays corresponding to the libpointer objects pAppBufferChA and pAppBufferChB are fixed in size so they will never grow larger during the data collection process.

The shared library (i.e. the ps5000a driver) writes a number of samples into the buffer registered with the ps5000aSetDataBuffer() function when data is available and this is then copied to the application buffer in the wrapper shared library.

The number of samples written to the driver buffer will always be less than or equal to the size of the driver buffer, and this size should also be passed to the ps5000aRunStreaming().

In the example, another larger buffer is used to copy the data out of the application buffer as on the next iteration the driver and application buffers will be overwritten if there is more data.

Hope this helps,

Post Reply