# c_in_scan()

Scans a range of counter channels, and stores the samples in an array.

## Prototype

c_in_scan(board_num, first_ctr, last_ctr, count, rate, memhandle, options)

## Parameters

board_num (int)

The number associated with the board when it was installed with InstaCal or created with create_daq_device().

first_ctr (int)

First counter channel of the scan. This parameter is zero-based, so the first counter number is "0".

last_ctr

Last counter channel of the scan. This parameter is zero-based, so the first counter number is "0".

TThe maximum allowable channel for both first_ctr and last_ctr depends on how many scan counters are available on the device in use.

count (int)

The total number of counter samples to collect. If more than one channel is being sampled then the number of samples collected per channel is equal to count / (last_ctr – first_ctr + 1)

rate (int)

The rate at which samples are taken in samples per second. The actual sampling rate in some cases will vary a small amount from the requested rate. The actual rate is returned.

memhandle (int)

The handle for the Windows buffer to store data. This buffer must have been previously allocated with win_buf_alloc_32().

options (ScanOptions)

Flags that control various options. May contain any combination of non-contradictory choices in the "options parameter values" section below.

## Returns

- The actual rate set, which may be different from the requested rate because of pacer limitations. (int)

### options parameter values

BACKGROUND | When the BACKGROUND option is used, control returns immediately to the next line in your program and the data collection from the counters into the buffer continues in the background. If the BACKGROUND option is not used, the c_inScan() function does not return to your program until all of the requested data has been collected and returned to the buffer. Use get_status() with CTRUNCTION to check on the status of the background operation. Use stop_background() with CTRFUNCTION to terminate the background process before it has completed. Execute stop_background() after normal termination of all background functions in order to clear variables and flags.
BLOCKIO | A/D transfers are handled in blocks (by REP-INSW for example). BLOCKIO is not recommended for slow acquisition rates. If the rate of acquisition is very slow (for example less than 200 Hz) BLOCKIO may not be the best transfer mode, as the operation status is not available until one packet of data is collected (typically 512 samples). For example, when acquiring 100 samples at 100 Hz using BLOCKIO, the operation will not complete until 5.12 seconds has elapsed.
CONTINUOUS | This option puts the function in an endless loop. Once it collects the required number of samples, it resets to the start of the buffer and begins again. The only way to stop this operation is by using stop_background() with CTRFUNCTION. Normally, you should use this option with BACKGROUND so that your program regains control.
CTR16BIT | Sets the counter resolution to 16-bits. When using devices that return data in a 16-bit format, create the buffer using win_buf_alloc().
CTR32BIT | Sets the counter resolution to 32-bits. When using devices that return data in a 32-bit format, create the buffer using win_buf_alloc_32().
CTR48BIT | Sets the counter resolution to 48-bits. When using devices that return data in a 64-bit format, create the buffer using win_buf_alloc_64().
CTR64BIT | Sets the counter resolution to 64-bits. When using devices that return data in a 64-bit format, create the buffer using win_buf_alloc_64().
EXTCLOCK | If this option is specified, conversions will be controlled by the signal on the external clock input rather than by the internal pacer clock. Each conversion will be triggered on the appropriate edge of the clock input signal; refer to board-specific information. When this option is used the rate parameter is ignored. The sampling rate is dependent on the clock signal. Options for the board will default to a transfer mode that will allow the maximum conversion rate to be attained unless otherwise specified.
EXTTRIGGER | If this option is specified, sampling does not begin until the trigger condition is met. You can set the trigger condition to rising edge, falling edge, or the level of the digital trigger input with the set_trigger(); refer to board-specific information.
HIGHRESRATE | Acquires data at a high resolution rate. When specified, the rate at which samples are acquired is in "samples per 1000 seconds per channel". When this option is not specified, the rate at which samples are acquired is in "samples per second per channel" (refer to the rate parameter above).
NOCLEAR | Disables the clearing of counters when the scan starts.
RETRIGMODE | Re-arms the trigger after a trigger event is performed. With this mode, the scan begins when a trigger event occurs. When the scan completes, the trigger is re-armed to acquire the next the batch of data. You can specify the number of samples in the scan for each trigger event (described below). The RETRIGMODE option can be used with the CONTINUOUS option to continue arming the trigger until stop_background() is called. You can specify the number of samples to acquire with each trigger event. This is the trigger count (retrigCount). Use the set_config() ConfigItem option BICTRTRIGCOUNT to set the trigger count. If you specify a trigger count that is either zero or greater than the value of the count parameter, the trigger count is set to the value of the count parameter. Specify the CONTINUOUS option with the trigger count set to zero to fill the buffer with count samples, re-arm the trigger, and refill the buffer upon the next trigger.
SINGLEIO | A/D data is transferred to memory one sample at a time. Rates attainable using SINGLEIO are PC-dependent and generally less than 4 kHz.