Hello,
we have been using the C sample code to obtain streaming in non-aggregated mode with PicoScope 5204.
We want to stream data to file with:
sample interval: 104ns
down sample ratio: (1 (no aggregation)
10MB buffer for channel A
a sleep time of 10 ms
Extracted code:
// Register the data buffer 10MB.
unsigned long bufferSize = 10000000;
short *buffer = (short*) malloc(bufferSize * sizeof(short));
ps5000SetDataBuffer(unit->handle, PS5000_CHANNEL_A, buffer, bufferSize);
// start the scope, sampe interval is 104
ps5000RunStreaming(unit->handle,
&g_sampleInterval,
PS5000_NS,
0,
bufferSize,
FALSE,
1,
bufferSize);
// Grab the data
while (!_kbhit())
{
Sleep(10);
g_ready = FALSE;
status = ps5000GetStreamingLatestValues(unit->handle, CallBackStreaming, NULL);
if (g_ready && g_sampleCount > 0)
{
fprintf(fp, "Collected %i samples, index = %i\n", g_sampleCount, g_startIndex);
for (unsigned long i = g_startIndex; i < (unsigned long)(g_startIndex + g_sampleCount); ++i)
{
// adc_to_mv
fprintf(fp, "%2lu: %d\n", i, ((buffer[i]* range ) / PS5000_MAX_VALUE) );
}
}
}
The data seems to be ok (we'we looked at in it MatLAB)
until the buffer wraps around, then we loose data.
We have a fairly new laptop Intel Core 2 Duo, 2.4GHz, 2GB RAM.
What could cause us to loose data (only happens when buffer wraps around, when g_startIndex = 0)?
Regards,
jan
Cart
