Measurement Computing TempBook rev.3.0 User Manual
Page 118

10-22 Enhanced API Programming Models (TempBook)
TempBook User’s Manual
ret& = VBdaqAdcTransferSetBuffer(handle&, buf0%(), BLOCK&, DatmCycleOff& +
DatmUpdateSingle&)
Start the first transfer; the transfer will actually start upon trigger detection. In this case, the following
software trigger will start the transfer:
ret& = VBdaqAdcTransferStart(handle&)
Issue a software trigger command to the hardware to trigger the transfer:
ret& = VBdaqAdcSoftTrig&(handle&)
The next do loop swaps the active buffer back and forth from buf0 to buf1 and waits for the acquisition
to go inactive or the buffer to fill up. Swapping continues until the transfer goes inactive:
whichBuf& = 0
Do
The following line changes the current buffer:
If whichBuf& = 1 Then whichBuf& = 0 Else whichBuf& = 1
Wait for the acquisition to go inactive or the buffer to be filled:
Do
ret& = VBdaqAdcTransferGetStat(handle&, active&, retCount&)
Loop While ((active& <> 0) And (retCount& < BLOCK&))
If the previous acquisition is still active, start another transfer into the next buffer:
If (active& <> 0) Then
If whichBuf& = 0 Then
ret& = VBdaqAdcTransferSetBuffer(handle&, buf0%(), BLOCK&,
DatmCycleOff& + DatmUpdateSingle&)
ret& = VBdaqAdcTransferStart(handle&)
Otherwise, restart the transfer into the current buffer:
Else
'ret& = VBdaqAdcBufferTransfer(buf1%(0), BLOCK&, 0, 0, 0,
tmpActive&, tmpRetCount&)
ret& = VBdaqAdcTransferSetBuffer(handle&, buf1%(), BLOCK&,
DatmCycleOff& + DatmUpdateSingle&)
ret& = VBdaqAdcTransferStart(handle&)
End If
End If
Send the data into the process buffer, totals():
If (retCount& > 0) Then
Average the readings in the process buffer and print the results:
For j& = 0 To channels& - 1
totals&(j&) = 0
Next j&
For i& = 0 To retCount& - 1
For j& = 0 To channels& - 1
Decide which buffer to add the data from:
If whichBuf& = 0 Then
totals&(j&) = totals&(j&) + buf1%(i& * channels& + j&)
Else
totals&(j&) = totals&(j&) + buf0%(i& * channels& + j&)
End If
Next j&
Next i&
Display the averaged results:
Print "Averages:";
For j& = 0 To channels& - 1
Print Tab(j& * 7 + 17); Format$((5# / 32768#) * totals&(j&) /
retCount&, "#0.000");
Next j&
Print
End If
Continue the do..while loop until the acquisition goes inactive:
Loop While (active& <> 0)
Close the device before exiting:
ret& = VBdaqClose(handle&)