Buffer clarification

Post your C and C++ discussions here
Post Reply
madnugget
Newbie
Posts: 0
Joined: Thu Feb 17, 2022 3:00 am

Buffer clarification

Post by madnugget »

Hi, I have trouble understand how should the buffers be properly defined. I have looked through the forum and had a rough understanding, but hope this post could help future users.

I am using a 3406D and 3206D and intend to run all channels at streaming at sampling interval of 56ns. To start off, I intend to capture up to 30s of data. For testing purpose, I had tried with 3s. With 56ns interval, I should be expecting ~53,571,428 sample points.

With reference to the example code, these are the values that I have changed in order to achieve close to ~50,000,000 data points.
#define BUFFER_SIZE 1024 /* change to 2,000,000*/

uint32_t sampleCount = 100000 /* Change to 5,000,000 Make sure buffer large enough */

Is this the correct way to set up? From info that I have gather, it was said to ensure that the overview buffer is > data buffer, for referencing to the example, it is referring to sampleCount and BUFFER_SIZE respectively?

There is another definition of buffer in the example as well:
buffers[PS3000A_MAX_CHANNEL_BUFFERS]
appBuffers[PS3000A_MAX_CHANNEL_BUFFERS]
I read that it is use for transferring of data from the scope (buffers) to the code (appBuffers). Does these need to be changed?

On the topic of timebase and sampleInterval, I am confused on how they relate to each other. For timebase 9, it was translated to 56ns, however strictly to sample at 56ns, I have to set
sampleInterval = 56 and
timeUnits = PS3000A_NS. May I know how does the timebase affects my acquisition?

Thanks for taking the time to go through!

madnugget
Newbie
Posts: 0
Joined: Thu Feb 17, 2022 3:00 am

Re: Buffer clarification

Post by madnugget »

May I also add another help request to guide on how should a proper data saving process should be like? Apologise that I am not well proficient in this area.

I had used the example code way to write the data to a txt file (even explored writing in binary) but it appears to be interferring with data acquisition? E.g commenting away the file IO write, it will show ~50,000,000 samples collected (as per example code). With the fwrite, I am getting way less than that, hence concluding it is the writing process lagging. Am I right?

I had seek more experience coder's help and was told the following as per what was frequently mentioned.
1) save the data to memory and only write to file once complete
-> My concern here is the huge amount of data involved. 3sec of data yields 50mil data points; i would require 30sec. Appreciate if advise could be given on actual implementation.
2) parallel thread writing the data to file
-> I was told it might not make a difference. Similarly, is there any working example that someone can point me to?

On top of that, I am using some typical industrial workstation specification. With many of the implementation discussed in the forum, is it only implementable on powerful supercomputer/reflective memory etc? From my understanding, this is a simple API coding of data acquisition from an oscilloscope and it should not be a problem for a standard workstation?

Appreciate any help and comments. Thanks!

Post Reply