I'm developing an application based on PicoScope 5242A. My application requires to get a block of data at fixed rate (10 Hz). So I setup a high precision timer and on its each tick I run the RunBlock command to request data. I fix the following values for PicoScope configuration:
Input signal frequency = 13.56 MHz
Resolution = 12-bits
Channels enabled = 2
Time-base = 2
Sample count = 185 (in order to gather approximately 10 sine waves in a single block)
The timer precisely ticks every 100 ms. The problem is that when I measure the time PicoScope takes after the RunBlock command until the values have been received in the PC buffers (using GetValues) is not only very random but also high. It usually takes as low as 3ms to as high as 230ms occasionally

Now as I read in the manual the expected overhead is tens of milliseconds but this is huge and bigger problem is its not constant. After getting a block at 10Hz, I need to perform data processing that must be finished well before the next block comes in. How can I get the blocks precisely at 10Hz always? Am I doing something wrong here? Please look into this problem.
Thanks. Here is the code I used to record the delay.
Code: Select all
while (true)
{
_ready = false;
_callbackDelegate = BlockCallback;
stopwatchDataAcqDuration.Restart();
do
{
retry = false;
status = Imports.RunBlock(_handle, 0, (int)sampleCount, _timebase, out timeIndisposed, 0, _callbackDelegate, IntPtr.Zero);
if (status == (short)StatusCodes.PICO_POWER_SUPPLY_CONNECTED || status == (short)StatusCodes.PICO_POWER_SUPPLY_NOT_CONNECTED || status == (short)StatusCodes.PICO_POWER_SUPPLY_UNDERVOLTAGE)
{
status = Imports.ChangePowerSource(_handle, status);
retry = true;
}
else
{
//textMessage.AppendText("Run Block Called\n");
}
}
while (retry);
while (!_ready)
{
//Thread.Sleep(100);
}
if (_ready)
{
short overflow;
status = Imports.GetValues(_handle, 0, ref sampleCount, 1, Imports.DownSamplingMode.None, 0, out overflow);
if (status == (short)StatusCodes.PICO_OK)
{
System.Diagnostics.Debug.Print(stopwatchDataAcqDuration.ElapsedMilliseconds.ToString());
}
else
{
//textMessage.AppendText("No Data\n");
}
}
else
{
//textMessage.AppendText("data collection aborted\n");
}
}
});