matlab examples with picoscope 3405A

Post your MATLAB discussions here
joejk
User
User
Posts: 4
Joined: Thu Mar 30, 2017 5:11 am

matlab examples with picoscope 3405A

Post by joejk »

Hello,
I am trying to run the MatLab examples supplied with the PS3000a SDK. They don't seem to work with my unit. The Picoscope firmware version is 1.2.1. I'm particularly interested in the streaming example -- it should work as is, shouldn't it?
Cheers
Joe

Hitesh

Re: matlab examples with picoscope 3405A

Post by Hitesh »

Hi Joe,

Sorry for the delay in a response coming back to you owing to the Easter break.

Please could you e-mail support@picotech.com and we can provide you with some updated files.

Regards,

joejk
User
User
Posts: 4
Joined: Thu Mar 30, 2017 5:11 am

Re: matlab examples with picoscope 3405A

Post by joejk »

Thanks for your response. Before I email support, the problem I'm having is with the call to 'GetStreamingLatestValues' which returns 13 (PICO_INVALID_PARAMETER). The c-code indicates that this is returned when it gets and invalid deviceIndex value. But the MATLAB example invokes this call using the device object (handle). Could that be the problem?

Hitesh

Re: matlab examples with picoscope 3405A

Post by Hitesh »

Hi joejk,

I have responded to your e-mail with some files to try.

These will be available via our File Exchange page in the near future.

Regards,

joejk
User
User
Posts: 4
Joined: Thu Mar 30, 2017 5:11 am

Re: matlab examples with picoscope 3405A

Post by joejk »

Hi Hitesh,
I have not received an email from you. Please let me know which files to download.
Cheers
Joe

Hitesh

Re: matlab examples with picoscope 3405A

Post by Hitesh »

Hi Joe,

I've resent the e-mail to you.

Please do check spam/junk folders as sometimes e-mails from our e-mail support system can end up there.

Regards,

joejk
User
User
Posts: 4
Joined: Thu Mar 30, 2017 5:11 am

Re: matlab examples with picoscope 3405A

Post by joejk »

Thank you. The streaming example in the new files is working.

I noticed in the new example that there is code like the following:
triggerGroupObj = get(ps3000aDeviceObj, 'Trigger');
triggerGroupObj = triggerGroupObj(1);
[status.setTriggerOff] = invoke(triggerGroupObj, 'setTriggerOff');

This is a bit different than what is documented in the Matlab Instrument Driver Guide that is available on the download page (updated May 2014). It looks like a new object is derived from the device object and has its own library functions. Is there more documentation on the triggerGroupObject? For example, if I wanted to use a simple external trigger, would I invoke the usual 'setSimpleTrigger' with the new trigger object? Or is there another function to be called using this object?

Similarly, there is also a streamingGroupObj:
streamingGroupObj = get(ps3000aDeviceObj, 'Streaming');

Are there other derived objects? Are they documented?
Cheers
Joe

Hitesh

Re: matlab examples with picoscope 3405A

Post by Hitesh »

Hi Joe,

Once you have created an icdevice object, you can use the methods function via the command window to view the functions available e.g.

Code: Select all

methods(ps3000aDeviceObj);
To view help for a function, use the instrhelp function e.g.

Code: Select all

instrhelp(ps3000aDeviceObj, 'ps3000aSetChannel');
To view the properties (and groups) of an object, call

Code: Select all

fieldnames('ps3000aDeviceObj')
You can then call the instrhelp function to view help text for the property you are interested in.

The same can be repeated for the various groups shown in the examples such as 'Block' and 'Trigger'.

If you are looking to use the external trigger, you can do so by calling the setSimpleTrigger() function from the newly created trigger group object.

There are other groups for Block, Rapid Block and the Signal Generator in order to group relevant functions together. The device object has the core functions and properties that apply to the setup of the device and are common to various modes of data collection.

It is our aim to provide Instrument Driver specific documentation via html files which will be packaged with the Instrument Driver.

You can also open the Instrument Driver in the Instrument Driver editor and view the functions and properties of the device.

Hope this helps,

joejk
User
User
Posts: 4
Joined: Thu Mar 30, 2017 5:11 am

Re: matlab examples with picoscope 3405A

Post by joejk »

Hello,
Thank you, Hitesh. That was helpful.

Further on streaming data with matlab: I'm trying to use triggering with streaming. It seems that the trigger is recorded upon the first trigger signal (rising edge), and I can get the index of the data where that trigger happens. But I need a way to get all the data indices corresponding to repeated trigger signals while I'm streaming data. Is this possible?
Cheers
Joe

