3 s826_dioinputread, 4 s826_diosafewrite, S826_dioinputread – Sensoray 826 User Manual
Page 57: S826_diosafewrite, S826_dioinputread)
Remarks
This function returns the output register states. Note that the returned values may not be the same as the physical I/O
pin states in the case of pins that are externally driven or routed to a counter channel's output signal.
8.3.3 S826_DioInputRead
The S826_DioInputRead function reads the physical states of all DIO channel I/O pins.
int S826_DioInputRead(
uint board, // board identifier
uint data[2] // pointer to data buffer
);
Parameters
board
826 board number. This must match the settings of the board's dip switches as described in section 2.2.
data
Pointer to a buffer (see Section 8.3) that will receive the physical I/O pin states.
Return Values
If the function succeeds, the return value is zero.
If the function fails, the return value is an error code.
Remarks
This function returns the sampled physical states of all DIO pins in the data buffer.
If this function is called immediately after calling S826_DioOutputWrite, the read data (sampled pin states) may not
accurately reflect the previously written data. This happens because the DIO pins are driven by open-drain buffers with
pull-up resistors. A pin will change state quickly when driven low, but when it is switched high, the state cannot change
as quickly because additional time is required for the circuit capacitance to be charged through the pull-up resistor. The
amount of time required for this depends on circuit capacitance; it can be shortened by decreasing the capacitance or by
decreasing the pull-up resistance (by adding an external pull-up resistor).
In some applications, it may be desirable to have a DIO write function that will not return until all pins are stable. This
can be implemented by calling S826_DioOutputWrite, and then polling with S826_DioInputRead until the expected
states are read.
8.3.4 S826_DioSafeWrite
The S826_DioSafeWrite function programs the DIO Safe registers.
int S826_DioSafeWrite(
uint board, // board identifier
uint data[2], // pointer to safemode data
uint mode // 0=write, 1=clear bits, 2=set bits
);
Parameters
board
826 board number. This must match the settings of the board's dip switches as described in section 2.2.
data
Pointer to data array (see Section 8.3) to be programmed into the Safe registers.
mode
Write mode for data: 0 = write, 1 = clear bits, 2 = set bits (see “Atomic Read-Modify-Write”).
826 Instruction Manual
52
Digital I/O