C-12, Background acquisition – Measurement Computing WaveBook rev.3.0 User Manual
Page 186
C-12 daqX API - Programming Models,
6-22-99
WaveBook 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("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 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&)
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&)
daqAdcSetAcq
daqAdcTransferSetBuffer
daqAdcSetMux
daqAdcTransferStart
daqAdcSetTrig
daqAdcArm
daqAdcSetFreq
daqAdcSoftTrig
daqAdcTransferGetStat
daqAdcTransferGetStat
Has any data
been transferred?
No
No
Yes
Yes
Is acquisition
complete?
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."
Now the data can be displayed or manipulated:
Print "Data acquired:"
For i& = 0 To channels& - 1
Print "Channel"; i& + 1; "Data:";
For j& = 0 To scans& - 1
Print Tab(j& * 7 + 17); buf%(j& * channels& + i&);
Next j&
Print
Next i&
Finally, close the device:
ret& = VBdaqClose(handle&)