Hitesh

Re: matlab examples with picoscope 3405A

Post by Hitesh »

Hi Joe,

It is only possible to obtain one trigger event during the course of a streaming data collection event, so you would have to consider multiple streaming acquisitions in succession or process the data afterwards looking for the trigger events.

How long do you need to capture data for and what is the sampling rate? What is the time interval between trigger events?

Regards,

joejk
User
User
Posts: 4
Joined: Thu Mar 30, 2017 5:11 am

Re: matlab examples with picoscope 3405A

Post by joejk »

Hi Hitesh,
Thank you for the reply.

Using my current configuration, I want to capture data on each and every channel at 20MS/s. The trigger signal is ~1kHz. For each channel, that's 20kS per trigger event. That data is to be squared and summed into the application buffer while data for the subsequent trigger event is being collected. I haven't yet tried this, so I don't know if there will be timing issues. I prefer not to miss data. Then I would like to continue to collect datain this manner for a variable amount of time - a few seconds to a few minutes.

Cheers
Joe

Hitesh

Re: matlab examples with picoscope 3405A

Post by Hitesh »

Hi Joe,

When stopping and starting streaming acquisition, there will some downtime of most likely tens of milliseconds.

If you did not need to process the data until after the whole data collection is complete, you could use rapid block mode to capture the 20 kS segments into memory.

The 20 MS/s sampling rate could potentially be achieved using downsampling in rapid block mode but in streaming mode the closest below the limit of the USB bus would be about 17 MS/s.

Regards,

joejk
User
User
Posts: 4
Joined: Thu Mar 30, 2017 5:11 am

Re: matlab examples with picoscope 3405A

Post by joejk »

Thank you, again.
I have tried a streaming with start/stop technique from the matlab script and a fraction of a second of data took many seconds to acquire (without squaring and summing). The other disadvantage was that each data segment was a bit arbitrary in length, and, though I did have the index of the trigger, sometimes the length was less than the 20kS minimum. I'm probably not doing it the best way, and it may be that the matlab for-loop is the bigger bottleneck -- not sure. I will investigate rapid block mode. Perhaps a MEX file to square and sum the data would be faster and on a separate thread(?).

How did you calculate the 17MS/s limit? Would this be the same for a picoscope 4824 (USB 3.0)? I would like 5 data channels, ideally, and that would require 5x20MS/s to be squared and accumulated in as close to real time as possible.

Joe

Hitesh

Re: matlab examples with picoscope 3405A

Post by Hitesh »

Hi Joe,

If you are able to undertake your data processing post-capture then a rapid-block capture might be a better option.

The device can sample at finite frequencies (see the Timebases section in the Programmer's Guide), with the maximum streaming rate being less than the fastest sampling rate for the device (due to the USB bandwidth).

With USB 2.0 devices, the maximum sampling rate is around 30 MS/s due to the bandwidth of the USB connection. Having checked using the formula in the Programmer's Guide, it should be possible to obtain a streaming rate of around 31 MS/s (apologies, looks like I got mixed up with the maximum sampling rate for the 3000D/D MSO models when using a USB 3.0 connection and the PicoScope 6 software :oops:).

The closest sampling rate to 20 MS/s is about 20.8 MS/s.

With the PicoScope 4824, 20 MS/s for 5 channels should be possible. The Instrument Driver package can be found via the MATLAB Add-Ons Manager if you search for PicoScope 4000 Series (A API) - MATLAB Generic Instrument Driver.

Regards,

joejk
User
User
Posts: 4
Joined: Thu Mar 30, 2017 5:11 am

Re: matlab examples with picoscope 3405A

Post by joejk »

Hi again,
I have tried the example PS3000A_ID_Rapid_Block_Plot3D_Example. I modified it to take data in successive calls to 'getRapidBlockData'. This works but each call displays text on the matlab command window:
getRapidBlockData: Retrieving data...
getRapidBlockData: Converting Analogue channels to millivolts and assigning to channel array.
getRapidBlockData: Data succesfully retrieved.

I think this slows down successive data acquisition and I would like to avoid it. Is there a way? I would also think that converting to millivolts could be deferred until all data is collected.

I also wish to port everything to another computer. I am uncertain where to go to download the definitive driver software and matlab examples, and what the folder hierarchy should be. The picotech website and the matlab website are different in this respect.
Joe

Post Reply