Test and Measurement Forum

Buffer overruns in fast streaming mode

Post your C and C++ discussions here

Buffer overruns in fast streaming mode

Postby maximus-ms » Fri Dec 07, 2012 11:22 am

I use BCB 6, PicoScope 2205.
In my work I need 1MS/s sample ratio. So I use fast streaming mode.
I use next code:

ps2000_run_streaming_ns(handle_ps, 1, PS2000_US, 1000000 , 0, 1, 100000); // start of sampling
while (run)
{
ps2000_get_streaming_last_values(handle_ps, ps2000FastStreamingReady);
Sleep(32); // 32ms dellay
}
My callback function runs in different thread. The callback functions gets close to 32000-samples bufer from driver every time. It just check every sample if it less -32767(Indicates a buffer overrun in fast streaming mode) and copy driver's bufer. It takes less then 1ms. When PicosCope run it takes until 50% of CPU time.

In result about some 10's of thousands samples is less then -32767 (losted samples) for 10 seconds.

How to fix the problem?
maximus-ms
Newbie
 
Posts: 0
Joined: Fri Dec 07, 2012 9:09 am

Re: Buffer overruns in fast streaming mode

Postby Hitesh » Mon Dec 10, 2012 2:45 pm

Hi maximus-ms,

Have you tried reducing the sleep time?

Try calling the ps2000_overview_buffer_status() function after every call to ps2000_get_streaming_last_values() and see if it returns a non-zero value - this will indicate a buffer overrun.

What version of the ps2000.dll are you using?

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2063
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Buffer overruns in fast streaming mode

Postby jkahrs » Tue Dec 11, 2012 6:44 pm

maximus-ms wrote:When PicosCope run it takes until 50% of CPU time.

The high CPU usage of the PS2000 driver seems to be the real reason why it is so hard to acquire data continuously with a PS2000 scope.
maximus-ms wrote:In result about some 10's of thousands samples is less then -32767 (losted samples) for 10 seconds.

How to fix the problem?


Having done much testing with a PS2005, I use a delay of 1 millisecond between calls to the driver (not 32 as you do). This seems to be important. This way I can acquire data continuously with a sample rate of 5 MHz.
jkahrs
Newbie
 
Posts: 0
Joined: Fri Dec 31, 2010 2:04 pm

Re: Buffer overruns in fast streaming mode

Postby maximus-ms » Wed Dec 12, 2012 11:32 am

Thanks everybody.
Have you tried reducing the sleep time?

Of course. Firstly I used 1-10 ms delay, but later I saw size of bufer which I get from DLL is 32512 samples, so it are some empty calls before buffer reach 32512 size. So I desided use 32-33ms delay.

Try calling the ps2000_overview_buffer_status() function after every call to ps2000_get_streaming_last_values() and see if it returns a non-zero value - this will indicate a buffer overrun.


I tried. The function doesn't work correct or I cann't use it.
Code: Select all
short previous_buffer_overrun = 0;
ps2000_overview_buffer_status ( handle_ps, &previous_buffer_overrun);

The function doesn't change variable "previous_buffer_overrun".

What version of the ps2000.dll are you using?

DLL version 2.0.8.105

maximus-ms wrote:
When PicosCope run it takes until 50% of CPU time.

The high CPU usage of the PS2000 driver seems to be the real reason why it is so hard to acquire data continuously with a PS2000 scope.

The PicoScope6 (software) uses 35-40% of CPU time... hm...

Does it metter: I use Windows 7x64 ?
maximus-ms
Newbie
 
Posts: 0
Joined: Fri Dec 07, 2012 9:09 am

Re: Buffer overruns in fast streaming mode

Postby Hitesh » Thu Dec 13, 2012 9:51 am

Hi maximus-ms,

Our dlls are 32-bit but will work on 64-bit operating systems providing the application has been compiled as a 32-bit application.

Was your device supplied with a blue or white USB cable?

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2063
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Buffer overruns in fast streaming mode

Postby maximus-ms » Thu Dec 13, 2012 1:49 pm

Hitesh wrote:Was your device supplied with a blue or white USB cable?


The device supplied with a blue USB cable. What does it mean?
maximus-ms
Newbie
 
Posts: 0
Joined: Fri Dec 07, 2012 9:09 am

Re: Buffer overruns in fast streaming mode

Postby Hitesh » Thu Dec 13, 2012 3:19 pm

Pico Products used to be shipped with a white USB cable but the blue ones are more suited for the current draw required.

I thought perhaps if it was a white cable, it might impact on data transfer.

I did a quick test yesterday and found some data was missing but not to the extent of your application.

Please download SDK R10.4.3.1 from our website (http://www.picotech.com/software.html) and try the dll that is in there.

Thanks,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2063
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Buffer overruns in fast streaming mode

Postby maximus-ms » Fri Dec 14, 2012 8:45 am

Thank you very much.
I will try the SDK on Monday.
maximus-ms
Newbie
 
Posts: 0
Joined: Fri Dec 07, 2012 9:09 am

Re: Buffer overruns in fast streaming mode

Postby maximus-ms » Mon Dec 17, 2012 12:15 pm

Hitesh wrote:Please download SDK R10.4.3.1 from our website (http://www.picotech.com/software.html) and try the dll that is in there.

So... it is no reason!! I have same results.
maximus-ms
Newbie
 
Posts: 0
Joined: Fri Dec 07, 2012 9:09 am

Re: Buffer overruns in fast streaming mode

Postby maximus-ms » Mon Jan 14, 2013 12:49 pm

Dear, Hitesh.
Send me the working project in Buildr C++, please!
maximus-ms
Newbie
 
Posts: 0
Joined: Fri Dec 07, 2012 9:09 am

Re: Buffer overruns in fast streaming mode

Postby Hitesh » Mon Jan 14, 2013 4:33 pm

Hi,

I have a Visual Studio 2008 Express example in C if that will help.

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2063
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire


Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests