Sensoray 2410 API User Manual
Page 30

Sensoray 24xx Programming Guide
26
Model 2426 Multi-Function I/O Module
7.2.2 s2426_ReadDin()
Function:
Read the debounced physical states of the eight digital input channels.
Prototype:
BOOL s2426_ReadDin( SESSION sess, u32 *err, u8 *states, u32 *timestamp );
Returns:
True if the operation was successful, otherwise False is returned and
err
will contain the associated error code.
Notes:
Each digital input channel includes a monitoring circuit that enables the on-board processor to determine the
physical state of the channel. This function acquires a snapshot of the physical state of each channel, no matter
whether the channel is driven by its own output driver or by an externally generated signal.
Physical states are sampled periodically at one millisecond intervals and passed through a debounce filter.
Consequently,
states
may not accurately reflect the state of a channel that has changed its physical state within
the debounce interval.
Example:
// Read digital input states.
u8 states;
u32 err = ERR_NONE;
if
( !s2426_ReadDin( sess, &err, &states ) )
printf( "Error: %s\n", s24xx_ErrorText(err) );
7.2.3 s2426_ReadDout()
Function:
Read the programmed states of all sixteen digital output channels.
Prototype:
BOOL s2426_GetOutputs( 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.
Example:
// Get all programmed digital output states.
u32 err = ERR_NONE;
u16 states;
if
( !s2426_ReadDout( sess, &err, &states ) )
printf( "Error: %s\n", s24xx_ErrorText(err) );
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 application buffer that will receive the physical states of the digital
input channels. Each bit is associated with one channel. For example, bit 7 is
associated with channel 7. Logic one indicates the associated channel is in the
active state (driven low), while logic zero indicates inactive state (pulled high).
timestamp
Pointer to buffer that will receive the timestamp. The timestamp is a snapshot of the
I/O module’s system timer at the moment
counts
is sampled. Set to NULL if the
timestamp is not needed. See section 5.6 for more information about timestamps.
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 application buffer that will receive the programmed states of the
digital output channels. Each bit is associated with one channel. For example,
bit 7 is associated with channel 7. Logic one indicates the associated channel
is programmed to the active state, while logic zero indicates inactive state.