beautypg.com

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

Page 29

background image

Sensoray 24xx Programming Guide

25

Model 2426 Multi-Function I/O Module

Chapter 7: Model 2426 Multi-Function I/O Module

7.1 Overview

The API functions in this chapter can be used to monitor and control Model 2426 multi-function I/O modules. These functions are
only applicable to Model 2426 I/O modules; attempting to call them for other I/O module types will result in a

ERR_SHELLCOMMAND

transaction error.

7.2 Digital I/O Functions

7.2.1 s2426_SetDebounceTime()

Function:

Program the debounce time interval of one digital input channel.

Prototype:

BOOL s2426_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 switches to the active state,

s2426_ReadDin()

will not

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

s2426_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

( !s2426_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

Channel number in the range 0 to 7.

msec

Debounce time interval in milliseconds: 0 to 255.