beautypg.com

C-17, Direct-to-disk transfers – Measurement Computing WaveBook rev.3.0 User Manual

Page 191

background image

WaveBook User’s Manual,

6-22-99

daqX API - Programming Models C-17

Direct-to-Disk Transfers

This example takes multiple scans from multiple channels and writes them
directly to disk in a packed-data format. Functions used are:

VBdaqAdcSetRawDataFormat&(handle&, DadfPacked&)

VBdaqAdcArm&(handle&)

VBdaqAdcSetAcq&(handle&, DaamNShot, 0, scans&)

VBdaqAdcSetDiskFile&(handle&, "adcex8.bin",

DaomAppendFile&, 0)

VBdaqAdcSetFreq&(handle&, freq!)

VBdaqAdcSetMux&(handle&, 1, channels&, DgainX1&,

DafUniPolar&+DafAnalog&)

VBdaqAdcSetTrig&(handle&, DatsSoftware&,

DatdRisingEdge&, 0, HYSTERESIS%, 1)

VBdaqAdcSoftTrig&(handle&)

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

VBdaqAdcTransferSetBuffer&(handle&, buf%(), BLOCK&,

DatmCycleOn& + DatmUpdateBlock&)

VBdaqAdcTransferStart&(handle&)

VBdaqClose&(handle&)

VBdaqCvtRawDataFormat&(buf%(), DacaUnpack, BLOCK&,

channels&, scanCount&)

VBdaqOpen&("WaveBook0")

VBdaqSetErrorHandler(handle&, 100)

File handling in MS-Windows requires calls to the windows API, so the
following constants are defined for use in those calls. For further
information, see mapiwin.h.

Const GENERIC_READ& = &H80000000
Const OPEN_EXISTING = 3
Const FILE_ATTRIBUTE_NORMAL& = &H80
Const OPEN_ALWAYS = 4
Const CREATE_ALWAYS = 2

Also define the usual constants defining scan parameters and some
declarations for file manipulation:

Const channels& = 2
Const scans& = 800
Const freq! = 200#
Const BLOCK& = 200 ' CHANNELS& * BLOCK& must be a

multiple of 4

Const HYSTERESIS% = 0
Dim buf%(channels& * BLOCK&)
Dim fileHandle&

daqAdcSetAcq

daqAdcBufferTransfer

daqAdcSetBufferTransfer

daqAdcSetMux

daqAdcTransferStart

User code to manipulate, read,

or convert binary data file

daqAdcSetTrig

daqAdcSetDiskFile

daqAdcSetFreq

daqClose

daqAdcArm

No

Yes

daqAdcTransferGetStat

daqAdcSoftTrig

Is the transfer

still active?

Dim byteCount&, wordCount&, sampleCount&, scanCount&
Dim binFile$

First set the name of the file to be used for the acquisition:

binFile = "adcex8.bin"

Open the device, and set the error handler:

handle& = VBdaqOpen&("WaveBook0")
ret& = VBdaqSetErrorHandler(handle&, 100)
On Error GoTo ErrorHandlerADC8

Enable data packing:

ret& = VBdaqAdcSetRawDataFormat&(handle&, DadfPacked&)

Set the acquisition to NShot on trigger and the post-trigger scan count:

ret& = VBdaqAdcSetAcq&(handle&, DaamNShot, 0, scans&)