Measurement Computing WaveBook rev.3.0 User Manual
Page 152

8-18 Theory of Operation,
6-24-99
WaveBook User’s Manual
Using data packing (WaveBook/512 only), every 4 samples take 3 integers—thus, the buffer must be at
least (3/4)*(samples-per-scan)*(scanCount words) long. Also, the buffer must hold a whole number of
4-sample groups of packed data. The number of samples in the buffer must be a multiple of 4—(samples-
per-scan)*(scanCount words). See previous table for examples of buffer sizes.
The cycle argument is Boolean (true or false) and specifies if, after the buffer is full, new data is allowed
to overwrite old data already in the buffer.
• If cycle is false, the buffer is used as a linear buffer, where samples are stored into the buffer until the
buffer is full and the transfer stops.
• If cycle is true, the buffer is used as a circular buffer, where after the buffer is full, the transfer
begins again at the beginning of the buffer, overwriting the old data.
When WaveBook transfers data into a linear buffer in the PC, it places the first sample into the first word
of the buffer and continues transferring data until the buffer is full. After the buffer is full, the transfer is
stopped, and no more samples are written to the buffer. This preserves every sample from WaveBook; none
are ever overwritten in a linear buffer.
Even with the transfer stopped, WaveBook (as configured by the acquisition mode and scan count) may still
be acquiring more scans. If more scans are taken, they are stored in WaveBook's internal buffer until they
can be transferred to the PC. Another daqAdcTransferBufData command must be used to transfer
them into the PC. If the transfer is not restarted soon enough, the acquired scans will eventually overflow
WaveBook's internal buffer and samples will be lost.
The following diagram shows the scans as they are transferred into the first two of several linear buffers:
First Linear Buffer
Next Linear Buffer
Scan Number
∏
∏
∏
∏
1
2
3
…
60
61
62
63
…
120
When WaveBook transfers data into a circular buffer, it continues transferring until the acquisition is
complete. If the amount of data acquired exceeds the capacity of the buffer, then the oldest samples in the
buffer are overwritten. As more samples are acquired, more of the buffer is overwritten so that the most
recent samples are always kept in the buffer. For example, if an acquisition is configured for 1000 scans
and the buffer holds only 60 scans, then the buffer will initially be filled with Scans 1 through 60. Then,
Scan 61 overwrites Scan 1; Scan 62 overwrites Scan 2; and so on until Scan 120 overwrites Scan 60. The
end of the buffer has been reached again. So, Scan 121 is stored at the beginning of the buffer, overwriting
Scan 61. As shown below, this process of overwriting and re-using the buffer continues until all 1000 scans
have been acquired.
First Data Set into Circular Buffer
Buffer Position
1
2
3
…
39
40
41
42
...
58
59
60
Scan
1
2
3
...
39
40
41
42
...
58
59
60
Second Data Set
Buffer Position
1
2
3
...
39
40
41
42
...
58
59
60
Scan
61
62
63
...
99
100
101
102
...
118
119
120
Third Data Set
Buffer Position
1
2
3
...
39
40
41
42
...
58
59
60
Scan
121
122
123
...
159
160
161
162
...
178
179
180
When the acquisition is complete, the buffer holds only Scans 941 through 1000 (first Scans 961 through
1000, then Scans 941 through 960). All of the scans preceding Scan 941 have been overwritten. At this
point, the buffer has the following contents:
Final Data Set in a Circular Buffer
Buffer Position
1
2
3
...
39
40
41
42
...
58
59
60
Scan
961
962
963
…
999
1000
941
942
…
958
959
960
In this case, because the total number of scans is not an even multiple of the buffer size, the oldest scan is
not at the beginning of the buffer and the last scan is not at the end of the buffer. For easier processing, the
daqAdcBufferRotate
command can arrange the buffer so that the oldest scan is at the beginning of the
buffer (and the last is at the end).
daqAdcBufferRotate
only works on unpacked data (one sample per 16-bit word). If the buffer were
transferred as packed data (with WaveBook/512 only), then daqCvtRawDataFormat must first be used
to unpack the buffer. After daqCvtRawDataFormat (if necessary) and daqAdcBufferRotate have
been used, the buffer will be unpacked with the scans in their natural order from oldest to newest (first to
last).