beautypg.com

Measurement Computing Data Acquisition Systems rev.10.4 User Manual

Page 25

background image

Programmer’s Manual

988594

API Programming, General Models 2-15

Dim handle&, ret&, channels&(8), gains&(8) flags&(8)
Dim buf%(80000), active&, count&
Dim bufsize& = 10000 ‘ In scans
' Define arrays of channels and gains : 0-7 , unity gain
For x& = 0 To 7

channels&(x&) = x&

gains&(x&) = DgainX1&

flags&(x&) = DafAnalog& + DafSingleEnded& + DafUnipolar&
Next x&
' Load scan sequence FIFO
ret& = VBdaqAdcSetScan&(handle&,channels&(), gains&(), flags&(), 8)

Next, set the internal sample rate to 3 kHz.

ret& = VBdaqAdcSetFreq&(handle&,3000!)

The acquisition mode needs to be configured to be fixed-length acquisition with no pre-trigger scan data
and 10 scans of post-trigger scan data. The mode is set to

DaamInfinitePost&

, which will configure the

acquisition as having indefinite length and, as such, will be terminated by the application. In this mode, the
pre- and post-trigger count values are ignored.

ret& = VBdaqAdcSetAcq&(handle&,DaamInfinitePost&, 0, 0)

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 immediate, 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. This buffer is necessary to hold incoming
A/D data while it is being prepared for disk I/O. Since this is to be an indefinite-length transfer to a
circular buffer, the buffer cycle mode should be turned on with

DatmCycleOn&

. For efficiency, block

update mode is specified with

DatmUpdateBlock&

. The buffer size is set to 10,000 scans. The buffer

size indicates only the size of the circular buffer, not the total number of scans to be taken.

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

DatmUpDateBlock&+DatmCycleOn&)

Now the destination disk file is configured and opened. For this example, the disk file is a new file to be
created by the driver. After the following line has been executed, the specified file will be opened and
ready to accept data.

ret& = VBdaqAdcSetDiskFile&(handle&,”c:dasqdata.bin”, DaomCreateFile&, 0)

With all acquisition parameters being configured and the acquisition transfer to disk 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 and, subsequently, to the specified disk file. 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; then A/D input data will be transferred to the
specified disk file as it is being collected.

ret& = VBdaqAdcSoftTrig&(handle&)