Tbkrdnback – Measurement Computing TempBook rev.3.0 User Manual
Page 71

TempBook User’s Manual
tbkCommand Reference (Standard API) 9-11
tbkRdNBack
DLL Function
int tbkRdNBack(uint *buf, uint count, uchar cycle, uchar update Single);
C
tbkRdNBack(unsigned _far *buf, unsigned count, unsigned char cycle, unsigned
char updateSingle);
QuickBASIC
BtbkRdNBack% (buf%, ByVal count%, ByVal cycle%, ByVal updateSingle%)
Visual Basic
VBtbkRdNBack% (buf%(), count%, cycle%, updateSingle%)
Turbo Pascal
tbkRdNBack( buf:WordP; count:word; cycle:byte; updateSingle:byte ):integer;
Parameters
uint *buf
An array where the A/D scans will be placed
uint count
The number of scans to be taken
Valid values: 1 - 32767
uchar cycle
A flag that if non-zero will enable continuous operation, or if 0 will disable it
uchar updateSingle
A flag that if non-zero will enable single scans to be read into buf or if 0 will enable buf to be updated in
a block of 256 scans
Returns
TerrMultBackXfer
- Background read already in progress
TerrNoError
- No error
See Also
tbkGetBackStat, tbkBackStop, tbkSetTag, tbkSetClk, tbkSetTrig
Program References
None
tbkRdNBack
reads multiple A/D scans in the background using interrupts. This function will
return control back to the user’s program after initiating the background transfer. The user can then
monitor the status of the background transfer with the tbkGetBackStat function or stop the
transfer with the tbkBackStop function. Because the transfer occurs in the background, the user
can perform other tasks in the foreground. This function assumes that the A/D acquisition has
already been setup.
If the cycle flag is true, the background transfer will run continuously looping back to the beginning
of ‘buf’ after ‘count’ scans have been read. This allows the user to read large amounts of data
without calling tbkRdNBack multiple times. As long as the user monitors how much data is in the
buffer and processes the data before it gets overwritten, the background transfer can run indefinitely.
In this mode, the user should get the total number of scans written into ‘buf’ using
tbkGetBackStat
and keep track of the total number of scans processed in a variable. The
difference between these two totals is the number of unprocessed valid scans in ‘buf’ that the user
can process.
Note: the Visual Basic chapter includes an example program which demonstrates how to use the
cycle mode of tbkRdNBack.
The updateSingle flag allows the user to control whether the TempBook/66 updates ‘buf’ one
sample at a time or in blocks of 256 scans. Enabling updateSingle allows the user to read A/D
data during slow acquisitions as the data is acquired. Because the updateSingle flag is directly
tied to the number of interrupts that will be generated on the computer, the flag should not be
enabled if the acquisition rate is greater than roughly 500 scans per second (sampling rate * # of
channels). For example, an acquisition running at 1 Hz might enable the updateSingle flag so
that the data can be read each second rather than waiting for 256 seconds. An acquisition running at
10,000 Hz would disable the flag so the computer does not hang.