beautypg.com

Measurement Computing TempBook rev.3.0 User Manual

Page 111

background image

TempBook User’s Manual

Enhanced API Programming Models (TempBook) 10-15

The acquisition begins upon detection of the trigger event. The trigger event is configured with
daqAdcSetTrig

. The next line defines the trigger event to be the immediate trigger source which will

start the acquisition immediately. The variable DatsSoftware& is a constant defined in DaqX.bas.
Since the trigger source is configured as software, the other trigger parameters are not needed.

ret& = VBdaqAdcSetTrig&(handle&,DatsSoftware&, 0, 0, 0, 0)

A buffer now is configured to hold the A/D data to be acquired. Since a circular buffer will not be used, the
buffer cycle mode should be turned off with DatmCycleOff&. The single update mode is specified with
DatmUpdateSingle&

. The buffer size is set to 10, the number of scans.

ret& = VBdaqAdcTransferSetBuffer&(handle&,buf%(), scans&,

DatmUpDateSingle&+DatmCycleOff&)

With all acquisition parameters and the transfer configured, the acquisition can now be armed. Once armed,
the acquisition will begin immediately upon detection of the trigger event. As in the case of the immediate
trigger, the acquisition will begin immediately upon execution of the daqAdcArm function.

ret& = VBdaqAdcArm&(handle&)

After setting up and arming the acquisition, data collection will begin upon satisfaction of the trigger event.
Since the trigger source is software, the trigger event will not take place until the application issues the
software trigger event. To prepare for the trigger event, the following line initiates an A/D transfer from the
Daq* device to the defined user buffer. No data is transferred at this point, however.

ret& = VBdaqAdcTransferStart&(handle&)

The transfer has been initiated, but no data will be transferred until the trigger event occurs. The following
line will signal the software trigger event to the driver.

ret& = VBdaqAdcSoftTrig&(handle&)

Both the acquisition and the transfer are now currently active. The transfer will continue indefinitely until
terminated by the application. The application can monitor the transfer process with the following lines of
code:

ret& = VBdaqWaitForEvent(handle&, DteAdcDone&)

Once this function returns, the acquisition as well as the data transfer has been stopped. We should check
the status one more time to get the total number of scans actually transferred to disk.

ret& = VBdaqAdcTransferGetStat(handle&,active&,retCount&)

Finally, display the results and close the device.

Print "Results of BufferTransfer:"
Print " Digital_ch_0 Analog_ch_5 Analog_ch_8"
For i& = 0 To scans& - 1
' shift the upper (valid) 8 bits of the digital input to the lower 8

bits

buf%(i& * channels&) = ((buf%(i& * channels&) And &HFF00) \ 256) And

&HFF

Print "Scan"; i& + 1; "Data:";
For j& = 0 To channels& - 1
Print Tab(j& * 14 + 17); buf%(i& * channels& + j&);
Next j&
Print
Next i&
ret& = VBdaqClose(handle&)