Skip to content

set_digital_output

Runs at once Any mode Takes control

Switch one of the control box's isolated outputs on or off. The robot takes the new level at once and switches the output within one control tick (4 ms). Outputs 1, 2 and 3 are on terminals 6, 7 and 8 of the control box; an isolated output switches an external voltage. get_hardware() reports every output's level, under "io".

It is not queued: the output switches when the command arrives, while moves sent before it may still be running. To switch it after a move, call wait_idle() first.

Syntax

robot.set_digital_output(pin, value)

Arguments

Name Type Default Description
pin int required The output: 1, 2 or 3. A number with a fraction is cut to a whole number first.
value bool | int required True or 1 switches the output on, False or 0 off. Any other value is refused.

Default values

Every output is off each time the robot software starts, also after a restart.

Returns

Nothing.

Examples

robot.move_joints(90, -105, 165, 0, -30, 180)
robot.wait_idle()
robot.set_digital_output(1, True)
robot.set_digital_output(1, False)

Further details

Warning

The robot never switches an output off by itself: not on an error, a pressed E-stop, disable() or safety_stop(), nor when your program ends or disconnects. Switch outputs off yourself when they must not stay on.

Usage restrictions 3 codes

This command runs at once; it is not queued. The robot accepts it in any mode and state, from the client that holds control or when no client does.

It answers with one of these codes when it does not carry the command out:

  • [6101] Control held by another client — another client holds control; the message names it
  • [6003] Invalid arguments — the pin or the value is missing, or the value is not true or false (1 / 0); only a raw client can send that
  • [6008] Invalid I/O pin — pin is not 1, 2 or 3

In Python, a code above raises CommandRejected; its number is the code. The call raises:

  • CommandRejected: The robot refused it: pin is not 1, 2 or 3, or another client holds control.
  • RobotTimeout: The robot did not answer within 5 s.
  • RobotConnectionError: The client is not connected.
  • ValueError: pin cannot be read as a whole number, for example "one", or value is not True, False, 1 or 0. Nothing is sent.
  • TypeError: pin is None or another type that is no number. Nothing is sent.

If the connection drops while the call waits for the robot's answer, it raises CommandRejected with the code CONNECTION_LOST (DISCONNECTED after disconnect()); while it waits for the robot's status, RobotConnectionError.

Like every immediate command, it also answers BAD_ARGS when a raw client sends a value the robot cannot read at all, and INTERNAL when it fails inside the robot.

Protocol

A client that does not use robotclient sends this over the TCP command protocol (port 29000) for the example above:

{"id": "c1", "cmd": "set_digital_output", "args": [1, true]}

See also