# cbFileAInScan()

Scans a range of A/D channels and stores the samples in a disk file. cbFileAInScan() reads the specified number of A/D samples at the specified sampling rate from the specified range of A/D channels from the board. If the A/D board has programmable gain, it sets the gain to the specified range.

The collected data is returned to a file in binary format. Use cbFileRead() to load data from that file into an array. See board-specific information to determine if this function is supported on your board.

## Function Prototype

C/C++

int cbFileAInScan(int BoardNum, int LowChan, int HighChan, long Count, long *Rate, int Range, char *FileName, unsigned Options)

Visual Basic

Function cbFileAInScan(ByVal BoardNum&, ByVal LowChan&, ByVal HighChan&, ByVal Count&, Rate&, ByVal Range&, ByVal FileName$, ByVal Options&) As Long

## Arguments

BoardNum

The number associated with the board when it was installed with InstaCal or created with cbCreateDaqDevice(). The specified board must have an A/D. BoardNum may be 0 to 99.

LowChan

First A/D channel of scan

HighChan

Last A/D channel of scan

The maximum allowable channel depends on which type of A/D board is being used. For boards with both single ended and differential inputs, the maximum allowable channel number also depends on how the board is configured (for example, eight channels for differential, 16 for single-ended).

Count

Specifies the total number of A/D samples that will be collected. If more than one channel is being sampled, the number of samples collected per channel is equal to Count / (HighChan-LowChan+1).

Rate

Sample rate in samples per second (Hz) per channel. The maximum sampling rate depends on the A/D board that is being used (see Rate explanation in cbAInScan()).

Range

If the selected A/D board does not have a programmable range feature, this argument is ignored. Otherwise set the Range argument to any range that is supported by the selected A/D board. Refer to board-specific information for a list of the supported A/D ranges of each board.

FileName

The name of the file in which to store the data. If the file doesn't exist, it will be created.

Options

Bit fields that control various options. Refer to the constants in the Options argument values section below.

## Returns

- Error code or 0 if no errors.
- Rate – the actual sampling rate

### Options argument values

EXTCLOCK | If this option is used, conversions are controlled by the signal on the trigger input line rather than by the internal pacer clock. Each conversion is triggered on the appropriate edge of the trigger input signal (refer to board-specific information in the Universal Library User's Guide). Additionally, the Rate argument is ignored. The sampling rate is dependent on the trigger signal.
EXTTRIGGER | If this option is specified, the sampling does not begin until the trigger condition is met. On many boards, this trigger condition is programmable (refer to the cbSetTrigger() function and board-specific information for details) and can be programmed for rising or falling edge or an analog level. On other boards, only polled gate triggering is supported. Assuming active high operation, data acquisition commences immediately if the trigger input is high. If the trigger input is low, acquisition is held off until it goes high. Acquisition continues until NumPoints& samples are taken, regardless of the state of the trigger input. For polled gate triggering, this option is most useful if the signal is a pulse with a very low duty cycle (trigger signal in TTL low state most of the time) to hold off triggering until the pulse occurs.
DTCONNECT | Samples are sent to the DT-Connect port if the board is equipped with one.

## Notes

- OVERRUN Error - (Error code 29) This error indicates that the data was not written to the file as fast as the data was sampled. Consequently some data was lost. The value returned from cbFileGetInfo() in TotalCount is the number of points that were successfully collected.

### Important!

In order to understand the functions, read the board-specific information contained in the Universal Library User's Guide. We also urge you to examine and run one or more of the example programs supplied prior to attempting any programming of your own. Following this advice may save you hours of frustration, and wasted time.

This note, which appears elsewhere, is especially applicable to this function. Now is the time to read the board-specific information for your board. We suggest that you make a copy of that page to refer to as you read this manual and examine the example programs.