beautypg.com

Counted acquisitions using linear buffers – Measurement Computing Personal Daq rev.6.0 User Manual

Page 123

background image

Counted Acquisitions Using Linear Buffers

This section sets up an acquisition that collects
post-trigger A/D scans. This particular example
demonstrates the setting up and collection of a
fixed-length A/D acquisition in a linear buffer.

Personal Daq User’s Manual Appendix A,

878495

API Custom Program Modules A-5

First, the acquisition is configured by setting up
the channel scan group configuration, the
acquisition frequency, the acquisition trigger
and the acquisition mode. When configured, the
acquisition is then armed by calling the
daqAdcArm

function.

At this point, the Personal Daq device trigger is
armed and A/D acquisition will begin upon
trigger detection. If the trigger source has been
configured to be DatsImmediate&, A/D
data collection will begin immediately.

This example will retrieve 10 samples from
channels 1 through 8, triggered immediately
with a 10 Hz sampling frequency and unity gain
[for Personal Daq]. Functions used include:

VBdaqAdcSetMux&(handle&,
startChan&, endChan&, gain&,
flags&)

VBdaqAdcSetRate&(handle&,
Mode&, acqState&, regRate!, actualRate!)

Set the trigger event
to be immediate.

Configure an ADC transfer
data buffer to be 10 scans
long and terminate once the
end of the buffer is reached.
Initiate a transfer into the
configured buffer.

Arm the acquisition. Since
trigger source is immediate,
the acquisition begins now.

Wait for the acquisition to
complete.

Process the data.

Define a channel
scan group.

Set the sampling
rate.

Configure a counted
acquisition for 10
post-trigger scans.

DaqAdcSetTrigEnhanced

daqAdcArm

daqWaitForEvent

daqAdcSetMux

DaqAdcSetRate

daqAdcSetAcq

daqAdcTransferSetBuffer

daqAdcTransferStart

User program code

Function VBdaqAdcSetTrigEnhanced&(handle&, triggerSources&(), gains&(),
adcRanges&(), trigSense&(), levels!(), hysteresis!(), chan&(), ChanCount&,
opstr$)

VBdaqAdcSetAcq&(handle&,mode&,preTrigCount&,postTrigCount&)

VBdaqAdcTransferSetBufferSingle&(ByVal handle&, buf!(), ByVal ScanCount&,
ByVal transferMask&)

VBdaqAdcTransferStart&(handle&)

VBdaqWaitForEvent&(handle&,daqEvent&)

This program will initialize the Personal Daq hardware, then take readings from the analog input channels
in the base unit (not the expansion channels). The functions used in this program are of a lower level than
those used in the previous section and provide more flexibility.

Dim buf!(80), handle&, ret&, flags&

The following function defines the channel scan group. The function specifies a channel scan group from
channel 1 through 8 with all channels being analog unipolar input channels with a gain of ×1. Specifying
this configuration uses PgainX1 in the gain parameter and the DafAnalog value in the flags
parameter. The flags parameter is a bit-mask field in which each bit specifies the characteristics of the
specified channel(s). Although each channel can set up independently (and different from the others) in
this example we will set them all the same.

ret& = VBdaqAdcSetMux&(handle&,1, 8, PgainX1&,

DafAnalog&+DafDifferential&+DafMeasDuration610&)

Next, set the internal sample rate to 10 Hz.

ret& = VBdaqAdcSetRate&(handle&,DarmFrequency&,DaasPostTrig&,10!,actual!)

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 DaamNShot&, which will configure the
acquisition as a fixed-length acquisition that will terminate automatically upon the satisfaction of the post-
trigger count of 10.

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

This manual is related to the following products: