beautypg.com

Transfers with driver-allocated buffers – Measurement Computing TempBook rev.3.0 User Manual

Page 122

background image

10-26 Enhanced API Programming Models (TempBook)

TempBook 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("TempBook0")

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("TempBook0")
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&)

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