beautypg.com

1 overview, 2 digital i/o functions – Sensoray 2410 API User Manual

Page 18

background image

Sensoray 24xx Programming Guide

14

Model 2410 Digital I/O Module

Chapter 6: Model 2410 Digital I/O Module

6.1 Overview

The API functions in this chapter are used to monitor and control Model 2410 48-channel digital I/O modules. They are applicable
only to Model 2410 I/O modules. Any attempt to call them for other I/O module types will result in a

ERR_SHELLCOMMAND

transaction error.

Several of these API functions convey information for all 48 DIO channels through an array of three 16-bit words, with each bit
representing one DIO channel. In such cases, the first word (array index 0) represents DIO channels 0-15 (lsb-msb), the second
word represents channels 16-31, and the third word represents channels 32-47.

6.2 Digital I/O Functions

6.2.1 s2410_SetDebounceTime()

Function:

Program the debounce time interval of one digital input channel.

Prototype:

BOOL s2410_SetDebounceInterval( SESSION sess, u32 *err, u8 chan, u8 msec );

Returns:

True if the operation was successful, otherwise False is returned and

err

will contain the associated error code.

Notes:

Physical input states are sampled periodically at one millisecond intervals and passed through a debounce filter. A
digital input is regarded to be in a particular state only after it has held steady in that state for its debounce interval.

For example, consider the case of a digital input channel that has a 30 millisecond debounce interval. If the channel
has been in the inactive state for a long time and then it switches to the active state,

s2410_ReadDin()

will not

indicate the new (active) state until 30 milliseconds after the physical input became active. If the input goes active
and then switches to inactive before the 30 milliseconds has elapsed,

s2410_ReadDin()

will never indicate that the

input is active.

Upon boot-up, all digital inputs are configured to have a ten millisecond debounce interval by default.

Example:

// Configure channel 3 for a 50 millisecond debounce interval.

u32 err = ERR_NONE;

if

( !s2410_SetDebounceTime( sess, &err, 3, 50 ) )

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.

chan

DIO channel number: 0 to 47.

msec

Debounce time interval in milliseconds: 0 to 255.