Test and Measurement Forum

Streaming mode and circular buffers

Post your MATLAB discussions here

Streaming mode and circular buffers

Postby EthicsGradient » Tue Mar 01, 2016 11:22 am

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.
EthicsGradient
Newbie
 
Posts: 0
Joined: Tue Mar 01, 2016 11:17 am

Re: Streaming mode and circular buffers

Postby Hitesh » Tue Mar 01, 2016 2:15 pm

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,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2058
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Streaming mode and circular buffers

Postby EthicsGradient » Tue Mar 01, 2016 2:49 pm

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!
EthicsGradient
Newbie
 
Posts: 0
Joined: Tue Mar 01, 2016 11:17 am

Re: Streaming mode and circular buffers

Postby Hitesh » Wed Mar 02, 2016 12:32 pm

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,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2058
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire


Return to MATLAB

Who is online

Users browsing this forum: No registered users and 0 guests