cbDaqInScan()

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.

Function Prototype

C/C++

int cbDaqInScan(int BoardNum, short ChanArray[], short ChanTypeArray[], short GainArray[], int ChanCount, long* Rate, long *PretrigCount, long *TotalCount, int MemHandle, int Options);

Visual Basic

Function cbDaqInScan(ByVal BoardNum&, ChanArray%, ChanTypeArray%, GainArray%, ByVal ChanCount&, CBRate&, PretrigCount&, CBCount&, ByVal MemHandle&, ByVal Options&) 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. The board must support synchronous input.

ChanArray

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

ChanTypeArray

Array containing channel types. Each element of this array defines the type of the corresponding element in the ChanArray. Set to one of the constants in the "ChanTypeArray argument values" section below.

GainArray

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

ChanCount

Number of elements in each of the three arrays - ChanArray, ChanTypeArray, and GainArray.

Rate

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

Rate also returns the value of the actual rate set, which may be different from the requested rate because of pacer limitations.

PretrigCount

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 PreTrigCount is set to zero. PreTrigCount is ignored if the EXTTRIGGER option is not specified.

PreTrigCount also returns the value of the actual pre-trigger count set, which may be different from the requested pre-trigger count, because pre-trigger count must be a multiple of ChanCount.

PreTrigCount must be evenly divisible by the number of channels being scanned (ChanCount). If it is not, this function adjusts the number (up) to the next valid value, and returns that value to the PreTrigCount argument.

TotalCount

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

TotalCount also returns the value of the actual total count set, which may be different from the requested total count because total count must be a multiple of ChanCount.

TotalCount must be evenly divisible by the number of channels being scanned (ChanCount). If it is not, this function adjusts the number (down) to the next valid value, and returns that value to the TotalCount argument.

MemHandle

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

Options

Bit fields that control various options. This field may contain any combination of non-contradictory choices in the "Options argument values" section below.

Returns

ChanTypeArray argument values

ANALOGAnalog input channel.
ANALOG_SEAnalog input channel, single-ended mode.
ANALOG_DIFFAnalog input channel, differential mode.
DIGITALDigital port; not programmable.
DIGITAL88-bit digital input port.
DIGITAL1616-bit digital input port. (FIRSTPORTA only)
PADZEROPlaceholder channel; fills the corresponding data elements with zero.
CJCCJC channel.
CTRCounter channel.
CTR1616-bit counter.
CTR32LOWLower 16-bits of a 32-bit counter.
CTR32HIGHUpper 16-bits of a 32-bit counter.
CTRBANK0Bank 0 of a counter.
CTRBANK1Bank 1 of a counter.
CTRBANK2Bank 2 of a counter.
CTRBANK3Bank 3 of a counter.
SETPOINTSTATUSThe 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.
TCThermocouple channel.

The cbGetTCValues() 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.

ChanTypeArray flag values

SETPOINT_ENABLEEnables a setpoint. When this option is specified, it must be OR'ed with the ChanTypeArray argument values.

You set the setpoint criteria with the cbDaqSetSetpoints() function. The number of channels set with the SETPOINT_ENABLE flag must match the number of setpoints set by the cbDaqSetSetpoints() function's SetpointCount argument.

Options argument values

BACKGROUNDWhen 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, the cbDaqInScan() function does not return control to your program until all of the requested data has been collected and returned to the buffer.

Use cbGetStatus() with DAQIFUNCTION to check on the status of the background operation. Use cbStopBackground() with DAQIFUNCTION to terminate the background process before it has completed. Execute cbStopBackground() after normal termination of all background functions, in order to clear variables and flags.
BLOCKIOA/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.
CONTINUOUSThis 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 cbStopBackground() with DAQIFUNCTION. Normally this option should be used in combination with BACKGROUND so that your program will regain control.
EXTCLOCKConversions 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 argument 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.
EXTTRIGGERSampling will not begin until the trigger condition is met (refer to the cbDaqSetTrigger() function).
HIGHRESRATEAcquires 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 argument above).
NOCALIBRATEDATATurns off real-time software calibration for boards which are software calibrated, by applying calibration factors to the data on a sample by sample basis as it is acquired. Turning off software calibration saves CPU time during a high speed acquisition run, which may be required if your processor is less than a 150 MHz Pentium and you require an acquisition speed faster than 200 kHz. These numbers may not apply to your system. Only trial will tell for sure. DO NOT use this option if you do not have to. If this option is used, the data must be calibrated after the acquisition run with cbACalibrateData().
NOCLEARDisables the clearing of counters when the scan starts.
RETRIGMODERe-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 cbStopBackground() is called.

You can specify the number of samples to acquire with each trigger event. This is the trigger count. Use the cbSetConfig() ConfigItem option BIADTRIGCOUNT to set the trigger count. If you specify a trigger count that is either zero or greater than the value of the cbAInScan() Count argument, the trigger count will be set to the value of the Count argument.

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.
SCALEDATAConverts raw scan data — to voltage, temperature, and so on, depending upon the selected channel sensor category — during the analog input scan, and puts the scaled data directly into the user buffer. The user buffer should have been allocated with cbScaledWinBufAlloc().
Results using SCALEDATA may be slightly different from results using cbToEngUnits() near range limits, due to the nature of the calibration being applied and the internal calculation using floating count values. If this is undesirable use cbToEngUnits().
SINGLEIOA/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.