Measurement Computing WaveBook rev.3.0 User Manual
Page 182

C-8 daqX API - Programming Models,
6-22-99
WaveBook User’s Manual
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&,preTri
gCount&,postTrigCount&)
•
VBdaqAdcTransferSetBuffer&(handle&,b
uf%(), scanCount&, transferMask&)
Configure a scan
group of channels.
Set the sampling
frequency.
Configure the acquisition
to be indefinite post-
trigger.
Configure the trigger
event to be software
trigger.
Configure a circular
acquisition buffer 10,000
scans in length.
Open the disk file and
make it ready to receive
A/D Data.
Arm the acquisition.
Trigger the acquisition.
Wait for data to
become available.
Check status of transfer.
User code to determine
if transfer should stop.
Transfer is complete;
disarm the acquisition.
Initiate data transfer to
disk (no data will transfer
until trigger event occurs).
daqAdcSetTrig
daqAdcSetDiskFile
daqAdcArm
daqAdcSetScan
daqAdcSetFreq
daqAdcSetAcq
daqAdcTransferSetBuffer
daqAdcSoftTrig
daqAdcTransferStart
daqAdcWaitForEvent
daqAdcTransferGetStat
daqAdcDisarm
Yes
User
Terminator
No
•
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 that the flags may be
channel-specific.
Dim handle&, ret&, channels&(8), gains&(8) flags&(8)
Dim buf%(80000), active&, count&
Dim bufsize& = 10000 ‘ In scans
' Define arrays of channels and gains : 0-7 , unity gain
For x& = 0 To 7
channels&(x&) = x&
gains&(x&) = DgainX1&
flags&(x&) = DafAnalog& + DafSingleEnded& + DafUnipolar&
Next x&
' Load scan sequence FIFO
ret& = VBdaqAdcSetScan&(handle&,channels&(), gains&(), flags&(), 8)
Next, set the internal sample rate to 3 kHz.
ret& = VBdaqAdcSetFreq&(handle&,3000!)
The acquisition mode needs to be configured to be fixed-length acquisition with no pre-trigger scan data
and 10 scans of post-trigger scan data. The mode is set to DaamInfinitePost&, which will configure