Sensoray 2410 API User Manual
Page 19

Sensoray 24xx Programming Guide
15
Model 2410 Digital I/O Module
6.2.2 s2410_ReadDin()
Function:
Read the debounced physical states of all DIO channels.
Prototype:
BOOL s2410_ReadDin( SESSION sess, u32 *err, u16 *states );
Returns:
True if the operation was successful, otherwise False is returned and
err
will contain the associated error code.
Notes:
Every DIO channel includes a monitoring circuit that enables that channel’s physical state to be read. This function
acquires a snapshot of the physical state of each channel without regard for whether the channel is driven by its
on-board output driver or by an externally generated signal.
Physical states are sampled in parallel (all 48 channels are sampled simultaneously) at one millisecond intervals.
Sample data are passed through a debounce filter which may cause latency or, in the case of rapidly changing
physical states, undetected state changes. Consequently, the values returned in
states[]
may not accurately reflect
the instantaneous physical states of channels that have changed within the debounce interval.
Example:
// Read and display the debounced input states of all DIO channels.
u16 states[3];
u32 err = ERR_NONE;
if
( !s2410_ReadDin( sess, &err, states ) )
printf( "Error: %s\n", s24xx_ErrorText(err) );
else
printf( "input states: %04x %04x %04x\n", states[2], states[1], states[0] );
6.2.3 s2410_ReadDout()
Function:
Read the programmed output states of all DIO channels.
Prototype:
BOOL s2410_ReadDout( SESSION sess, u32 *err, u16 *states );
Returns:
True if the operation was successful, otherwise False is returned and
err
will contain the associated error code.
Notes:
This function reads the programmed states of all DIO output drivers. Note that these states may differ from those
returned by
s2410_ReadDin()
because channels can be driven by off-board signals as well as on-board drivers.
Also, in the case of channels operating in PWM output mode, the instantaneous driver states are determined by
each channel’s PWM generator.
Example:
// Get all DIO output states.
u16 states[3];
u32 err = ERR_NONE;
Argument
Description
sess
Session handle obtained from
s24xx_SessionOpen()
.
err
Pointer to error code. See Section 4.3.1 for details.
states
Pointer to an array that will receive the state values. Each bit has the following
meaning:
1 - active state (driven low by on-board driver or off-board signal).
0 - inactive state (pulled high).
Argument
Description
sess
Session handle obtained from
s24xx_SessionOpen()
.
err
Pointer to error code. See Section 4.3.1 for details.
states
Pointer to an array that will receive the state values. Each bit has the following
meaning:
1 - active state (driven low by on-board driver).
0 - inactive state (pulled high by on-board driver or driven low by off-board signal).