Measurement Computing TempBook rev.3.0 User Manual
Page 107

TempBook User’s Manual
Enhanced API Programming Models (TempBook) 10-11
Indefinite Acquisition, Direct-To-Disk Using Circular Buffers
This program demonstrates the use of circular buffers in cycle mode to collect analog input data directly to
disk. In cycle mode, this data transfer can continue indefinitely. When the transfer reaches the end of the
physical data array, it will reset its array pointer
back to the beginning of the array and continue
writing data to it. Thus, the allocated buffer
can be used repeatedly like a FIFO buffer.
Unlike the Standard API, the Enhanced API has
built-in direct-to-disk functionality. Therefore,
very little needs to be done by the application
to configure direct-to-disk operations.
First, the acquisition is configured by setting up
the channel scan group configuration, the
acquisition frequency, the acquisition trigger
and the acquisition mode. Once configured, the
transfer to disk is set up and the acquisition is
then armed by calling the daqAdcArm
function.
At this point, the Daq* device trigger is armed
and A/D acquisition to disk will begin
immediately upon trigger detection.
This example will retrieve an indefinite amount
of scans for channels 0 through 7, triggered via
software with a 3000 Hz sampling frequency
and unity gain. Functions used include:
•
VBdaqAdcSetScan&(handle&,
startChan&, endChan&, gain&,
flags&)
•
VBdaqAdcSetFreq&(handle&,freq!
)
•
VBdaqAdcSetTrig&(handle&,
triggerSource&, rising&,
level%, hysteresis%,channel&)
•
VBdaqAdcSetAcq&(handle&,mode&,
preTrigCount&,postTrigCount&)
•
VBdaqAdcTransferSetBuffer&(han
dle&,buf%(), scanCount&,
transferMask&)
•
VBdaqAdcTransferStart&(handle&)
•
VBdaqAdcTransferGetStat&(handle&,status&,retCount&)
•
VBdaqAdcWaitForEvent&(handle&,daqEvent&)
•
VBdaqAdcSetDiskFile&(handle&,filename$,openMode&,preWrite&)
This program will initialize the Daq* hardware, then take readings from the analog input channels in the
base unit (not the expansion cards) and store them to disk automatically. The following lines demonstrate
channel scan group configuration using the daqAdcSetScan command. Note: flags may be channel-
specific.
Dim handle&, ret&, channels&(8), gains&(8) flags&(8)
Dim buf%(80000), active&, count&
Dim bufsize& = 10000 ‘ In scans