Breadcrumbs

wait_digital_input()

Definition

wait_digital_input(index, val, timeout=None)

Features

This function waits until the signal value of the digital input register of the controller becomes val (ON or OFF). The waiting time can be changed with a timeout setting. The waiting time ends, and the result is returned if the waiting time has passed. This function waits indefinitely if the timeout is not set.

Parameters

Parameter Name

Data Type

Default Value

Description

index

int

-

A number 1 - 20 which means the I/O index mounted on the controller.

  • 17 - 20 are inputs of the SI1 - SI4 terminals.

val

int

-

I/O value

  • ON : 1

  • OFF : 0

timeout

float

-

Waiting time (sec)

This function waits indefinitely if the timeout is not set.

Return

Value

Description

0

Success

-1

Failed (time-out)

Exception

Exception

Description

DR_Error (DR_ERROR_TYPE)

Parameter data type error occurred

DR_Error (DR_ERROR_VALUE)

Parameter value is invalid

DR_Error (DR_ERROR_RUNTIME)

C extension module error occurred

DR_Error (DR_ERROR_STOP)

Program terminated forcefully

Example

Python
wait_digital_input(1, ON) # Indefinite wait until the no. 1 contact becomes ON 	
wait_digital_input(2, OFF) # Indefinite wait until the no. 2 contact becomes OFF
res = wait_digital_input(1, ON, 3) # Wait for up to 3 seconds until the no. 1 contact becomes ON
    # Waiting is terminated and res = 0 if the no. 1 contact becomes ON within 3 seconds.
    # Waiting is terminated and res = -1 if the no. 1 contact does not become ON within 3 seconds.