Skip to main content
Skip table of contents

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 NameData TypeDefault ValueDescription

index

int

-

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

value

int

-

I/O value

  • ON : 1
  • OFF : 0

timeout

float

-

Waiting time (sec)

This function waits indefinitely if the timeout is not set.

Return

ValueDescription

0

Success

-1

Failed (time-out)

Exception

ExceptionDescription

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

PY
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.
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.