Digital input/output, Checking inputs – Wavetronix Click 500 (programmable controller) (CLK-500) - Developer Guide User Manual
Page 98
Digital Input/Output
9
In this chapter
˽ Checking Inputs
˽ Setting Digital Outputs
˽ Example Code 9.1
9
TextThe Click 500 has two digital inputs, a voltage supply monitor input and two digital
outputs. The digital inputs are checked using the ClickDioCheck function; the voltage sup-
ply monitor input is checked using the ClickDioVccCheck function; and the outputs are
driven using the ClickDioSet function.
Checking Inputs
It is recommended that you check the digital inputs in a callback function registered with
the interrupt timer (see Chapter 6). This will allow you to check the inputs on a regular
schedule (about 90 times a second). It will also allow you to perform glitch filtering by re-
quiring that the inputs be on or off for several consecutive interrupts.
The digital inputs are multi-function inputs. To select the appropriate function, use DIP
switch 1 and 2 on the side of the device. Switch 1 is for input 1 and switch 2 is for input 2
(see Chapter 1).
The ClickDioCheck function is passed the input number identifier (D1 or D2) and returns
an integer that indicates the status of the corresponding input. The ClickDioVccCheck
function has no input parameters and returns an integer that indicates the status of the cor-
responding input. Depending on the type of input, the following directives can be used to
clearly interpret the return value (see Table 9.1).