Test and Measurement Forum

overviewBuffers

Post your Linux discussions here

overviewBuffers

Postby emilgoode » Mon Oct 03, 2011 8:49 am

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
emilgoode
Newbie
 
Posts: 0
Joined: Mon Oct 03, 2011 8:21 am

Re: overviewBuffers

Postby Martyn » Tue Oct 04, 2011 9:58 am

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 Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2348
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: overviewBuffers

Postby emilgoode » Thu Oct 13, 2011 4:23 pm

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);
}
emilgoode
Newbie
 
Posts: 0
Joined: Mon Oct 03, 2011 8:21 am

Re: overviewBuffers

Postby Martyn » Tue Oct 18, 2011 12:47 pm

When you say that the stream becomes unreliable exactly what do you mean ?
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2348
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: overviewBuffers

Postby emilgoode » Wed Oct 19, 2011 10:12 am

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
emilgoode
Newbie
 
Posts: 0
Joined: Mon Oct 03, 2011 8:21 am

Re: overviewBuffers

Postby Martyn » Thu Oct 27, 2011 7:44 am

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 Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2348
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots


Return to Linux

Who is online

Users browsing this forum: No registered users and 0 guests