Syntax, Example 1 – Echelon Neuron C User Manual

Page 24

Advertising
background image

4

Predefined Events

The reference value is the value read the last time the change event evaluated to

TRUE. For the unqualified io_changes event, the event equates to TRUE when
the current value is different from the reference value.
A task can access the input value for the I/O object through the input_value

keyword. The input_value is always a signed long.

For the bit, byte, and nibble I/O objects, changes are not latched. The change

must persist until the io_changes event is processed. The leveldetect input object
can be used to latch changes that might not persist until the io_changes event

can be processed.

Syntax

io_changes (

io-object-name

) [to

expr

| by

expr

]

io-object-name

The I/O object name (see the

I/O Model Reference

). I/O

objects of the following input object types can be used in

an unqualified change event. The by and to options can
also be used where noted.

bit

(to)

byte

(by, to)

dualslope

(by)

leveldetect

(to)

nibble

(by, to)

ontime

(by)

period

(by, to)

pulsecount

(by)

quadrature

(by)

to

expr

The to option specifies the value of the I/O state necessary
for the io_changes event to become TRUE. The compiler

accepts an unsigned long value for

expr

, where

expr

is a

Neuron C expression. However, each I/O object type has
its own range of meaningful values.

by

expr

The by

option compares the current value with the

reference value. The io_changes event becomes TRUE
when the difference (absolute value) between the current

value and the reference value is greater than or equal to

expr

.

The default initial reference value used for comparison purposes is zero. You can

set the initial value by calling the io_change_init( ) function. If an explicit
reference value is passed to io_change_init( ), that value is used as the initial

reference value: io_change_init(

io-object-name

,

value

). If no explicit value is

passed to io_change_init( ), the I/O object’s current value is used as the initial
value: io_change_init(

io-object-name

).

Example 1

IO_0 input bit push_button;

when (io_changes(push_button) to 0)
{
...

Advertising