Capturing data

Post your MATLAB discussions here
Post Reply
IBT_ETHZ
Newbie
Posts: 0
Joined: Mon Feb 06, 2017 10:38 am

Capturing data

Post by IBT_ETHZ »

Hello,

My aim is to use the picoscope and function generator from MATLAB to automatize and in vitro experiment. In particular, I connect to the picoscope and have a loop to set the parameters of the function generator via MATLAB (the loop runs over the parameter space). In each loop iteration, I would like to capture data using the picoscope and save the data in .mat format.

I had some trouble connecting to the picoscope to begin with, but now I can connect and set up the channels, but I'm a little clueless on how to capture and save data. I tried going through the forum, but couldn't find something very helpful. Could you please guide me and/or point to other posts that have this problem solved?

Thanks.
Picoscope model: 3205B

Hitesh

Re: Capturing data

Post by Hitesh »

Hi,

It would be helpful if you can try capturing a signal as desired using the PicoScope 6 software. If you click Views -> View Properties we can also see the sampling information.

We can then advise on how to map the settings across to a MATLAB script.

You should be using the files from the ps3000a_BETA folder in this Instrument Driver package.

Regards,

IBT_ETHZ
Newbie
Posts: 0
Joined: Mon Feb 06, 2017 10:38 am

Re: Capturing data

Post by IBT_ETHZ »

Hi Hitesh,

Thanks for your prompt reply. I've attached a snapshot of the properties that you requested.
Attachments
ViewProperties_snapshot.PNG
ViewProperties_snapshot.PNG (9.91 KiB) Viewed 8894 times

Hitesh

Re: Capturing data

Post by Hitesh »

Hi IBT_ETHZ,

Thank you for the information.

Based on the sampling rate, I would suggest modifying the Block mode capture example.

You can set the channels based on the information in the Properties pane.

You will need to use the Programmer's Guide to work out the timebase index required for a 16 ns sampling interval and then set the timebase property of the Instrument Driver.

You will also need to set the pre- and post-trigger samples to match the 32764 samples in your setting. As your screenshot does not show the full PicoScope screen I cannot see any trigger settings, but if you have one set and the trigger diamond is at 50% pre-trigger, then you would set 16382 for your pre- and post-trigger samples.

To set the signal generator, copy and paste the code from the example script that shows how to set an the in-built function generator and then set the parameters accordingly.

One further tip is that if the struct ps3000aEnuminfo has been loaded into the MATLAB workspace from the PS3000aConfig.m file, you can check the enumeration values available e.g. to set a square wave.

Hope this helps,

IBT_ETHZ
Newbie
Posts: 0
Joined: Mon Feb 06, 2017 10:38 am

Re: Capturing data

Post by IBT_ETHZ »

Hi Hitesh,

Thanks a lot for your reply. I just have one more question. I want to collect data over a 3 minute period continuously while I'm recording, but I'm not entirely sure if that is possible because of how block mode takes memory.

My question is that for the code below, do I just change the 'numPostTriggerSamples' to (3 min * 60 sec/min * 62.5MS/sec) = 112500MSamples?

Code: Select all

%% Set Block Parameters and Capture Data
% Capture a block of data and retrieve data values for Channels A.

% Block data acquisition properties and functions are located in the 
% Instrument Driver's Block group.

blockObj = get(ps3000aDeviceObj, 'Block');
blockObj = blockObj(1);

% Set pre-trigger and post-trigger samples as required
% The default of 0 pre-trigger and 1 million post-trigger samples is used
% in this example.

preTriggerSamples = 0;
postTriggerSamples = data.BUFFER_SIZE - preTriggerSamples;

set(ps3000aDeviceObj, 'numPreTriggerSamples', preTriggerSamples);
set(ps3000aDeviceObj, 'numPostTriggerSamples', postTriggerSamples);

Hitesh

Re: Capturing data

Post by Hitesh »

Hi,

Unfortunately, the PicoScope 3205B only has 32 MS memory so it is not possible to capture 3 minutes of data at 62.5 MS/s into memory on the PicoScope.

In streaming mode, you could collect data at up to around 31.25 MS/s (shared between all channels) but this could be impacted by overheads on the PC e.g. CPU/memory usage by MATLAB.

To collect data in streaming mode at 62.5 MS/s you would require one of the USB 3.0 PicoScope 3000 Series models.

Regards,

IBT_ETHZ
Newbie
Posts: 0
Joined: Mon Feb 06, 2017 10:38 am

Re: Capturing data

Post by IBT_ETHZ »

Hi Hitesh,

Thanks again, but would it be possible to collect data intermittently (for the maximum time possible), save it, and restart collecting data and do so for say 3 minutes? If so, how would you recommend to implement it?

Best regards

Hitesh

Re: Capturing data

Post by Hitesh »

Hi,

You could capture successive blocks of data but there would be deadtime in between while the scope rearms itself which could be tens of milliseconds. You would have to process the data in each loop to avoid it being overwritten.

The other option is to reduce the sampling interval if possible and use either block or streaming mode data capture.

Regards,

Post Reply