I'm creating streaming capture program using GetStreamingLatestValues().
It is roughly working now, but I'm a bit puzzled.
1. How can I assure the program captured all data, or how can I count the number of data dropped ? I feel this feature is important for me because I need up to 5 or 10 Mega samples per Sec capturing.
2. How should I handle 'PICO_BUSY' status ? Should I just neglect and retry this code ?
Assuming, 'PICO_BUSY' means 'driver is busy just now', I wrote like,
status = Imports.GetStreamingLatestValues(_handle, callback, param);
if (status == PICO_BUSY)
{
Thread.Sleep(10);
status = Imports.GetStreamingLatestValues(_handle, callback, param);
}
//PICO_BUSY status still happens.
But PICO_BUSY status still happens. Does it mean some error status ?
Thanks in advance.
To ensure the best possible chance of collecting the data without dropping too much data, you should set the size of the overview buffer to be a little larger than the number of samples that would be collected in the time it takes to execute a single iteration of the loop to collect data.
When you get a 'PICO_BUSY' status code, you should wait a little while before calling GetStreamingValues() again.
Thank you, excuse me for lack of information.
I'm using PicoScope 3205B and 3206B now, and palnnig to use 2205MSO also.
As to "the size of the overview buffer", if my understanding is correct,
my program assigned 640kbytes (for 320k samples) .
I feel it is large enough, isn't it ?
My program is like below code.
BufferSize = 320000
buffers = new short[_channelCount * 2][];
for(int chan=0; chan< _channelCount; chan++)
{
buffers[chan] = new short[BufferSize];
buffers[chan + 2] = new short[tempBufferSize];
status = Imports.SetDataBuffers(_handle, (Imports.Channel)(chan),
buffers[chan], buffers[chan+2], (int)BufferSize, 0,
Imports.RatioMode.None );
}
appBuffer = new short[ _channelCount * BufferSize ];
intval = 240;
units = Imports.ReportedTimeUinits.NanoSeconds;
ratioMode = Imports.RatioMode.None;
do{
status = Imports.RunStreaming(_handle, ref interval, units, 2000, 4000,
false, 1, ratioMode, BufferSize);
#if status != PICO_OK; do somothing to recover or wait;
...
} while (status != PICO_OK);
#prepare the output file;
bwriter = new System.IO.BinaryWriter(File.OpenWrite("capdata.bin"));
while (! stop_condition)
{
status = Imports.GetStreamingLatestValues(_handle, callback, param);
#
# if status == PICO_OK and callback has done job, captured data is in
'appBuffer';
# output them
for(int i=0;i<_sampled; i++)
bwriter.Write((short)appBuffers[i]);
}
#
Imports.Stop(_handle);
bwrite.close();
Do you have any hits how many miliseconds I should wait before
calling GetStreamingValues() again, when PICO_BUSY detected ?
For example,
Assuming, preTrigger + postTrigger <= 8000 and sample-interval is 240 nano Sec,
calculating; 8000 x 240 nano = 1920 micro ,
2 m Sec wait should be enough ? I'm not sure.
Just to add to AndrewA's response, if the call to GetStreamingLatestValues() returns something other than PICO_OK, handle the status code accordingly in your loop e.g. if it is PICO_BUSY, wait a short while before calling the functions again.
To ensure the best possible chance of collecting the data without dropping too much data, you should set the size of the overview buffer to be a little larger than the number of samples that would be collected in the time it takes to execute a single iteration of the loop to collect data.
When you get a 'PICO_BUSY' status code, you should wait a little while before calling GetStreamingValues() again.
Which specific PicoScope device are you using?
Regards,
Do you mean the time from callback call to callback call (or from PICO_OK over PICO_BUSY to PICO_OK) as the time it takes to execute a single iteration of the loop to collect data?