beautypg.com

Daqadcbufferrotate – Measurement Computing Data Acquisition Systems rev.10.4 User Manual

Page 59

background image

daqAdcBufferRotate

Also See: daqAdcTransferGetStat,

daqAdcTransferSetBuffer

Format

daqAdcBufferRotate(handle, buf, scanCount, chanCount, retCount)

Purpose

daqAdcBufferRotate

linearizes a circular buffer acquired via a transfer in cycle mode.

Parameter Summary

Parameter Type

Description

handle DaqHandleT

Handle to the device whose ADC transfer buffer will be rotated

buf PWORD Pointer to the buffer being rotated
scanCount DWORD

Total number of scans in the buffer

chanCount DWORD

Number of channels in each scan

retCount DWORD

Last value returned in the retCount parameter of the
daqAdcTransferGetStat

function

Parameter Values

handle:

obtained from the daqOpen function

buf:

must be a valid pointer to memory whose size is at least equal to

(scanCount * chanCount * 2)
scanCount:

valid length of buffer from 1 to 4,294,967,295 scans; however, memory limitations apply

chanCount:

defined by channel configuration; see daqAdcSetScan for details

retCount:

valid range of 1 to 4,294,967,295

Returns

DerrNoError

No error

Function Usage

This function will organize the circular buffer chronologically. In other words, it will order the data from
oldest-first to newest-last in the buffer. daqAdcBufferRotate is used primarily with pre-trigger scans

When scans are configured using daqAdcTransferSetBuffer with a DatmCycleOn value for the
transferMask

parameter, the buffer is set up as a circular buffer--once it is full, it is re-used, starting at the

beginning of the buffer. Thus, when the acquisition is complete, the buffer may have been written over many
times and the location of the last acquired scan may be at any point within the buffer.

For example, suppose a buffer is set to hold 60 scans, and an acquisition of 1000 scans is triggered. The buffer
is first filled with scans 1 through 60. Once the end of the buffer is reached, new scans are written at the
beginning of the buffer: scan 61 overwrites scan 1, scan 62 overwrites scan 2, and so on, until scan 120
overwrites scan 60. At this point, the end of the buffer has been reached again--so, scan 121 is stored at the
beginning of the buffer, overwriting scan 61. This process of writing and overwriting the buffer continues until
all 1000 scans have been acquired. At this point, the buffer has the following contents:

Buffer Position

1 2 3 ... 39 40 41 42 ... 59 59 60

Scan

961 962 963 ... 999 1000

941 942 ... 958 959 960

Since the total number of scans is not an even multiple of the buffer size, the oldest scan is not at the beginning
of the buffer, and the last scan is not at the end of the buffer. The daqAdcBufferRotate function can
rearrange the scans into a more natural order, writing the final scan into the final buffer position. This results in
the follwoing arrangement:

Programmer’s Manual

908594

Daq API Command Reference 4.2-3