User manual
Programmer’s Guide Page 37 of 64
for (int n=0; n<nbrSegments; n++) {
for (int i=0; i<nbrSamples; i++) {
waveformUnwrap[(n*nbrSamples)+i]=
waveformArray[n*segDescArray[n].actualSegmentSize +
(segDescArray[n].indexFirstPoint+i) %
segDescArray[n].actualSegmentSize];
}
}
3.11.4. Averaging Waveforms in a Digitizer
The driver includes 4 functions provided to improve performance when averaging waveforms.
The first pair of functions, AcqrsD1_averagedData for any digitizer (and the older AcqrsD1_averagedWform for
8-bit digitizers only), are meant only for single channel, single segment operation. They average a predefined number
of waveforms, taking care of the acquisition loop internally. The client must supply a working array (dataArray or
waveformArray, for internal use) and an accumulation array (sumArray). The accumulation array is reset
automatically inside the function at the beginning of each call. When the function returns successfully, the
accumulation array contains the sample-by-sample sum of the waveforms. To get the average values, the array
elements must be divided by the number of acquisitions nbrAcq. If, for each acquisition, the trigger does not arrive
within the requested timeout after the beginning of the acquisition, the function returns with an error code.
The second pair of functions, AcqrsD1_accumulateData for any digitizer (and the older
AcqrsD1_accumulateWform for 8-bit digitizers only) can be used for multi-channel operation and can be called for
each acquisition the user wants to accumulate. It reads the waveform in the module, and performs a sample-by-
sample accumulation in the client array. Here again, the client must supply a working array (dataArray or
waveformArray, for internal use) and an accumulation array (sumArray). The client controls the acquisition, and
must reset the accumulation array appropriately.
In both cases, the allocation of the memory for the working array (dataArray or waveformArray) has been left to
the client for performance reasons. Its size must be at least the requested number of samples nbrSamples + 32, for
reasons of data alignment. The content of this working array is not meant to be used by the client.
Please note that in both cases, sub-sample timing information (i.e. horPos, see section 3.12, Horizontal Parameters
in Acquired Waveforms) is not taken into account.
3.11.5. Reading an Averaged Waveform from an Averager
Averaged waveforms can be read out either in Volts, or as 32-bit accumulated sums. In either case, we recommend
the use of the general-purpose read function AcqrsD1_readData, rather than the obsolete function
AcqrsD1_readRealWform.
3.11.5.1. Averaged Waveforms in Volts
You should use the general-purpose function AcqrsD1_readData. As long as the mode is still set to averager, either
function automatically divides the accumulated waveform sum by the number of acquired waveforms, and returns
the result in Volts. They also return zero into the variables horPos, tStampLo and tStampHi, since they are irrelevant
in the context of an averaged waveform.
Use this code fragment for the general-purpose function: