cbDInScan()

Performs multiple reads of a digital input port on a device with a pacer clock.

Function Prototype

C/C++

int cbDInScan(int BoardNum, int PortType, long Count, long *Rate, int MemHandle, int Options)

Visual Basic

Function cbDInScan(ByVal BoardNum&, ByVal PortType&, ByVal Count&, Rate&, 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.

PortType

The digital port to read, usually FIRSTPORTA or FIRSTPORTB.

Count

The number of times to read the digital port.

Rate

Number of times per second (Hz) to read the port. The actual sampling rate in some cases will vary a small amount from the requested rate. The actual rate is returned.

MemHandle

Handle for the Windows buffer to store data. This buffer must have been previously allocated with cbWinBufAlloc()or cbWinBufAlloc32().

Options

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

Returns

Options argument values

BACKGROUNDIf the BACKGROUND option is not used then the cbDInScan() function will not return to your program until all of the requested data has been collected and returned to MemHandle.

When the BACKGROUND option is used, control returns immediately to the next line in your program and the transfer from the digital input port to MemHandle will continue in the background. Use cbGetStatus() with DIFUNCTION to check on the status of the background operation. Use cbStopBackground() with DIFUNCTION to terminate the background process before it has completed.
BLOCKIOData 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.
CONTINUOUSThis option puts the function in an endless loop. Once it transfers the required number of bytes it resets to the start of DataBuffer and begins again. The only way to stop this operation is with cbStopBackground() with DIFUNCTION. Normally this option should be used in combination with BACKGROUND so that your program will regain control.
DWORDXFERNormally this function reads a single (byte) 16-bit port. When DWORDXFER is specified, this function reads two adjacent 16-bit ports at a time, and stores the value of both ports together as the low and high byte of a single array element in the buffer. It is usually required to set PortType to AuxPort0.
EXTCLOCKIf this option is used then transfers will be controlled by the signal on the trigger input line rather than by the internal pacer clock. Each transfer will be triggered on the appropriate edge of the trigger input signal (refer to board-specific information in the Universal Library User's Guide). When this option is used the Rate argument is ignored. The transfer rate is dependent on the trigger signal.
EXTTRIGGERIf this option is used, then the scan will not begin until the signal on the trigger input line meets the trigger criteria.
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).
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 digital input samples to acquire per trigger - this is the trigger count. The RETRIGMODE option can be used with the CONTINUOUS option to continue arming the trigger until cbStopBackground() is called.

You specify the trigger count with the cbSetConfig() ConfigItem option BIDITRIGCOUNT. If you specify a trigger count that is either zero or greater than the value of the cbDInScan() Count argument, the trigger count is 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.
SINGLEIOData is transferred to memory one sample at a time. Rates attainable using SINGLEIO are PC-dependent and generally less than 4 kHz.
WORDXFERNormally this function reads a single (byte) 8-bit port. When WORDXFER is specified, this function reads two adjacent 8-bit ports at a time, and stores the value of both ports together as the low and high byte of a single array element in the buffer. It is usually required to set PortType to FIRSTPORTA.

Note