Sensoray 2410 API User Manual
Page 33
Sensoray 24xx Programming Guide
29
Model 2426 Multi-Function I/O Module
7.3.2 s2426_ReadAout()
Function:
Read the programmed analog output level.
Prototype:
BOOL s2426_ReadAout( SESSION sess, u32 *err, s16 *setpoint );
Returns:
True if the operation was successful, otherwise False is returned and
err
will contain the associated error code.
Example:
// Read and display the programmed analog output level.
u32 err = ERR_NONE;
s16 setpoint;
if
( !s2426_ReadAout( sess, &err, &setpoint ) )
printf( "Error: %s\n", s24xx_ErrorText(err) );
else
printf( "Aout: %f Volts\n", (double)setpoint / 3276.8 );
7.3.3 s2426_ReadAdc()
Function:
Read all eight digital input channels.
Prototype:
BOOL s2426_ReadAdc( SESSION sess, u32 *err, S2426_ADC_SAMPLE *samples, BOOL timestamps );
Returns:
True if the operation was successful, otherwise False is returned and
err
will contain the associated error code.
Notes:
This function returns sample data from the module’s eight analog input channels.
Example:
// Read and display the six external analog input channels.
int i;
u32 err = ERR_NONE;
S2426_ADC_SAMPLE samp[8];
// allocate space for 8 chans
if
( !s2426_ReadAdc( sess, &err, &samp, TRUE ) )
printf( "Error: %s\n", s24xx_ErrorText(err) );
else
{
for ( i = 0; i < 6; i++ )
printf( "chan %d: %f at t=%d\n", i, samp[i].volts, samp[i].timestamp );
}
Argument
Description
sess
Session handle obtained from
s24xx_SessionOpen()
.
err
Pointer to error code. See Section 4.3.1 for details.
setpoint
Pointer to buffer that will receive the current analog output level.
Argument
Description
sess
Session handle obtained from
s24xx_SessionOpen()
.
err
Pointer to error code. See Section 4.3.1 for details.
samples
Pointer to an array of eight
S2426_ADC_SAMPLE
structures. These will be filled with
digitized sample data and, if desired, timestamps for those samples. Channels 0 through 5
measure external signals, while channels 6 and 7 measure on-board reference standards.
timestamps
Set to True to receive timestamps with digitized sample data.