overviewBuffers

Post your Linux discussions here
Post Reply
emilgoode
Newbie
Posts: 0
Joined: Mon Oct 03, 2011 8:21 am

overviewBuffers

Post by emilgoode »

Hello,

I'm writing a graphical application for picoscope 2204 so that it can be used on Linux. At the moment I'm using fast streaming with the callback function where you get access to the overviewBuffers datastructure. I want to display the samples from the overviewBuffers "live" graphically in my application.
According to the following code example that was given in another post in the forum, there are 2 buffers for every channel, max and min.
Maybe I'm missing something that is obvious but I'm wondering why there are 2 buffers for each channel?
Also how should I display the samples from these two buffers (as coming from one channel) in my application? In what order are the samples collected in the two buffers and in what order should I read from them?

if(g_DeviceSetting.channel_Setting[PS3000_CHANNEL_A].enabled)
{
memcpy(g_display.buffer_max_a + (g_NumberOfSamples - nValues), overviewBuffers[0], nValues * sizeof(short));
memcpy(g_display.buffer_min_a + (g_NumberOfSamples - nValues), overviewBuffers[1], nValues * sizeof(short));
}

Thanks for your help.

Best regards, Emil

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

Re: overviewBuffers

Post by Martyn »

In fast streaming mode, the PicoScope 2000 driver can use a method called aggregation to reduce the amount of data your application needs to process. This means that for every block of consecutive samples, it stores only the minimum and maximum values. You can set the number of samples in each block, called the aggregation parameter, when you call ps2000_run_streaming_ns() for real-time capture, and when you call ps2000_get_streaming_values() to obtain post-processed data.

You can take the average of the values at each location in the two buffers for use in your application.
Martyn
Technical Support Manager

emilgoode
Newbie
Posts: 0
Joined: Mon Oct 03, 2011 8:21 am

Re: overviewBuffers

Post by emilgoode »

Hello,

Thank you for your quick response!

After a little experimentation with different parameters I managed to get a reliable and steady data stream and display it in my application. However I'm only able to get a correct and steady stream of samples at very specific settings (with very large buffers).
I get a reliable stream of samples using the following parameters to the ps2000_run_streaming_ns function:

sample_interval: 10
time_units: PS2000_US
max_samples: 2000000
noOfSamplesPerAggregate: 100
overview_buffer_size: 500000

If I change these settings the sample stream becomes unreliable.
Correct me if I'm wrong but It seems that the fast streaming feature in the Linux driver is not of the same quality than in the Windows version? Using the Windows software its possible to do fast streaming with all kinds of sampling rates with reliable results. Will the fast streaming functionality in the Linux driver be improved upon in the near future and do you have any plans of making the driver open source?

Best regards, Emil

I should note that I'm using the overview_buffer callback function.
Here is how I'm reading from the overview_buffers (Channel A) and adding it to the buffer in my application:

for (i = 0; i < n_values; i++) {
max = *(overview_buffers[0]+(i*sizeof(short)));
min = *(overview_buffers[1]+(i*sizeof(short)));
average = (max + min) / 2.0;
enqueue_channel_a(average);
}

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

Re: overviewBuffers

Post by Martyn »

When you say that the stream becomes unreliable exactly what do you mean ?
Martyn
Technical Support Manager

emilgoode
Newbie
Posts: 0
Joined: Mon Oct 03, 2011 8:21 am

Re: overviewBuffers

Post by emilgoode »

Hello,

For example when I change the sample_interval to 100 us and keep the other settings as in my previous post I get frequent sample values of -32768 (Min value of a short).

5.00
5.00
-32768.00
0.00
0.00
5.00

I guess this means that the buffers have overrun, but increasing the overview_buffer_size does not help as I'm already using very large buffers. When changing the sample_interval to 1 us I get unreliable sample values as shown below (after letting it run for a couple of seconds).

5.00
5.00
5.00
-141.00
5.00
5.00
5.00
5.00
5.00
5.00
5.00
5.00
5.00
5.00
5.00
123.00
15934.00
15934.00
15934.00
15806.00
15806.00
15806.00
15934.00
15934.00
15934.00

(The picoscope was not connected to any source while collecting samples)

Any advice is greatly appreciated.

Best regards, Emil

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

Re: overviewBuffers

Post by Martyn »

Would it be possible for you to provide your code so that I can look at this in more detail ?

You can post it on here here (please use the code button to format the text so that it appears in a code box) or email it to me at support@picotech.com

Thanks
Martyn
Technical Support Manager

Post Reply