Pre-installed application - controlling via digital inputs

Digital inputs of the router can be used to change the running direction of the counter (see here) or reset it.

Configuration of the running direction

The running direction is defined by the flag flag4 - Counter_Direction. If the flag has the value 1, the counter will be increased each second by 1; if the flag has the value 0, the counter is stopped; if the flag has the value -1, the counter will be decreased each second by 1.

Digital input IN1 of the router sets the value of the flag.

To achieve this, two events are configured. One that increases the flag flag4 - Counter_Direction by 1 with each closure of the digital input IN1 (connecting IN1 to VCC), and one that sets flag4 - Counter_Direction to -1 again with each exceeding of the value 1 by this flag. Thus, the counter cycles with each closure of the inputs between -1 (decrease counter), 0 (stop counter) and 1 (increase counter).

Menu Data pointsDigital I/Os

The data point input1 for digital input 3.1 of the router (IN1) is added here.

de app counter inputs

Menu Events → edit Counter_Direction_Event ()

An event is added here, which triggers an action with each change of the data point input1 - Counter_Direction to HIGH (closing the digital input IN1), which increments the value of data point flag4 - Counter_Direction by the value 1.

de app counter event direction

Menu Events → edit Counter_Direction_Rollover_Event ()

An event is added here, which triggers an action with each exceeding of the value by the data point flag4 - Counter_Direction, which sets the value of data point flag4 - Counter_Direction to the value -1.

de app counter event direction rollover

Configuration of the reset

Digital input IN2 of the router resets the counter.

To achieve this, an event is configured, which (re)sets the flag flag3 - Counter to 0 with each closure of the digital input IN2 (connecting IN1 to VCC).

Menu Data pointsDigital I/Os

The data point input2 for digital input 3.2 of the router (IN2) is added here.

de app counter inputs

Menu Events → edit Counter_Direction_Event ()

An event is added here, which triggers an action with each change of the data point input2 - Counter_Reset to HIGH (closing the digital input IN2), which sets the value of data point flag3 - Counter to the value 0.

de app counter event reset