beautypg.com

Background acquisition – Measurement Computing TempBook rev.3.0 User Manual

Page 112

background image

10-16 Enhanced API Programming Models (TempBook)

TempBook User’s Manual

Background Acquisition

This example reads scans from several channels into a user-allocated
buffer in the background. 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&)

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 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)

Arm the acquisition:

ret& = VBdaqAdcArm&(handle&)

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&)
ret& = VBdaqAdcSoftTrig&(handle&)

These next few lines wait for the first data to be received, by checking the retCount value after calling
daqAdcTransferGetStat()

:

retCount& = 0
While retCount& = 0
ret& = VBdaqAdcTransferGetStat&(handle&, active&, retCount&)
Wend

With the same function, wait for the acquisition to complete:

While active& <> 0
ret& = VBdaqAdcTransferGetStat&(handle&, active&, retCount&)
Wend
Print "Acquisition complete:"; retCount&; "scans acquired."