beautypg.com

C-20, Transfers with driver-allocated buffers – Measurement Computing WaveBook rev.3.0 User Manual

Page 194

background image

C-20 daqX API - Programming Models,

6-22-99

WaveBook User’s Manual

Transfers with Driver-Allocated Buffers

This example demonstrates the use of the new
daqAdcTransferBufData()

function. The following program reads

scans of multiple channels in the background mode and uses a software
trigger to start the acquisition. Functions used include:

VBdaqAdcArm&(handle&)

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

VBdaqAdcSetFreq&(handle&, freq#)

VBdaqAdcSetMux&(handle&, 1, channels&, DgainX1&, 1)

VBdaqAdcSetTrig&(handle&, DatsSoftware&, 0,0,0,0)

VBdaqAdcSoftTrig&(handle&)

VBdaqAdcTransferBufData(handle&, userBuf(0), 1,

DatmWait , retVal)

VBdaqAdcTransferGetStat(handle, active, retCount);

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

DatmCycleOff& + DatmUpdateSingle&)

VBdaqAdcTransferStart(handle&)

VBdaqClose(handle&)

VBdaqOpen("WaveBook0")

VBdaqSetErrorHandler(handle&, 100)

The constants used are defined as follows:

Const channels& = 8
Const scans& = 9
Const freq# = 200

As usual, the device is opened and the error handler is set up:

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

The acquisition is configured for 9 post-trigger scans and

Nshot

mode:

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

scans&)

daqAdcSetAcq

daqAdcTransferSetBuffer

daqAdcSetMux

daqAdcTransferStart

User code

daqAdcSetTrig

daqAdcArm

daqAdcSetFreq

daqAdcSoftTrig

daqAdcTransferBufData

daqAdcTransferGetStat

Has all data

been transferred?

No

Yes

Set up the scan configuration for channels 1 to 9 with a gain of ×1:

ret& = VBdaqAdcSetMux&(handle&, 1, channels&, DgainX1&, 1)

Set the post-trigger scan rates:

ret& = VBdaqAdcSetFreq&(handle&, freq#)

Set the trigger source to a software trigger command; the other trigger parameters are not needed with a
software trigger.

ret& = VBdaqAdcSetTrig&(handle&, DatsSoftware&, 0,0,0,0)

Now to set up the buffer for a background acquisition, in update single mode with cycle mode off.

ret& = VBdaqAdcTransferSetBuffer(handle&, buf%(), scans&, DatmCycleOff& +

DatmUpdateSingle&)

Start the transfer, and trigger to begin transferring data:

ret& = VBdaqAdcTransferStart(handle&)

Arm the acquisition:

ret& = VBdaqAdcArm&(handle&)

Trigger the transfer:

ret& = VBdaqAdcSoftTrig&(handle&)

Monitor the progress of the background transfer:

VBdaqAdcTransferGetStat(handle, active, retCount);
retCount=1;
while retCount<>0 do
VBdaqAdcTransferBufData(handle&, userBuf(0), 1, DatmWait , retVal)
print"Transfer in progress: “,retCount, “scans acquired."
for i=0 to CHANS