Counted acquisitions using linear buffers – Measurement Computing WaveBook rev.3.0 User Manual
Page 180

C-6 daqX API - Programming Models,
6-22-99
WaveBook User’s Manual
Counted Acquisitions Using Linear Buffers
This section sets up an acquisition that collects
post-trigger A/D scans. This particular example
demonstrates the setting up and collection of a
fixed-length A/D acquisition in a linear buffer.
First, the acquisition is configured by setting up
the channel scan group configuration, the
acquisition frequency, the acquisition trigger and
the acquisition mode. When configured, the
acquisition is then armed by calling the
daqAdcArm
function.
At this point, the Daq* device trigger is armed
and A/D acquisition will begin upon trigger
detection. If the trigger source has been
configured to be DatsImmediate&, A/D data
collection will begin immediately.
This example will retrieve 10 samples from
channels 0 through 7, triggered immediately with
a 1000 Hz sampling frequency and unity gain.
Functions used include:
•
VBdaqAdcSetMux&(handle&,
startChan&, endChan&, gain&,
flags&)
•
VBdaqAdcSetFreq&(handle&,freq!)
Set the trigger event
to be immediate.
Configure an ADC transfer
data buffer to be 10 scans
long and terminate once the
end of the buffer is reached.
Initiate a transfer into the
configured buffer.
Arm the acquisition. Since
trigger source is immediate,
the acquisition begins now.
Wait for the acquisition to
complete.
Process the data.
Define a channel
scan group.
Set the sampling
frequency.
Configure a counted
acquisition for 10
post-trigger scans.
daqAdcSetTrig
daqAdcArm
daqWaitForEvent
daqAdcSetMux
daqAdcSetFreq
daqAdcSetAcq
daqAdcTransferSetBuffer
daqAdcTransferStart
User program code
•
VBdaqAdcSetTrig&(handle&, triggerSource&, rising&, level%, hysteresis%,
channel&)
•
VBdaqAdcSetAcq&(handle&,mode&,preTrigCount&,postTrigCount&)
•
VBdaqAdcTransferSetBuffer&(handle&,buf%(), scanCount&, transferMask&)
•
VBdaqAdcTransferStart&(handle&)
•
VBdaqAdcWaitForEvent&(handle&,daqEvent&)
This program will initialize the Daq* hardware, then take readings from the analog input channels in the
base unit (not the expansion cards). The functions used in this program are of a lower level than those used
in the previous section and provide more flexibility.
Const freq!=1000!
Const scans&=10
Dim buf%(BLOCK&*channels&), handle&, ret&, flags&
where
const block& = 6 and
const channels& = 8
The acquisition mode must be configured as a fixed-length acquisition with no pre-trigger scan data and 10
scans of post-trigger scan data. The mode is set to DaamNShot& to configure a fixed-length acquisition
that will terminate automatically upon the satisfaction of the post-trigger count of 10 (the value of
scans&
).
ret& = VBdaqAdcSetAcq&(handle&,DaamNShot&, 0, scans&)
The following function defines the channel scan group. The function specifies a channel scan group from
channel 1 through 8 with all channels being analog unipolar input channels with a gain of ×1. Specifying
this configuration uses DgainX1 in the gain parameter and the DafAnalog and the DafUnipolar
values in the flags parameter. The flags parameter is a bit-mask field in which each bit specifies the
characteristics of the specified channel(s). In this case, the DafAnalog and the DafUnipolar values
are added together to form the appropriate bit mask for the specified flags parameter.
ret& = VBdaqAdcSetMux&(handle&,1, channels&, DgainX1&,
DafAnalog&+DafUnipolar&)