Using PS5000 API to capture data like PicoScope

Post your C and C++ discussions here
Post Reply
ristiisa
Newbie
Posts: 0
Joined: Fri Jan 13, 2017 1:48 pm

Using PS5000 API to capture data like PicoScope

Post by ristiisa »

How could I get the same data, shown in the following image, using the PS5000 API:
Image

I tried to use ps5000RunStreaming and ps5000GetStreamingLatestValues but I have several issues with my code:
http://pastebin.com/nxUGmkK3

1. I need to keep calling ps5000GetStreamingLatestValues or the callback is not being called.
2. maxPreTriggerSamples and maxPostPreTriggerSamples does not seem to do any effect in ps5000RunStreaming.
Regardless if 1000 or 100000 samples the returned amount of data seems random and is sometimes larger than the amount of samples requested. For example with down sample ratio of 1 and 2000 samples, last call returned 1929576 samples.
3. autoStop in ps5000RunStreaming will not trigger.
4. Should I stop calling ps5000GetStreamingLatestValues if I have received the amount of samples that would fill my time window? Some times the data keeps coming and will not stop (sampleCount > 0).

Here is my setup information:
Driver Version 1.5.4.32
USB Version 2,0
Hardware Version 1
Variant 5203
Batch/Serial AV367/54
Cal Date 18.10.2011
Kernel Version 1,0
Digital H/W Ver. 1
Analogue H/W Ver. 1

Hitesh

Re: Using PS5000 API to capture data like PicoScope

Post by Hitesh »

Hi ristiisa,

Would it be possible to attach the screenshot or a PicoScope psdata file showing the PicoScope collection settings please?

When you start the device streaming, you need to poll for data using the ps5000GetStreamingLatestValues() function and ensure that in the streaming callback, you are copying data from the driver buffers into application buffers which you can then process. You need to be requesting data regularly otherwise it could be lost, so also try reducing the sleep from 100 to a value that ensures that the loop execution time is sufficient for data to be collected at the sampling rate without loss of data.

The maxPreTriggerSamples and maxPostPreTriggerSamples parameters are used when the autoStop flag is set and also when requesting data from the driver post-capture using the ps5000GetValuesAsync() call.

Looking at the code, I can see that you are requesting a 16 ns sampling interval which is faster than what is possible over USB 2.0 connections. Does this return an error status code? It might be worth trying to drop the sampling interval down to 32 ns or less.

You can obtain a later version of a 32-bit driver from the PicoScope 6.12 stable release installation directory.

Regards,

ristiisa
Newbie
Posts: 0
Joined: Fri Jan 13, 2017 1:48 pm

Re: Using PS5000 API to capture data like PicoScope

Post by ristiisa »

Hi Hitesh,

How do I know that loss of data has occured?
How does PS5000 API know that I have collected all the samples?
Should I be using the ps5000GetValuesAsync instead of ps5000GetStreamingLatestValues?

I took the 16ns sample rate from the value shown in PicoScope GUI. All calls return PICO_OK.

I attached the psdata file to this post.

Regards,
Ristiisa
Attachments
20170116-0001.psdata
(109.78 KiB) Downloaded 458 times

Hitesh

Re: Using PS5000 API to capture data like PicoScope

Post by Hitesh »

Hi ristiisa,

Probably the best way to check if there is lost data would be to inspect the data post-capture and look for discontinuities.

The driver would know if all the samples have been collected as it will keep a count internally.

The ps5000aGetValuesAsync() is used to retrieve data AFTER the capture is complete.

Looking at your image and data file, you appear to be using a block mode capture so I would suggest referring to the section about block mode captures in the Programmer's Guide.

Regards,

Post Reply