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")
creation_params: RapidCode.CreationParameters = helpers.get_creation_parameters()
controller: RapidCode.MotionController = RapidCode.MotionController.Create(creation_params)
helpers.check_errors(controller)
NODE_INDEX = 0
OUTPUT_INDEX = 0
output0 = RapidCode.IOPoint.CreateDigitalOutput(controller.NetworkNodeGet(NODE_INDEX), OUTPUT_INDEX)
output0.Set(False)
print(f"Output {OUTPUT_INDEX} set to: False")
controller.SampleWait(1)
output_value = output0.Get()
print(f"Output {OUTPUT_INDEX} value: {output_value}")
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()