APIs, concepts, guides, and more
IO: Input & Output

Learn how to work with Input/Output operations in Python.

Warning
This is a sample program to assist in the integration of the RMP motion controller with your application. It may not contain all of the logic and safety features that your application requires. We recommend that you wire an external hardware emergency stop (e-stop) button for safety when using our code sample apps. Doing so will help ensure the safety of you and those around you and will prevent potential injury or damage.

The sample apps assume that the system (network, axes, I/O) are configured prior to running the code featured in the sample app. See the Configuration page for more information.


In this page:


📜 IO: IOPoint Objects

Learn how to use IOPoint 📖 objects to read and write network data. Shows how to create IOPoint objects for digital outputs and use them to control IO.

""" This sample demonstrates how to use IOPoint objects to read and write network data.
Shows how to create IOPoint objects for digital outputs and use them to control IO.
Requires an EtherCAT network with nodes that have digital outputs.
"""
from _imports import RapidCode, helpers
print("⬤ IO: IOPoint Objects")
# get/create the motion controller
creation_params: RapidCode.CreationParameters = helpers.get_creation_parameters()
controller: RapidCode.MotionController = RapidCode.MotionController.Create(creation_params)
helpers.check_errors(controller)
NODE_INDEX = 0 # the EtherCAT Node we will be communicating with
OUTPUT_INDEX = 0 # the PDO Index in that Node
# create IOPoint for digital output - automatically gets memory index of specified node and output index
output0 = RapidCode.IOPoint.CreateDigitalOutput(controller.NetworkNodeGet(NODE_INDEX), OUTPUT_INDEX)
# set the output to false
output0.Set(False)
print(f"Output {OUTPUT_INDEX} set to: False")
# wait one sample for the change to take effect
controller.SampleWait(1)
# read back the value
output_value = output0.Get()
print(f"Output {OUTPUT_INDEX} value: {output_value}")
# set the output to true
output0.Set(True)
print(f"Output {OUTPUT_INDEX} set to: True")
controller.SampleWait(1)
output_value = output0.Get()
print(f"Output {OUTPUT_INDEX} value: {output_value}")
controller.Delete()