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.
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.
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.
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.