beautypg.com

C-15, Data packing & rotating – Measurement Computing WaveBook rev.3.0 User Manual

Page 189

background image

WaveBook User’s Manual,

6-22-99

daqX API - Programming Models C-15

Data Packing & Rotating

This section demonstrates an acquisition made up of pre-trigger and post-
trigger scans from multiple channels using a DSP-based analog trigger. It
also uses data packing and rotating. Functions used include:

VBdaqAdcArm&(handle&)

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

VBdaqAdcSetFreq&(handle&, POST_freq!)

VBdaqAdcSetRawDataFormat(handle&, DadfPacked&)

VBdaqAdcSetScan&(handle&, chans&(), gains&(),

polarities&(), channels&)

VBdaqAdcSetTrig&(handle&, DatsHardwareAnalog&,

rising&, level%, HYSTERESIS%, chans&(0))

VBdaqAdcSoftTrig&(handle&)

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

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

DatmCycleOff& + DatmUpdateSingle&)

VBdaqAdcTransferStart(handle&)

VBdaqClose(handle&)

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

BLOCK&, channels&)

VBdaqOpen("WaveBook0")

VBdaqSetErrorHandler(handle&, 100)

VBdaqWaitForEvent(handle&, DteAdcData&)

These declarations specify the number of channels, the pre- and post-scan
counts and frequencies, and block size for the acquisition:

Const channels& = 4
Const PRE_SCANS& = 5
Const POST_SCANS& = 9
Const PRE_freq! = 100#
Const POST_freq! = 200#
Const BLOCK& = (PRE_SCANS& + POST_SCANS&)

Also declared are the trigger level, hysteresis, and rising parameters:

Const level% = 0
Const HYSTERESIS% = 0
Const rising& = 0

daqAdcSetRawDataFormat

daqAdcArm

daqAdcSetAcq

daqAdcTransferSetBuffer

daqAdcSetFreq

daqAdcSoftTrig

daqAdcSetTrig

daqWaitForEvent

daqAdcSetScan

daqAdcTransferStart

daqAdcTransferGetStat

daqAdcCvtRawDataFormat

No

Has all data
been collected?

Yes

The buffer is dimensioned, as well as arrays to hold values for channels, gains, and polarities:

Dim buf%(BLOCK& * channels&)
Dim chans&(channels&), gains&(channels&), polarities&(channels&)

Initialize the arrays with the channel numbers and gains for each channel:

chans&(0) = 1 ' channel numbers
chans&(1) = 3
chans&(2) = 5
chans&(3) = 7
For i& = 0 To channels& - 1
gains&(i&) = DgainX1& ' unity gain
polarities&(i&) = 1 ' bipolar
Next i&

Now to open the device and set up the error handler:

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

Specify the packed-data format for the transfer:

ret& = VBdaqAdcSetRawDataFormat(handle&, DadfPacked&)

Configure the acquisition for Nshot, with 9 post-trigger scans:

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

Set the scan configuration using the arrays initialized earlier:

ret& = VBdaqAdcSetScan&(handle&, chans&(), gains&(), polarities&(),

channels&)