# cbAConvertPretrigData()

For products with pretrigger implemented in hardware (most products), this function converts and aligns the raw data collected by cbAPretrig(). The cbAPretrig() function can return either raw A/D data or converted data, depending on whether or not the CONVERTDATA option was used. The raw data as it is collected is not in the correct order. After the data collection is completed it must be rearranged into the correct order. This function correctly orders the data also, starting with the first pretrigger data point and ending with the last post-trigger point.

## Function Prototype

C/C++

int cbAConvertPretrigData(int BoardNum, long PretrigCount, long TotalCount, unsigned short ADData[], unsigned short ChanTags[])

Visual Basic

Function cbAConvertPretrigData(ByVal BoardNum&, ByVal PretrigCount&, ByVal TotalCount&, ADData%, ChanTags%) As Long

## Arguments

BoardNum

The number associated with the board when it was installed with InstaCal or created with cbCreateDaqDevice(). BoardNum may be 0 to 99.

PretrigCount

Number of pre-trigger samples. This value must match the value returned by the PretrigCount argument in the cbAPretrig() function.

TotalCount

Total number of samples that were collected.

ADData

Pointer to the data array. this value must match the array name used in the cbAPretrig() function.

ChanTags

Pointer to the channel tag array or a NULL pointer may be passed if using 16-bit boards or if channel tags are not desired; see the note regarding 16-bit boards below.

## Returns

- Error code or 0 if no errors.
- ADData - converted data.

## Notes

- When you collect data with cbAPretrig() and you don't use the CONVERTDATA option, you must use this function to convert the data after it is collected. There are cases where the CONVERTDATA option is not allowed, for example, if you use the BACKGROUND option with cbAPretrig() on some devices, the CONVERTDATA option is not allowed. In those cases this function should be used to convert the data after the data collection is complete.

- 12-Bit A/D boards
- On some 12-bit boards, each raw data point consists of a 12-bit A/D value with a 4-bit channel number. This function pulls each data point apart and puts the A/D value into the ADData and the channel number into the ChanTags array.
- The name of the ADData array must match that used in cbAInScan() or cbWinBufToArray().
- Upon returning from cbAConvertPretrigData(), ADData array contains only 12-bit A/D data.
- 16-Bit A/D boards
- This function is for use with 16-bit A/D boards only insofar as ordering the data. No channel tags are returned.

### Visual Basic Programmers

After the data is collected with cbAPretrig() it must be copied to an array with cbWinBufToArray().

Important: The entire array must be copied. This array includes the extra 512 samples needed by cbAPretrig(). Example code is given below:

Count& = 10000
Dim ADData%(Count& + 512)
Dim ChanTags%(Count& + 512)

cbAPretrig%(BoardNum, LowChan, HighChan, PretrigCount&, Count&...)

cbWinBufToArray%(MemHandle%, ADData%, Count& + 512)
cbAConvertPretrigData%(PretrigCount&, Count&, ADData%, ChanTags%)