Double buffering – Measurement Computing TempBook rev.3.0 User Manual
Page 117

TempBook User’s Manual
Enhanced API Programming Models (TempBook) 10-21
Double Buffering
This example demonstrates using double buffering in the
background mode, so that data can be read into one buffer
while the another buffer can be processed in the
foreground. Functions used include:
•
VBdaqAdcArm&(handle&)
•
VBdaqAdcBufferTransfer(buf1%(0),
BLOCK&, 0, 0, 0, tmpActive&,
tmpRetCount&)
•
VBdaqAdcSetAcq&(handle&, DaamNShot&, 0,
scans&)
•
VBdaqAdcSetFreq&(handle&, freq!)
•
VBdaqAdcSetMux&(handle&, 1, channels&,
DgainX1&, DafAnalog&+DafUnipolar&)
•
VBdaqAdcSetTrig(handle&, DatsSoftware&,
rising&, level%, HYSTERESIS%, 1)
•
VBdaqAdcSoftTrig&(handle&)
•
VBdaqAdcTransferGetStat(handle&,
active&, retCount&)
•
VBdaqAdcTransferSetBuffer(handle&,
buf0%(), BLOCK&,
DatmCycleOff& + DatmUpdateSingle&)
•
VBdaqAdcTransferStart(handle&)
•
VBdaqClose(handle&)
•
VBdaqOpen("TempBook0")
•
VBdaqSetErrorHandler(handle&, 100)
The following constants define the number of channels and
other acquisition parameters:
Const channels& = 8
Const scans& = 20000
Const BLOCK& = 1000
Const freq! = 5000#
Const level% = 0
Const HYSTERESIS% = 0
Const rising& = 0
Dimension 2 buffers for double buffering:
Dim buf0%(channels& * BLOCK&)
Dim buf1%(channels& * BLOCK&)
Set error handler and initialize TempBook:
handle& = VBdaqOpen("TempBook0")
ret& = VBdaqSetErrorHandler(handle&,
100)
On Error GoTo ErrorHandlerADC7
Set the acquisition to NShot on trigger and the post-
trigger scan count:
ret& = VBdaqAdcSetAcq&(handle&,
DaamNShot&, 0, scans&)
Set the scan configuration for unity gain, from channels 1
to 8, in analog unipolar mode:
ret& = VBdaqAdcSetMux&(handle&, 1,
channels&, DgainX1&,
DafAnalog&+DafUnipolar&)
Set the post-trigger scan rate:
ret& = VBdaqAdcSetFreq&(handle&, freq!)
Set the trigger source to a software trigger command:
ret& = VBdaqAdcSetTrig(handle&,
DatsSoftware&, rising&, level%,
HYSTERESIS%, 1)
Arm the acquisition:
ret& = VBdaqAdcArm&(handle&)
Set up the first buffer for BLOCK scans, with cycle mode off and update single on: