Real time collection and analysis with Matlab

Post any questions you may have about our current range of oscilloscopes
Post Reply
Achc
Newbie
Posts: 0
Joined: Wed Jun 29, 2022 4:56 pm

Real time collection and analysis with Matlab

Post by Achc »

I need to collect a signal from a Picoscope 2208B and analyze it in real time with Matlab.
Ideally the time interval has to be 100ns and I need to analyze ~1ms samples at the time and plot the results.

It seems to me that this could be accomplished using the instrument driver with streaming data capture, but I'm not sure if the process would be fast and smooth enough? It's ok to have a small delay between the analysis and the data acquisition of a single sample, as long the data are stored and plotted continuously.

Thanks in advance, let me know if I have formulated the problem clearly. I'm modifying the Streaming Data Capture Example to see how well it works for my application.

Achc
Newbie
Posts: 0
Joined: Wed Jun 29, 2022 4:56 pm

Re: Real time collection and analysis with Matlab

Post by Achc »

Follow up: I'm running a modified version of PS2000A_ID_Streaming_Example for analyzing and plotting the stream of samples. It works but is there a way to maintain constant the number of collected samples? Data analysis would be a lot easier if the size of the sample were say 100xsample interval

bennog
Advanced User
Advanced User
Posts: 208
Joined: Mon Nov 26, 2012 9:16 am
Location: Netherlands

Re: Real time collection and analysis with Matlab

Post by bennog »

Double buffering is the only solution I could think of.

Everything you receive you put in a ring buffer, at least 2 or 3 times the number of samples you want.
When there is enough data in the ring buffer you take the samples you want and analyze them. The extra samples you leave in the ring buffer for the next time.

Benno

Martyn
Site Admin
Site Admin
Posts: 4499
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Real time collection and analysis with Matlab

Post by Martyn »

The 2208B can stream data continuously at 9.6 MS/s shared between active channels so if you need a sampling interval of 100nsecs, particularly if you need more than 1 channel, then streaming will not be suitable.

Can you draw a picture of the data you are looking to collect, the number of samples required and any sections where you do not need to collect data. We can then look at whether the 2208B will be suitable for your requirements.
Martyn
Technical Support Manager

Achc
Newbie
Posts: 0
Joined: Wed Jun 29, 2022 4:56 pm

Re: Real time collection and analysis with Matlab

Post by Achc »

@ Benno: thank you for help, are you suggesting to use a circular buffer in Matlab? If so can you please point me to an example?

@Marty: Thanks for your feedback. The data collected are voltage pulses from a photomultiplier tube. The pulse duration is typically 100ns, and I need to collect the signal continuously or else I may miss some events. I have used the picoscope 6 to store the pulses in the scope buffer at 9.6 MS/s but I can only record 10 sec of data at the most, which is too short for my needs.

I only need to read data from one channel, so 9.6 MS/s should be (barely) enough. The issue is that the code "PS2000A_ID_Streaming_Example" is storing data in real time at a rate of only ~1MS/s. I'm pretty sure I have only enabled a single channel. Where is the bottleneck? I'm using a laptop with SS USB port to connect to the picoscope 2000.

Thanks again,

bennog
Advanced User
Advanced User
Posts: 208
Joined: Mon Nov 26, 2012 9:16 am
Location: Netherlands

Re: Real time collection and analysis with Matlab

Post by bennog »

My main expertise is in C and C++.

I even can not tell you if MATLAB is fast enough to do tis at 10M values per second.

I know C and C++ can do it with ease, there are always programmers that can even produce code that even C is too slow 8)

Benno

Martyn
Site Admin
Site Admin
Posts: 4499
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Real time collection and analysis with Matlab

Post by Martyn »

The concern is that with a fastest streaming rate of 9.6MS/sec on a single channel, equating to a sampling interval of 104nsec, there will always be a chance of missing 100nsec pulses.

A scope from our 3000D series would better fit this application as they can stream significantly faster as they are USB3 based devices.
Martyn
Technical Support Manager

Achc
Newbie
Posts: 0
Joined: Wed Jun 29, 2022 4:56 pm

Re: Real time collection and analysis with Matlab

Post by Achc »

Thanks Martyn,
Back to my earlier question, is there a way to fix the sample number? Typically, the sample number varies greatly. for instance, ~200000 samples are sent, then ~3000, then ~200000 etc.

Martyn
Site Admin
Site Admin
Posts: 4499
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Real time collection and analysis with Matlab

Post by Martyn »

I would use a linked list of fixed size buffers that you fill in the callback. How many you need will depend upon how much data you wish to handle in your application at any one time, and how long it takes to process it.
Martyn
Technical Support Manager

Post Reply