# daq_in_scan()

Scans analog, digital, counter, and temperature input channels synchronously, and stores the samples in an array. This function only works with boards that support synchronous input.

## Prototype

daq_in_scan(board_num, chan_list, chan_type_list, gain_list, chan_count, rate, pretrig_count, total_count, memhandle, options)

## Parameters

board_num (int)

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

chan_list (list of int or DigitalPortType)

List containing channel values. Valid channel values are analog input channels, digital ports, counter input channels, and temperature input channels of the device.

chan_type_list (list ofChannelType)

List containing channel types. Each element of this list defines the type of the corresponding element in the chan_list. Set to one of the constants in the chan_type_list parameter value section below.

gain_list (list of ULRange)

List containing A/D range codes. If the corresponding element in the chan_list is not an analog input channel, the range code for this channel is ignored.

chan_count (int)

Number of elements in each of the three lists - chan_list, chan_type_list, and gain_list.

rate (int)

The sample rate at which samples are acquired, in samples per second per channel.

The actual sampling rate in some cases will vary a small amount from the requested rate. The actual rate is returned.

pretrig_count (int)

Sets the number of pre-trigger samples to collect. Specifies the number of samples to collect before the trigger occurs. This function won’t run in pre-trigger mode if pre_trig_count is set to zero. pre_trig_count is ignored if the EXTTRIGGER option is not specified.

The actual pre-trigger count set will be the second value returned, which may be different from the requested pre-trigger count, because pre-trigger count must be a multiple of chan_count.

pre_trig_count must be evenly divisible by the number of channels being scanned (chan_count). If it is not, this function adjusts the number (up) to the next valid value, and returns that value as the second return value.

total_count (int)

Total number of samples to collect. Specifies the total number of samples to collect and store in the buffer. total_count must be greater than pretrig_count.

The actual total_count set will will be the third value returned, which may be different from the requested total count because total count must be a multiple of chan_count.

total_count must be evenly divisible by the number of channels being scanned (chan_count). If it is not, this function adjusts the number (down) to the next valid value, and returns that value as the third return value.

memhandle (int)

Handle for the Windows buffer to store data. This buffer must have been previously allocated. For 16-bit data, create the buffer with win_buf_alloc(). For data that is > 16-bit and ≤ 32-bit, use win_buf_alloc_32(). For data that is > 32-bit and ≤ 64-bit, use win_buf_alloc_64(). When using scaled data, use scaled_win_buf_alloc().

options

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

## Returns

- actual_rate (int) – The actual rate set, which may be different from the user specified rate due to pacer limitations.
- actual_pretrig_count (int) – The actual pretrig count (see pretrig_count parameter).
- actual_total_count (int) – The actual total count (see total_count parameter).

### chan_type_list parameter values

ANALOG | Analog input channel.
DIGITAL | Digital port; not programmable.
DIGITAL8 | 8-bit digital input port.
DIGITAL16 | 16-bit digital input port. (FIRSTPORTA only)
PADZERO | Placeholder channel; fills the corresponding data elements with zero.
CJC | CJC channel.
CTR16 | 16-bit counter.
CTR32LOW | Lower 16-bits of a 32-bit counter.
CTR32HIGH | Upper 16-bits of a 32-bit counter.
CTRBANK0 | Bank 0 of a counter.
CTRBANK1 | Bank 1 of a counter.
CTRBANK2 | Bank 2 of a counter.
CTRBANK3 | Bank 3 of a counter.
SETPOINTSTATUS | The setpoint status register. This is a bit field indicating the state of each of the setpoints. A "1" indicates that the setpoint criteria has been met.
SETPOINT_ENABLE | Enables a setpoint. When this option is specified, it must be OR’ed with the chan_type_list parameter values. You set the setpoint criteria with the daq_set_setpoints() function. The number of channels set with the SETPOINT_ENABLE flag must match the number of setpoints set by the daq_set_setpoints() setpoint_count parameter.
TC | Thermocouple channel. The get_tc_values() function can be used to convert raw thermocouple data to data on a temperature scale (CELSIUS, FAHRENHEIT, or KELVIN). Note: If at least one TC channel is listed in the channel array, and averaging is enabled for that channel, the averaging will be applied to all of the channels listed in the channel array.

### options parameter values

BACKGROUND | When the BACKGROUND option is used, control returns immediately to the next line in your program, and the data collection into the buffer continues in the background. If the BACKGROUND option is not used, daq_in_scan() does not return control to your program until all of the requested data has been collected and returned to the buffer. Use get_status() with DAQIFUNCTION to check on the status of the background operation. Use stop_background() with DAQIFUNCTION 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 is probably not the best choice for transfer mode. The reason for this is that status for the operation is not available until one packet of data has been collected (typically 512 samples). The implication is that if 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 DAQIFUNCTION. Normally this option should be used in combination with BACKGROUND so that your program will regain control.
EXTCLOCK | 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. 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 | Sampling will not begin until the trigger condition is met; refer to set_trigger().
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.
SINGLEIO | A/D transfers to memory are initiated by an interrupt. One interrupt per conversion. Rates attainable using SINGLEIO are PC-dependent and generally less than 10 kHz.

## Returns

- actual_rate (int) – The actual rate set, which may be different from the requested rate because of pacer limitations.
- actual_pretrig_count (int) – The actual pretrig count (see pretrig_count parameter)
- actual_total_count (int)– The actual total count (see total_count parameter)