beautypg.com

Multiple hardware scans, software triggering – Measurement Computing WaveBook rev.3.0 User Manual

Page 184

background image

C-10 daqX API - Programming Models,

6-22-99

WaveBook User’s Manual

Multiple Hardware Scans, Software Triggering

This model takes multiple scans from several channels. The functions used
here are of a lower level than the one-step functions, and more control is
allowed over the acquisition. This program exemplifies this flexibility by
individually configuring the channels and by explicitly setting up the transfer
buffer.

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 is set up and the acquisition
is then armed by calling the daqAdcArm function.

At this point, the WaveBook/Daq* device trigger is armed, and A/D
acquisition will begin immediately upon trigger detection.

This example will retrieve 10 scans for channels 0, 5, and 8, 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&,postTrigCo

unt&)

VBdaqAdcTransferSetBuffer&(handle&,buf%(), scanCount&,

transferMask&)

VBdaqAdcTransferStart&(handle&)

VBdaqAdcTransferGetStat&(handle&,status&,retCount&)

VBdaqAdcWaitForEvent&(handle&,daqEvent&)

daqAdcSetScan

daqAdcSetFreq

daqAdcSetAcq

daqAdcTransferStart

daqAdcSetTrig

daqAdcSoftTrig

daqAdcTransferSetBuffer

daqWaitForEvent

daqAdcArm

daqAdcTransferGetStat

This program will initialize the hardware, then take readings from the analog input channels in the base unit
(not the expansion cards). The following lines demonstrate channel scan group configuration using the
daqAdcSetScan

command. Note that the flags may be channel-specific.

Const freq! = 3000
Const scans& = 10
Const channels& = 3
Dim buf%(scans& * channels&)
Dim chans&(channels&), gains&(channels&), flags&(channels&)

Now set up the desired channels and their individual gains and flags.

chans&(0) = 0 ' high speed digital channel
chans&(1) = 5 ' analog channel 5
chans&(2) = 8 ' analog channel 8
' Channel gains and flags setting
For i& = 0 To channels& - 1
gains&(i&) = DgainX1& ' unity gain
flags&(i&) = DafAnalog& + DafSingleEnded& + DafUnipolar&
Next i&

Open the device, and set up the error handler. For simplicity, the error handler is not defined explicitly.
Refer to Example 1 for more information.

handle& = VBdaqOpen("WaveBook0")
ret& = VBdaqSetErrorHandler(handle&, 100)
On Error GoTo ErrorHandlerADC3

Now set the scan configuration:

ret& = VBdaqAdcSetScan&(handle&,chans&(), gains&(), flagss&(), channels&)

Next, set the internal sample rate to 3 kHz.

ret& = VBdaqAdcSetFreq&(handle&,3000!)

The acquisition mode needs to be configured to be a fixed-length acquisition with no pre-trigger scan data
and 10 scans of post-trigger scan data. The mode is set to DaamNShot&, which will configure the
acquisition as having finite length and, as such, will be terminated when the post-trigger count has been
satisfied. Once finished, the acquisition is automatically disarmed.

ret& = VBdaqAdcSetAcq&(handle&,DaamNShot&, 0, scans&)